jimu-decompiled/sources/com/ubt/jimu/pack/view/RobotSelectActivity.java
2025-05-13 19:24:51 +02:00

294 lines
11 KiB
Java

package com.ubt.jimu.pack.view;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.view.View;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestBuilder;
import com.bumptech.glide.request.RequestOptions;
import com.ubt.jimu.JimuApplication;
import com.ubt.jimu.R;
import com.ubt.jimu.base.SuperActivity;
import com.ubt.jimu.base.cache.Cache;
import com.ubt.jimu.base.dialog.JimuSimpleDialog;
import com.ubt.jimu.base.entities.Constant;
import com.ubt.jimu.base.entities.Package;
import com.ubt.jimu.base.entities.Robot;
import com.ubt.jimu.pack.adapter.RobotSelectAdapter;
import com.ubt.jimu.pack.contract.RobotContract$Presenter;
import com.ubt.jimu.pack.contract.RobotContract$View;
import com.ubt.jimu.pack.presenter.RobotPresenter;
import com.ubt.jimu.unity.bluetooth.MyUnityListener;
import com.ubt.jimu.unity.bluetooth.UnityActivity;
import com.ubt.jimu.utils.SPUtils;
import com.ubt.jimu.widgets.LoadStateView;
import com.ubt.jimu.widgets.player.UbtPlayer;
import java.util.List;
/* loaded from: classes2.dex */
public class RobotSelectActivity extends SuperActivity implements View.OnClickListener, RobotContract$View, RobotSelectAdapter.ListItemOnClickListener, LoadStateView.RetryListener {
private RobotSelectAdapter a;
private int b;
private int c;
private long d;
private String e;
private String f;
private RobotPresenter g;
ImageView im_robot_pack;
ImageView imgPlayPackageVideo;
LoadStateView load_state;
RelativeLayout rl_pack_click;
RelativeLayout rl_play_package_video;
RecyclerView rv_robot_list;
private void D0() {
final Package a = this.g.a(this.d);
if (a == null) {
this.rl_play_package_video.setVisibility(8);
return;
}
if (TextUtils.isEmpty(a.getVideoUrl())) {
this.rl_play_package_video.setVisibility(8);
return;
}
this.rl_play_package_video.setVisibility(0);
this.imgPlayPackageVideo.post(new Runnable() { // from class: com.ubt.jimu.pack.view.j
@Override // java.lang.Runnable
public final void run() {
RobotSelectActivity.this.b(a);
}
});
if (a.getPlayed() > 0) {
return;
}
c(a);
}
private void E0() {
RobotPresenter robotPresenter = this.g;
if (robotPresenter != null) {
robotPresenter.unSubscribe();
}
setResult(8);
finish();
}
public static void a(Context context, String str, long j, String str2, int i, int i2) {
Intent intent = new Intent(context, (Class<?>) RobotSelectActivity.class);
intent.putExtra(Constant.SelectRobot.PACKAGEID_KEY, j);
intent.putExtra(Constant.SelectRobot.PACKAGE_NAME_KEY, str);
intent.putExtra(Constant.SelectRobot.PACKAGE_IMAGE_PATH_KEY, str2);
intent.putExtra(Constant.SelectRobot.BUNDLE_KEY_FROM, i);
intent.putExtra(MyUnityListener.CALLER, i2);
((Activity) context).startActivityForResult(intent, 9);
}
static /* synthetic */ void a(DialogInterface dialogInterface, int i) {
}
static /* synthetic */ void b(DialogInterface dialogInterface, int i) {
}
private void c(final Package r3) {
JimuSimpleDialog.showWifiOnlyDialog(this, new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.pack.view.i
@Override // android.content.DialogInterface.OnClickListener
public final void onClick(DialogInterface dialogInterface, int i) {
RobotSelectActivity.b(dialogInterface, i);
}
}, new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.pack.view.g
@Override // android.content.DialogInterface.OnClickListener
public final void onClick(DialogInterface dialogInterface, int i) {
RobotSelectActivity.this.a(r3, dialogInterface, i);
}
}, false);
}
@Override // com.ubt.jimu.pack.contract.RobotContract$View
public void Z() {
if (this.b == 7) {
this.rl_pack_click.setVisibility(8);
} else {
this.rl_pack_click.setVisibility(0);
}
this.load_state.a(LoadStateView.LoadState.SUCCEED);
}
@Override // com.ubtech.view.BaseView
/* renamed from: a, reason: merged with bridge method [inline-methods] */
public void setPresenter(RobotContract$Presenter robotContract$Presenter) {
}
public /* synthetic */ void b(Package r2) {
RequestBuilder<Drawable> a = Glide.a(this.imgPlayPackageVideo).a(r2.getVideoThumbnail());
a.a(new RequestOptions().b());
a.a(this.imgPlayPackageVideo);
}
@Override // com.ubt.jimu.base.SuperActivity
protected void initData() {
Intent intent = getIntent();
this.d = intent.getLongExtra(Constant.SelectRobot.PACKAGEID_KEY, 0L);
this.e = intent.getStringExtra(Constant.SelectRobot.PACKAGE_NAME_KEY);
this.f = intent.getStringExtra(Constant.SelectRobot.PACKAGE_IMAGE_PATH_KEY);
this.b = intent.getIntExtra(Constant.SelectRobot.BUNDLE_KEY_FROM, 0);
this.c = intent.getIntExtra(MyUnityListener.CALLER, 0);
this.g = new RobotPresenter(this);
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) this.rv_robot_list.getLayoutParams();
if (this.b == 7) {
layoutParams.addRule(3, R.id.nbv_bar);
this.rl_pack_click.setVisibility(8);
this.rl_pack_click.setEnabled(false);
this.g.a();
} else {
layoutParams.addRule(3, this.rl_pack_click.getId());
this.g.b(this.d);
}
if (!TextUtils.isEmpty(this.f)) {
Glide.e(JimuApplication.l()).a(this.f).a(this.im_robot_pack);
}
this.rv_robot_list.setLayoutAnimation(AnimationUtils.loadLayoutAnimation(this, R.anim.recyclerview_layoutanimation));
this.rv_robot_list.setLayoutManager(new LinearLayoutManager(this, 0, false));
this.a = new RobotSelectAdapter(this);
this.rv_robot_list.setAdapter(this.a);
D0();
}
@Override // com.ubt.jimu.base.SuperActivity
protected void initEvent() {
this.rl_pack_click.setOnClickListener(this);
this.im_robot_pack.setOnClickListener(this);
this.a.a(this);
this.load_state.setRetryListener(this);
}
@Override // com.ubt.jimu.base.SuperActivity
public View initView() {
getWindow().requestFeature(12);
return View.inflate(this, R.layout.activity_select_robot_layout, null);
}
@Override // com.ubt.jimu.pack.contract.RobotContract$View
public void j(List<Robot> list) {
if (list == null || list.size() == 0) {
this.load_state.a(LoadStateView.LoadState.EMPTY);
} else {
this.rl_pack_click.setVisibility(0);
this.a.a(list);
}
}
@Override // androidx.fragment.app.FragmentActivity, android.app.Activity
protected void onActivityResult(int i, int i2, Intent intent) {
super.onActivityResult(i, i2, intent);
if (i == 9 && i2 == 8) {
E0();
}
}
@Override // androidx.fragment.app.FragmentActivity, android.app.Activity
public void onBackPressed() {
finishAfterTransition();
}
@Override // android.view.View.OnClickListener
public void onClick(View view) {
int id = view.getId();
if (id == R.id.im_robot_pack || id == R.id.rl_pack_click) {
PackSelectActivity.a(this, this.b, this.d);
finish();
}
}
protected void onPlayPackageVideo(View view) {
Package a = this.g.a(this.d);
if (a == null || TextUtils.isEmpty(a.getVideoUrl())) {
return;
}
if (a.getPlayed() > 0) {
UbtPlayer.a(this, "", a.getVideoUrl());
} else {
c(a);
}
}
@Override // com.ubt.jimu.BaseActivity, com.ubt.jimu.ScreenRotationManageActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
protected void onResume() {
super.onResume();
}
@Override // com.ubt.jimu.widgets.LoadStateView.RetryListener
public void p0() {
if (this.b != 7) {
this.g.b(this.d);
return;
}
this.rl_pack_click.setVisibility(8);
this.rl_pack_click.setEnabled(false);
this.g.a();
}
@Override // com.ubt.jimu.pack.contract.RobotContract$View
public void q() {
this.rl_pack_click.setVisibility(8);
this.load_state.a(LoadStateView.LoadState.EMPTY);
}
@Override // com.ubt.jimu.pack.contract.RobotContract$View
public void v() {
this.rl_pack_click.setVisibility(8);
this.load_state.a(LoadStateView.LoadState.LOADING);
}
@Override // com.ubt.jimu.pack.contract.RobotContract$View
public void y() {
this.load_state.a(LoadStateView.LoadState.FAILURE);
}
@Override // com.ubt.jimu.pack.adapter.RobotSelectAdapter.ListItemOnClickListener
public void a(int i, final Robot robot, View view, View view2) {
if (robot == null) {
return;
}
if (robot.isAllDownloaded()) {
Cache.getInstance().setPackageName(this.e);
SPUtils.a(Constant.SelectRobot.INTERSTELLAR_ADVENTURE_SELECT_PACKAGE_KEY, this.e);
Cache.getInstance().setRobot(robot);
Cache.getInstance().setPackageId(this.d);
Cache.getInstance().setPackageImagePath(this.f);
UnityActivity.startUnityActivity(this, robot, this.b, this.c, "");
E0();
return;
}
JimuSimpleDialog.showWifiOnlyDialog(this, new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.pack.view.h
@Override // android.content.DialogInterface.OnClickListener
public final void onClick(DialogInterface dialogInterface, int i2) {
RobotSelectActivity.a(dialogInterface, i2);
}
}, new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.pack.view.f
@Override // android.content.DialogInterface.OnClickListener
public final void onClick(DialogInterface dialogInterface, int i2) {
RobotSelectActivity.this.a(robot, dialogInterface, i2);
}
}, false);
}
public /* synthetic */ void a(Robot robot, DialogInterface dialogInterface, int i) {
DownloadRobotActivity.a(this, robot, this.e, this.d, this.f, this.b, this.c, "");
}
public /* synthetic */ void a(Package r1, DialogInterface dialogInterface, int i) {
r1.setPlayed(1);
this.g.a(r1);
UbtPlayer.a(this, "", r1.getVideoUrl());
}
}