Initial commit

This commit is contained in:
2025-05-13 19:24:51 +02:00
commit a950f49678
10604 changed files with 932663 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
package com.ubt.jimu.ar.contract;
import com.ubt.jimu.base.entities.Package;
import com.ubt.jimu.base.entities.Robot;
import com.ubtech.presenter.BasePresenter;
/* loaded from: classes.dex */
public interface GameListContract$Presenter extends BasePresenter {
void a(Package r1, Robot robot);
void a(String str);
boolean h();
}

View File

@@ -0,0 +1,23 @@
package com.ubt.jimu.ar.contract;
import android.content.Context;
import com.ubt.jimu.base.download.DownloadTask;
import com.ubt.jimu.base.entities.Robot;
import com.ubtech.view.BaseView;
/* loaded from: classes.dex */
public interface GameListContract$View extends BaseView<GameListContract$Presenter> {
void a(DownloadTask downloadTask);
void a(Robot robot);
Context b();
void b(Robot robot);
void onDownloadFail();
void onProgress(int i, int i2, int i3);
void onStartDownload();
}

View File

@@ -0,0 +1,25 @@
package com.ubt.jimu.ar.model;
import android.app.ActivityManager;
import android.content.Context;
import android.os.Build;
import android.util.Log;
import com.ubt.jimu.JimuApplication;
import com.ubt.jimu.utils.DeviceUtils;
/* loaded from: classes.dex */
public class ArGameSupportModel {
private Context a = JimuApplication.l().getApplicationContext();
public boolean a() {
if (Build.VERSION.SDK_INT < 23 || DeviceUtils.a() < 4) {
return false;
}
ActivityManager.MemoryInfo c = DeviceUtils.c(this.a);
if (c != null) {
return ((c.totalMem >> 10) >> 10) >= 1000;
}
Log.e("ArGameSupportModel", "Get memory info fail!");
return false;
}
}

View File

@@ -0,0 +1,118 @@
package com.ubt.jimu.ar.presenter;
import android.util.Log;
import com.ubt.jimu.ar.contract.GameListContract$Presenter;
import com.ubt.jimu.ar.contract.GameListContract$View;
import com.ubt.jimu.ar.model.ArGameSupportModel;
import com.ubt.jimu.base.cache.Cache;
import com.ubt.jimu.base.db.robot.RobotDbHandler;
import com.ubt.jimu.base.download.DownloadTask;
import com.ubt.jimu.base.download.Downloader;
import com.ubt.jimu.base.entities.Package;
import com.ubt.jimu.base.entities.Robot;
import com.ubt.jimu.discover.CourseRepository;
import com.ubt.jimu.utils.RxSchedulers;
import io.reactivex.Observer;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;
import java.util.concurrent.Executors;
/* loaded from: classes.dex */
public class GameListPresenterImp implements GameListContract$Presenter {
private ArGameSupportModel a;
private GameListContract$View b;
private CompositeDisposable c;
public GameListPresenterImp(GameListContract$View gameListContract$View) {
Executors.newSingleThreadExecutor();
this.c = new CompositeDisposable();
this.b = gameListContract$View;
this.a = new ArGameSupportModel();
}
@Override // com.ubt.jimu.ar.contract.GameListContract$Presenter
public boolean h() {
return this.a.a();
}
@Override // com.ubt.jimu.ar.contract.GameListContract$Presenter
public void a(Package r3, Robot robot) {
if (r3 != null && robot != null) {
Cache.getInstance().setPackageName(r3.getPackageName());
Cache.getInstance().setRobot(robot);
Cache.getInstance().setPackageId(r3.getId());
Cache.getInstance().setPackageImagePath(r3.getPackageImage());
return;
}
Log.e("GameListPresenterImp", "Package or robot is null. package:" + r3 + " robot:" + robot);
}
@Override // com.ubt.jimu.ar.contract.GameListContract$Presenter
public void a(String str) {
Robot robotByModelName = RobotDbHandler.getRobotByModelName(str);
if (robotByModelName != null) {
if (!robotByModelName.isAllDownloaded()) {
a(robotByModelName);
return;
} else {
this.b.b(robotByModelName);
return;
}
}
CourseRepository.a(this.b.b(), "dujiaoshou").compose(RxSchedulers.a()).subscribe(new Observer<Robot>() { // from class: com.ubt.jimu.ar.presenter.GameListPresenterImp.1
@Override // io.reactivex.Observer
/* renamed from: a, reason: merged with bridge method [inline-methods] */
public void onNext(Robot robot) {
if (robot == null || robot.getState() == -100) {
GameListPresenterImp.this.b.onDownloadFail();
} else if (robot.isAllDownloaded()) {
GameListPresenterImp.this.b.b(robot);
} else {
GameListPresenterImp.this.a(robot);
}
}
@Override // io.reactivex.Observer
public void onComplete() {
}
@Override // io.reactivex.Observer
public void onError(Throwable th) {
Log.e("GameListPresenterImp", "Get model info by model name fail!", th);
GameListPresenterImp.this.b.onDownloadFail();
}
@Override // io.reactivex.Observer
public void onSubscribe(Disposable disposable) {
Log.i("GameListPresenterImp", "onSubscribe");
GameListPresenterImp.this.c.b(disposable);
}
});
}
public DownloadTask a(final Robot robot) {
DownloadTask downloadJimuRobot = Downloader.downloadJimuRobot(robot, new Downloader.IDownloadJimuRobotListener() { // from class: com.ubt.jimu.ar.presenter.GameListPresenterImp.2
@Override // com.ubt.jimu.base.download.Downloader.IDownloadJimuRobotListener
public void onFailed() {
GameListPresenterImp.this.b.onDownloadFail();
}
@Override // com.ubt.jimu.base.download.Downloader.IDownloadJimuRobotListener
public void onPrepareStart() {
GameListPresenterImp.this.b.onStartDownload();
}
@Override // com.ubt.jimu.base.download.Downloader.IDownloadJimuRobotListener
public void onProgress(int i, int i2, int i3) {
GameListPresenterImp.this.b.onProgress(i, i2, i3);
}
@Override // com.ubt.jimu.base.download.Downloader.IDownloadJimuRobotListener
public void onSuccess() {
GameListPresenterImp.this.b.a(robot);
}
});
this.b.a(downloadJimuRobot);
return downloadJimuRobot;
}
}

View File

@@ -0,0 +1,278 @@
package com.ubt.jimu.ar.view;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.AnimationSet;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.ubt.jimu.BaseActivity;
import com.ubt.jimu.R;
import com.ubt.jimu.ar.contract.GameListContract$Presenter;
import com.ubt.jimu.ar.contract.GameListContract$View;
import com.ubt.jimu.ar.presenter.GameListPresenterImp;
import com.ubt.jimu.base.download.DownloadTask;
import com.ubt.jimu.base.entities.Package;
import com.ubt.jimu.base.entities.Robot;
import com.ubt.jimu.unity.bluetooth.UnityActivity;
import com.ubt.jimu.widgets.NavigationBarView;
import com.ubtech.view.dialog.SimpleDialog;
/* loaded from: classes.dex */
public class GameListActivity extends BaseActivity implements GameListContract$View, View.OnClickListener {
private NavigationBarView a;
private ImageView b;
private ImageView c;
private ImageView d;
private ImageView e;
private View f;
private ImageView g;
private TextView h;
private RelativeLayout i;
private GameListContract$Presenter j;
private AnimationDrawable k;
private Handler l;
public Package m;
private volatile int o;
private DownloadTask q;
private Runnable n = new Runnable() { // from class: com.ubt.jimu.ar.view.GameListActivity.1
@Override // java.lang.Runnable
public void run() {
GameListActivity.this.F0();
}
};
private boolean p = false;
private void E0() {
this.j.a("dujiaoshou");
}
/* JADX INFO: Access modifiers changed from: private */
public void F0() {
AnimationSet animationSet = new AnimationSet(true);
AlphaAnimation alphaAnimation = new AlphaAnimation(1.0f, 0.0f);
alphaAnimation.setDuration(5000L);
animationSet.addAnimation(alphaAnimation);
animationSet.setFillAfter(true);
this.i.startAnimation(animationSet);
}
private void initView() {
setContentView(R.layout.activity_ar_game_list);
this.a = (NavigationBarView) findViewById(R.id.nbv_bar);
this.a.setTitleColor(-1);
this.b = (ImageView) findViewById(R.id.iv_butterfly1);
this.c = (ImageView) findViewById(R.id.iv_butterfly2);
this.d = (ImageView) findViewById(R.id.iv_butterfly3);
this.e = (ImageView) findViewById(R.id.iv_butterfly4);
findViewById(R.id.img_rainbow_world).setOnClickListener(this);
findViewById(R.id.img_flower_world).setOnClickListener(this);
this.f = findViewById(R.id.fl_download);
this.f.setVisibility(8);
this.g = (ImageView) findViewById(R.id.iv_loading);
this.h = (TextView) findViewById(R.id.tv_progress);
this.i = (RelativeLayout) findViewById(R.id.rl_warning);
}
public void D0() {
new SimpleDialog.Builder(this).d(R.string.ok).b(new DialogInterface.OnClickListener(this) { // from class: com.ubt.jimu.ar.view.GameListActivity.5
@Override // android.content.DialogInterface.OnClickListener
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
}).a((CharSequence) getString(R.string.device_not_support_ar)).a().show();
}
@Override // android.view.View.OnClickListener
public void onClick(View view) {
int id = view.getId();
if (id == R.id.img_flower_world) {
this.o = 2;
if (this.j.h()) {
E0();
return;
} else {
D0();
return;
}
}
if (id != R.id.img_rainbow_world) {
Log.e(this.TAG, "");
return;
}
this.o = 1;
if (this.j.h()) {
E0();
} else {
D0();
}
}
@Override // com.ubt.jimu.BaseActivity, com.ubt.jimu.ScreenRotationManageActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, androidx.core.app.ComponentActivity, android.app.Activity
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
initView();
this.j = new GameListPresenterImp(this);
this.l = new Handler(getMainLooper());
Intent intent = getIntent();
if (intent != null) {
this.m = (Package) intent.getSerializableExtra("PACKAGE");
}
if (this.m == null) {
this.i.setVisibility(8);
} else {
this.i.setVisibility(0);
this.l.postDelayed(this.n, 5000L);
}
}
@Override // com.ubt.jimu.BaseActivity, com.ubt.jimu.ScreenRotationManageActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
public void onDestroy() {
DownloadTask downloadTask = this.q;
if (downloadTask != null) {
downloadTask.pause();
this.q = null;
}
this.b.clearAnimation();
this.c.clearAnimation();
this.d.clearAnimation();
this.e.clearAnimation();
this.i.clearAnimation();
this.l.removeCallbacks(this.n);
super.onDestroy();
}
@Override // com.ubt.jimu.ar.contract.GameListContract$View
public void onDownloadFail() {
this.p = false;
toastError(getString(R.string.tips_download_failed));
View view = this.f;
if (view != null) {
view.setVisibility(8);
}
this.g.clearAnimation();
}
@Override // com.ubt.jimu.BaseActivity, androidx.appcompat.app.AppCompatActivity, android.app.Activity, android.view.KeyEvent.Callback
public boolean onKeyDown(int i, KeyEvent keyEvent) {
if (i == 4 && this.p) {
return true;
}
return super.onKeyDown(i, keyEvent);
}
@Override // com.ubt.jimu.ar.contract.GameListContract$View
public void onProgress(int i, int i2, int i3) {
if (i == 1) {
this.h.setText(i3 + "%");
return;
}
int i4 = 100 / i;
int i5 = (i2 * i4) - (((100 - i3) * i4) / 100);
this.h.setText(i5 + "%");
Log.i(this.TAG, "percent:" + i5);
}
@Override // com.ubt.jimu.ar.contract.GameListContract$View
public void onStartDownload() {
this.p = true;
this.f.setVisibility(0);
RotateAnimation rotateAnimation = new RotateAnimation(0.0f, 359.0f, 1, 0.5f, 1, 0.5f);
rotateAnimation.setRepeatCount(-1);
rotateAnimation.setDuration(800L);
rotateAnimation.setInterpolator(new LinearInterpolator());
rotateAnimation.setRepeatMode(1);
this.g.startAnimation(rotateAnimation);
}
@Override // android.app.Activity, android.view.Window.Callback
public void onWindowFocusChanged(boolean z) {
super.onWindowFocusChanged(z);
if (z) {
this.k = (AnimationDrawable) this.b.getDrawable();
this.k.start();
this.k = (AnimationDrawable) this.e.getDrawable();
this.k.start();
this.l.postDelayed(new Runnable() { // from class: com.ubt.jimu.ar.view.GameListActivity.2
@Override // java.lang.Runnable
public void run() {
GameListActivity gameListActivity = GameListActivity.this;
gameListActivity.k = (AnimationDrawable) gameListActivity.c.getDrawable();
GameListActivity.this.k.start();
GameListActivity gameListActivity2 = GameListActivity.this;
gameListActivity2.k = (AnimationDrawable) gameListActivity2.d.getDrawable();
GameListActivity.this.k.start();
}
}, 300L);
}
}
@Override // com.ubt.jimu.ar.contract.GameListContract$View
public void b(Robot robot) {
Package r0;
if (robot != null && (r0 = this.m) != null) {
this.j.a(r0, robot);
}
int i = this.o;
if (i == 1) {
d(robot);
} else if (i != 2) {
Log.e(this.TAG, "Invalid gameId, do nothing");
} else {
c(robot);
}
}
public void c(final Robot robot) {
runOnUiThread(new Runnable() { // from class: com.ubt.jimu.ar.view.GameListActivity.4
@Override // java.lang.Runnable
public void run() {
UnityActivity.gotoFlowerWorldGamePage(GameListActivity.this, robot);
GameListActivity.this.finish();
}
});
}
public void d(final Robot robot) {
runOnUiThread(new Runnable() { // from class: com.ubt.jimu.ar.view.GameListActivity.3
@Override // java.lang.Runnable
public void run() {
UnityActivity.gotoRainbowWorldGamePage(GameListActivity.this, robot);
GameListActivity.this.finish();
}
});
}
@Override // com.ubt.jimu.ar.contract.GameListContract$View
public void a(DownloadTask downloadTask) {
this.q = downloadTask;
}
@Override // com.ubt.jimu.ar.contract.GameListContract$View
public void a(Robot robot) {
if (this.q != null) {
this.q = null;
}
View view = this.f;
if (view != null) {
view.setVisibility(8);
this.g.clearAnimation();
}
b(robot);
}
@Override // com.ubt.jimu.ar.contract.GameListContract$View
public Context b() {
return getApplicationContext();
}
}