jimu-decompiled/sources/com/ubt/jimu/controller/JockstickSettingActivity.java
2025-05-13 19:24:51 +02:00

938 lines
35 KiB
Java

package com.ubt.jimu.controller;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewStub;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.alibaba.android.arouter.facade.Postcard;
import com.alibaba.android.arouter.launcher.ARouter;
import com.ubt.jimu.R;
import com.ubt.jimu.base.EngineManager;
import com.ubt.jimu.base.SuperActivity;
import com.ubt.jimu.base.data.CtrlMotionType;
import com.ubt.jimu.base.data.Engine;
import com.ubt.jimu.base.data.ServoMode;
import com.ubt.jimu.base.entities.RobotLite;
import com.ubt.jimu.connect.model.Component;
import com.ubt.jimu.controller.adapter.SelectEngineListAdapter;
import com.ubt.jimu.controller.data.command.Gear;
import com.ubt.jimu.controller.data.config.JockstickConfig;
import com.ubt.jimu.controller.data.config.Wheel;
import com.ubt.jimu.controller.manager.CommandManager;
import com.ubt.jimu.controller.manager.MoveConfigManager;
import com.ubt.jimu.controller.presenter.JockstickSettingPresenter;
import com.ubt.jimu.controller.view.JockstickSettingView;
import com.ubt.jimu.utils.LogUtils;
import com.ubt.jimu.utils.SystemUtils;
import com.ubt.jimu.widgets.JAlertDialog;
import com.ubt.jimu.widgets.UniversalPopupWindow;
import com.ubtech.utils.XLog;
import com.ubtech.view.dialog.SimpleDialog;
import com.ubtech.view.widget.ToastView;
import com.ubtrobot.jimu.exception.RobotActiveException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/* loaded from: classes.dex */
public class JockstickSettingActivity extends SuperActivity implements JockstickSettingView, View.OnClickListener, SelectEngineListAdapter.OnItemClickListener {
private Bitmap A;
private Bitmap B;
private ArrayList<ImageView> C;
private ArrayList<ImageView> D;
private JockstickSettingPresenter E;
private List<Engine> G;
private Dialog H;
private JAlertDialog I;
private Animation J;
private Animation K;
private ImageView L;
ImageView a;
ImageView b;
ImageView btn_back;
ImageView c;
ImageView d;
ImageView e;
ImageView f;
ImageView g;
ImageView h;
private ImageView i;
ImageView im_control_affirm;
ImageView im_control_delete;
private ImageView j;
private ImageView k;
private ImageView l;
String mConfigId;
int mJockType;
RobotLite mRobotLite;
private SelectEngineListAdapter n;
private JockstickConfig o;
private JockstickConfig p;
private View q;
private View r;
RecyclerView rv_engine_list;
private View s;
private View t;
private Bitmap u;
private Bitmap v;
ViewStub vs_four_servo;
ViewStub vs_six_servo;
ViewStub vs_two_servo;
private Bitmap x;
private Bitmap y;
private EngineManager z;
private int m = 1;
private CtrlMotionType F = null;
/* renamed from: com.ubt.jimu.controller.JockstickSettingActivity$3, reason: invalid class name */
static /* synthetic */ class AnonymousClass3 {
static final /* synthetic */ int[] a = new int[ServoOrientationState.values().length];
static {
try {
a[ServoOrientationState.HIDE.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
a[ServoOrientationState.CLOCKWISE_ONCLICK.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
a[ServoOrientationState.CLOCKWISE_FORBIDDEN.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
try {
a[ServoOrientationState.ANTICLOCKWISE_ONCLICK.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
try {
a[ServoOrientationState.ANTICLOCKWISE_FORBIDDEN.ordinal()] = 5;
} catch (NoSuchFieldError unused5) {
}
}
}
enum ServoOrientationState {
CLOCKWISE_ONCLICK,
CLOCKWISE_FORBIDDEN,
ANTICLOCKWISE_ONCLICK,
ANTICLOCKWISE_FORBIDDEN,
HIDE
}
private void E0() {
if (TextUtils.isEmpty(this.mConfigId) || this.o.getMotionType() != CtrlMotionType.servo) {
return;
}
b(this.o.getServoList(), ServoMode.SERVO_MODE_TURN);
}
private void F0() {
JAlertDialog.Builder builder = new JAlertDialog.Builder(this);
builder.b(false);
builder.a(R.drawable.ic_loading);
builder.a(true);
this.I = builder.a();
this.I.show();
}
private void G0() {
UniversalPopupWindow.a(this).c(getResources().getString(R.string.delete_data_remind)).a(getResources().getString(R.string.cancel)).b(getResources().getString(R.string.ok)).a(new UniversalPopupWindow.UniversalPopupWindowListener() { // from class: com.ubt.jimu.controller.JockstickSettingActivity.2
@Override // com.ubt.jimu.widgets.UniversalPopupWindow.UniversalPopupWindowListener
public void a() {
JockstickSettingActivity.this.E.a(JockstickSettingActivity.this.o);
JockstickSettingActivity jockstickSettingActivity = JockstickSettingActivity.this;
ToastView.a(jockstickSettingActivity, jockstickSettingActivity.getResources().getString(R.string.delete_success), ToastView.Type.NORMAL).a();
JockstickSettingActivity.this.I0();
}
@Override // com.ubt.jimu.widgets.UniversalPopupWindow.UniversalPopupWindowListener
public void onCancel() {
}
}).a(this.t);
}
private void H0() {
JAlertDialog jAlertDialog = this.I;
if (jAlertDialog == null || !jAlertDialog.isShowing()) {
return;
}
this.I.dismiss();
}
/* JADX INFO: Access modifiers changed from: private */
public void I0() {
if (TextUtils.isEmpty(this.mConfigId)) {
setResult(-1);
} else {
Intent intent = new Intent();
intent.putExtra("configId", this.mConfigId);
setResult(-1, intent);
}
finish();
}
private List<Engine> J0() {
this.G = this.E.a(false);
return this.G;
}
private void K0() {
if (TextUtils.isEmpty(this.mConfigId)) {
this.o = new JockstickConfig();
JockstickConfig jockstickConfig = this.o;
int i = this.mJockType;
jockstickConfig.setType(i == 2 ? JockstickConfig.JockType.twoServo : i == 4 ? JockstickConfig.JockType.fourServo : JockstickConfig.JockType.sixServo);
this.im_control_delete.setVisibility(8);
} else {
this.im_control_delete.setVisibility(0);
this.o = (JockstickConfig) MoveConfigManager.a(getApplicationContext()).a(this.mConfigId);
if (this.o == null) {
this.o = new JockstickConfig();
}
JockstickConfig.JockType type = this.o.getType();
if (type == JockstickConfig.JockType.twoServo) {
this.mJockType = 2;
} else if (type == JockstickConfig.JockType.fourServo) {
this.mJockType = 4;
} else if (type == JockstickConfig.JockType.sixServo) {
this.mJockType = 6;
}
this.F = this.o.getMotionType();
}
this.p = this.o.cloneJockstickConfig();
this.n.a(this.p);
}
private void L0() {
Bitmap bitmap;
Bitmap bitmap2;
this.u = BitmapFactory.decodeResource(getResources(), R.drawable.engine_select);
this.x = BitmapFactory.decodeResource(getResources(), R.drawable.select_engine_onclick);
this.v = BitmapFactory.decodeResource(getResources(), R.drawable.bg_engine_2);
this.y = BitmapFactory.decodeResource(getResources(), R.drawable.select_engine_none);
this.A = BitmapFactory.decodeResource(getResources(), R.drawable.motor_s);
this.B = BitmapFactory.decodeResource(getResources(), R.drawable.motor_d);
int i = this.mJockType;
if (i == 2) {
View view = this.q;
if (view == null) {
this.q = this.vs_two_servo.inflate();
} else {
view.setVisibility(0);
}
b(this.q);
} else if (i == 4) {
View view2 = this.r;
if (view2 == null) {
this.r = this.vs_four_servo.inflate();
} else {
view2.setVisibility(0);
}
initFourServoLayout(this.r);
} else if (i == 6) {
View view3 = this.s;
if (view3 == null) {
this.s = this.vs_six_servo.inflate();
} else {
view3.setVisibility(0);
}
a(this.s);
}
boolean isOK = this.o.isOK();
this.im_control_affirm.setEnabled(isOK);
this.im_control_affirm.setAlpha(isOK ? 1.0f : 0.4f);
this.btn_back.setBackgroundResource(R.mipmap.btn_cancel);
this.im_control_delete.setBackgroundResource(R.mipmap.control_delete_icon);
CtrlMotionType motionType = this.o.getMotionType();
if (motionType == CtrlMotionType.servo) {
bitmap = this.u;
bitmap2 = this.v;
} else {
bitmap = this.A;
bitmap2 = this.B;
}
Wheel wheel = this.o.getWheel(1);
boolean z = wheel != null && wheel.getId() > 0;
ImageView imageView = this.b;
if (!z) {
bitmap = this.x;
}
imageView.setImageBitmap(bitmap);
if (z) {
ServoOrientationState b = b(wheel);
this.f.setClickable(true);
a(b, this.f);
this.n.b(a(motionType, wheel, J0()));
}
Wheel wheel2 = this.o.getWheel(2);
boolean z2 = wheel2 != null && wheel2.getId() > 0;
this.c.setImageBitmap(z2 ? bitmap2 : this.y);
if (z2) {
this.e.setClickable(false);
a(a(wheel2), this.e);
}
if (this.mJockType == 4) {
Wheel wheel3 = this.o.getWheel(3);
boolean z3 = wheel3 != null && wheel3.getId() > 0;
this.a.setImageBitmap(z3 ? bitmap2 : this.y);
if (z3) {
this.g.setClickable(false);
a(a(wheel3), this.g);
}
Wheel wheel4 = this.o.getWheel(4);
boolean z4 = wheel4 != null && wheel4.getId() > 0;
this.d.setImageBitmap(z4 ? bitmap2 : this.y);
if (z4) {
this.h.setClickable(false);
a(a(wheel4), this.h);
}
}
if (this.mJockType == 6) {
Wheel wheel5 = this.o.getWheel(3);
boolean z5 = wheel5 != null && wheel5.getId() > 0;
this.a.setImageBitmap(z5 ? bitmap2 : this.y);
if (z5) {
this.g.setClickable(false);
a(a(wheel5), this.g);
}
Wheel wheel6 = this.o.getWheel(4);
boolean z6 = wheel6 != null && wheel6.getId() > 0;
this.d.setImageBitmap(z6 ? bitmap2 : this.y);
if (z6) {
this.h.setClickable(false);
a(a(wheel6), this.h);
}
Wheel wheel7 = this.o.getWheel(5);
boolean z7 = wheel7 != null && wheel7.getId() > 0;
this.i.setImageBitmap(z7 ? bitmap2 : this.y);
if (z7) {
this.k.setClickable(false);
a(a(wheel7), this.k);
}
Wheel wheel8 = this.o.getWheel(6);
boolean z8 = wheel8 != null && wheel8.getId() > 0;
ImageView imageView2 = this.j;
if (!z8) {
bitmap2 = this.y;
}
imageView2.setImageBitmap(bitmap2);
if (z8) {
this.l.setClickable(false);
a(a(wheel8), this.l);
}
}
}
private void l(int i) {
Wheel wheel = this.p.getWheel(i);
if (wheel != null) {
wheel.setReverse(!wheel.isReverse());
a(b(wheel), this.D.get(i - 1));
}
}
private void m(int i) {
Wheel wheel = this.p.getWheel(i);
if (wheel == null || wheel.getId() <= 0) {
return;
}
int i2 = i % 2 == 0 ? 1 : -1;
if (wheel.isReverse()) {
i2 = -i2;
}
ImageView imageView = this.C.get(i - 1);
if (imageView != null) {
if (i2 == 1) {
imageView.startAnimation(this.J);
} else {
imageView.startAnimation(this.K);
}
this.L = imageView;
}
this.E.a(this.p.getMotionType(), wheel.getId(), Gear.FIFTH, i2);
}
@Override // com.ubt.jimu.controller.adapter.SelectEngineListAdapter.OnItemClickListener
public void A0() {
if (this.mRobotLite.isOfficial()) {
ToastView.a(this, getResources().getString(R.string.control_config_official)).a();
} else {
UniversalPopupWindow.a(this).c(getResources().getString(R.string.rotate_360)).a(new UniversalPopupWindow.UniversalPopupWindowListener() { // from class: com.ubt.jimu.controller.JockstickSettingActivity.1
@Override // com.ubt.jimu.widgets.UniversalPopupWindow.UniversalPopupWindowListener
public void a() {
Postcard a = ARouter.b().a("/controller/servosettings");
a.a("robotLite", JockstickSettingActivity.this.mRobotLite);
a.t();
}
@Override // com.ubt.jimu.widgets.UniversalPopupWindow.UniversalPopupWindowListener
public void onCancel() {
}
}).a(this.t);
}
}
public boolean D0() {
MoveConfigManager a = MoveConfigManager.a(getApplicationContext());
List<JockstickConfig> d = a.d();
int i = 0;
if (d != null && d.size() > 0) {
int i2 = 0;
for (JockstickConfig jockstickConfig : d) {
if (!jockstickConfig.getConfigID().equals(this.o.getConfigID())) {
if (this.p.equals(jockstickConfig)) {
ToastView.a(this, R.string.control_config_exist).a();
return false;
}
if (jockstickConfig.getType() == this.o.getType()) {
i2++;
}
}
}
i = i2;
}
if (TextUtils.isEmpty(this.mConfigId)) {
this.o.setIndex(i + 1);
}
this.o.setWheelList(this.p.getWheelList());
this.o.setMotionType(this.p.getMotionType());
a.a(this.o);
a.a(true);
return true;
}
@Override // com.ubt.jimu.base.SuperActivity
protected void initData() {
ARouter.b().a(this);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
linearLayoutManager.k(0);
this.rv_engine_list.setLayoutManager(linearLayoutManager);
this.n = new SelectEngineListAdapter(this);
this.rv_engine_list.setAdapter(this.n);
this.E = new JockstickSettingPresenter(this, this.mRobotLite);
LogUtils.c("initData:");
K0();
L0();
}
@Override // com.ubt.jimu.base.SuperActivity
protected void initEvent() {
this.n.a(this);
this.im_control_delete.setOnClickListener(this);
}
public void initFourServoLayout(View view) {
this.b = (ImageView) view.findViewById(R.id.im_front_left_engine);
this.c = (ImageView) view.findViewById(R.id.im_front_right_engine);
this.a = (ImageView) view.findViewById(R.id.im_left_back_engine);
this.d = (ImageView) view.findViewById(R.id.im_right_back_engine);
this.f = (ImageView) view.findViewById(R.id.im_orientation_flag_top);
this.f.setOnClickListener(this);
this.e = (ImageView) view.findViewById(R.id.im_orientation_flag_bottom);
this.e.setOnClickListener(this);
this.g = (ImageView) view.findViewById(R.id.im_orientation_top_l);
this.g.setOnClickListener(this);
this.h = (ImageView) view.findViewById(R.id.im_orientation_bottom_l);
this.h.setOnClickListener(this);
this.b.setOnClickListener(this);
this.c.setOnClickListener(this);
this.a.setOnClickListener(this);
this.d.setOnClickListener(this);
this.btn_back.setOnClickListener(this);
this.im_control_affirm.setOnClickListener(this);
this.C = new ArrayList<>();
this.C.add(this.b);
this.C.add(this.c);
this.C.add(this.a);
this.C.add(this.d);
this.D = new ArrayList<>();
this.D.add(this.f);
this.D.add(this.e);
this.D.add(this.g);
this.D.add(this.h);
}
@Override // com.ubt.jimu.base.SuperActivity
public View initView() {
this.t = View.inflate(this, R.layout.activity_wheel_set, null);
this.J = AnimationUtils.loadAnimation(this, R.anim.rotate_clockwise);
this.K = AnimationUtils.loadAnimation(this, R.anim.rotate_disclock);
return this.t;
}
@Override // android.view.View.OnClickListener
public void onClick(View view) {
switch (view.getId()) {
case R.id.btn_back /* 2131296371 */:
finish();
break;
case R.id.im_control_affirm /* 2131296715 */:
if (D0()) {
I0();
break;
}
break;
case R.id.im_control_delete /* 2131296717 */:
G0();
break;
case R.id.im_front_left_engine /* 2131296735 */:
a(1, this.F);
m(1);
this.m = 1;
break;
case R.id.im_front_right_engine /* 2131296736 */:
a(2, this.F);
m(2);
this.m = 2;
break;
case R.id.im_left_back_engine /* 2131296760 */:
a(3, this.F);
m(3);
this.m = 3;
break;
case R.id.im_left_middle_engine /* 2131296761 */:
a(5, this.F);
m(5);
this.m = 5;
break;
case R.id.im_orientation_bottom_l /* 2131296767 */:
l(4);
m(4);
break;
case R.id.im_orientation_flag_bottom /* 2131296768 */:
l(2);
m(2);
break;
case R.id.im_orientation_flag_middle_bottom /* 2131296769 */:
l(6);
m(6);
break;
case R.id.im_orientation_flag_middle_top /* 2131296770 */:
l(5);
m(5);
break;
case R.id.im_orientation_flag_top /* 2131296771 */:
l(1);
m(1);
break;
case R.id.im_orientation_top_l /* 2131296772 */:
l(3);
m(3);
break;
case R.id.im_right_back_engine /* 2131296793 */:
a(4, this.F);
m(4);
this.m = 4;
break;
case R.id.im_right_middle_engine /* 2131296794 */:
a(6, this.F);
m(6);
this.m = 6;
break;
}
}
@Override // com.ubt.jimu.BaseActivity, com.ubt.jimu.ScreenRotationManageActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
protected void onDestroy() {
ImageView imageView = this.L;
if (imageView != null) {
imageView.clearAnimation();
}
this.E.h();
super.onDestroy();
}
@Override // com.ubt.jimu.BaseActivity, com.ubt.jimu.ScreenRotationManageActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
protected void onPause() {
this.E.j();
super.onPause();
}
@Override // com.ubt.jimu.BaseActivity, com.ubt.jimu.ScreenRotationManageActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
protected void onResume() {
super.onResume();
this.n.a(J0());
EngineManager c = this.E.c();
if (c != null) {
CommandManager.a(getApplicationContext()).a(c);
}
E0();
this.E.g();
}
@Override // android.app.Activity, android.view.Window.Callback
public void onWindowFocusChanged(boolean z) {
if (z) {
this.E.k();
}
}
private ServoOrientationState a(Wheel wheel) {
if (wheel.getPosition() % 2 == 0) {
return wheel.isReverse() ? ServoOrientationState.ANTICLOCKWISE_FORBIDDEN : ServoOrientationState.CLOCKWISE_FORBIDDEN;
}
return wheel.isReverse() ? ServoOrientationState.CLOCKWISE_FORBIDDEN : ServoOrientationState.ANTICLOCKWISE_FORBIDDEN;
}
private ServoOrientationState b(Wheel wheel) {
if (wheel.getPosition() % 2 == 0) {
return wheel.isReverse() ? ServoOrientationState.ANTICLOCKWISE_ONCLICK : ServoOrientationState.CLOCKWISE_ONCLICK;
}
return wheel.isReverse() ? ServoOrientationState.CLOCKWISE_ONCLICK : ServoOrientationState.ANTICLOCKWISE_ONCLICK;
}
private void d(String str) {
new SimpleDialog.Builder(this).a((CharSequence) str).d(R.string.ok).a(R.string.cancel, true).b(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.controller.n0
@Override // android.content.DialogInterface.OnClickListener
public final void onClick(DialogInterface dialogInterface, int i) {
JockstickSettingActivity.this.b(dialogInterface, i);
}
}).a(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.controller.i0
@Override // android.content.DialogInterface.OnClickListener
public final void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
}).a().show();
}
private void a(View view) {
this.b = (ImageView) view.findViewById(R.id.im_front_left_engine);
this.c = (ImageView) view.findViewById(R.id.im_front_right_engine);
this.a = (ImageView) view.findViewById(R.id.im_left_back_engine);
this.i = (ImageView) view.findViewById(R.id.im_left_middle_engine);
this.d = (ImageView) view.findViewById(R.id.im_right_back_engine);
this.j = (ImageView) view.findViewById(R.id.im_right_middle_engine);
this.f = (ImageView) view.findViewById(R.id.im_orientation_flag_top);
this.f.setOnClickListener(this);
this.k = (ImageView) view.findViewById(R.id.im_orientation_flag_middle_top);
this.k.setOnClickListener(this);
this.e = (ImageView) view.findViewById(R.id.im_orientation_flag_bottom);
this.e.setOnClickListener(this);
this.l = (ImageView) view.findViewById(R.id.im_orientation_flag_middle_bottom);
this.l.setOnClickListener(this);
this.g = (ImageView) view.findViewById(R.id.im_orientation_top_l);
this.g.setOnClickListener(this);
this.h = (ImageView) view.findViewById(R.id.im_orientation_bottom_l);
this.h.setOnClickListener(this);
this.b.setOnClickListener(this);
this.c.setOnClickListener(this);
this.a.setOnClickListener(this);
this.i.setOnClickListener(this);
this.d.setOnClickListener(this);
this.j.setOnClickListener(this);
this.btn_back.setOnClickListener(this);
this.im_control_affirm.setOnClickListener(this);
this.C = new ArrayList<>();
this.C.add(this.b);
this.C.add(this.c);
this.C.add(this.a);
this.C.add(this.d);
this.C.add(this.i);
this.C.add(this.j);
this.D = new ArrayList<>();
this.D.add(this.f);
this.D.add(this.e);
this.D.add(this.g);
this.D.add(this.h);
this.D.add(this.k);
this.D.add(this.l);
}
private void b(View view) {
this.b = (ImageView) view.findViewById(R.id.im_front_left_engine);
this.c = (ImageView) view.findViewById(R.id.im_front_right_engine);
this.f = (ImageView) view.findViewById(R.id.im_orientation_flag_top);
this.f.setOnClickListener(this);
this.e = (ImageView) view.findViewById(R.id.im_orientation_flag_bottom);
this.e.setOnClickListener(this);
this.b.setOnClickListener(this);
this.c.setOnClickListener(this);
this.btn_back.setOnClickListener(this);
this.im_control_affirm.setOnClickListener(this);
this.C = new ArrayList<>();
this.C.add(this.b);
this.C.add(this.c);
this.D = new ArrayList<>();
this.D.add(this.f);
this.D.add(this.e);
}
private boolean b(List<Integer> list, ServoMode servoMode) {
this.z = this.E.c();
if (this.z == null || list == null || list.size() <= 0) {
return true;
}
ArrayList arrayList = new ArrayList();
Iterator<Integer> it = list.iterator();
boolean z = true;
while (it.hasNext()) {
int intValue = it.next().intValue();
if (this.z.getServoMode(intValue) != servoMode) {
arrayList.add(Integer.valueOf(intValue));
z = false;
}
}
if (!z) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < arrayList.size(); i++) {
String format = String.format(getResources().getString(R.string.servo_mode_servo_index), arrayList.get(i));
if (i == 0) {
sb.append(format);
} else {
sb.append(",");
sb.append(format);
}
}
d(String.format(getResources().getString(R.string.control_servo_mode_set), sb.toString()));
}
return z;
}
public /* synthetic */ void b(DialogInterface dialogInterface, int i) {
Postcard a = ARouter.b().a("/controller/servosettings");
a.a("robotLite", this.mRobotLite);
a.t();
dialogInterface.dismiss();
}
@Override // com.ubt.jimu.controller.view.JockstickSettingView
public void b(boolean z) {
if (z) {
return;
}
ToastView.a(this, getResources().getString(R.string.ble_connect_hint)).a();
}
public /* synthetic */ void b(String str, final RobotActiveException robotActiveException, final List list, boolean z) {
Dialog dialog = this.H;
if (dialog == null || !dialog.isShowing()) {
SimpleDialog.Builder builder = new SimpleDialog.Builder(this);
SimpleDialog.Builder b = builder.a((CharSequence) str).d(R.string.ok).b(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.controller.f0
@Override // android.content.DialogInterface.OnClickListener
public final void onClick(DialogInterface dialogInterface, int i) {
JockstickSettingActivity.this.a(robotActiveException, list, dialogInterface, i);
}
});
b.b(false);
b.a(false);
if (z) {
builder.a(R.string.cancel, true).a(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.controller.h0
@Override // android.content.DialogInterface.OnClickListener
public final void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
});
}
this.H = builder.a();
this.H.show();
}
}
@Override // com.ubt.jimu.controller.adapter.SelectEngineListAdapter.OnItemClickListener
public void a(final Engine engine, int i) {
if (this.p == null) {
return;
}
CtrlMotionType motionType = engine.getMotionType();
CtrlMotionType ctrlMotionType = this.F;
if (ctrlMotionType != null && ctrlMotionType != motionType) {
LogUtils.c("engine:" + this.F);
new SimpleDialog.Builder(this).b(R.string.control_jockstick_reset).d(R.string.ok).a(R.string.cancel, true).b(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.controller.j0
@Override // android.content.DialogInterface.OnClickListener
public final void onClick(DialogInterface dialogInterface, int i2) {
JockstickSettingActivity.this.a(engine, dialogInterface, i2);
}
}).a(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.controller.k0
@Override // android.content.DialogInterface.OnClickListener
public final void onClick(DialogInterface dialogInterface, int i2) {
dialogInterface.dismiss();
}
}).a().show();
return;
}
a(engine);
}
@Override // com.ubt.jimu.controller.view.IBaseControllerView
public void b(List<Component> list) {
this.E.a(list);
}
public /* synthetic */ void a(Engine engine, DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
this.p.emptyWheelList();
a(engine);
}
private void a(Engine engine) {
CtrlMotionType motionType = engine.getMotionType();
this.F = motionType;
this.p.setMotionType(motionType);
this.p.checkEngineExist(engine.getId());
this.p.putWheel(this.m, new Wheel(engine.getId(), this.m));
this.E.a(motionType, engine.getId(), Gear.FIFTH, this.m % 2 == 0 ? 1 : -1);
a(this.m, motionType);
SystemUtils.b(this);
}
private void a(int i, CtrlMotionType ctrlMotionType) {
Bitmap bitmap;
Bitmap bitmap2;
int i2;
if (ctrlMotionType == CtrlMotionType.servo) {
bitmap = this.u;
bitmap2 = this.v;
} else {
bitmap = this.A;
bitmap2 = this.B;
}
Wheel wheel = this.p.getWheel(i);
int i3 = -1;
if (wheel != null) {
i2 = wheel.getId();
if (i2 > 0) {
i3 = a(ctrlMotionType, wheel, this.G);
}
} else {
i2 = 0;
}
this.n.b(i3);
int i4 = 0;
while (i4 < this.C.size()) {
int i5 = i4 + 1;
Wheel wheel2 = this.p.getWheel(i5);
int id = wheel2 != null ? wheel2.getId() : 0;
ImageView imageView = this.C.get(i4);
if (id == i2 && i == i5) {
imageView.setImageBitmap(id > 0 ? bitmap : this.x);
} else {
imageView.setImageBitmap(id > 0 ? bitmap2 : this.y);
}
ImageView imageView2 = this.D.get(i4);
if (id == i2 && i == i5) {
ServoOrientationState b = id > 0 ? b(wheel2) : ServoOrientationState.HIDE;
imageView2.setClickable(true);
a(b, imageView2);
} else {
ServoOrientationState a = id > 0 ? a(wheel2) : ServoOrientationState.HIDE;
imageView2.setClickable(false);
a(a, imageView2);
}
if (this.p.isOK()) {
this.im_control_affirm.setEnabled(true);
this.im_control_affirm.setAlpha(1.0f);
} else {
this.im_control_affirm.setEnabled(false);
this.im_control_affirm.setAlpha(0.4f);
}
i4 = i5;
}
}
private int a(CtrlMotionType ctrlMotionType, Wheel wheel, List<Engine> list) {
if (list != null && list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
Engine engine = list.get(i);
if (engine.getMotionType() == ctrlMotionType && engine.getId() == wheel.getId()) {
return i;
}
}
}
return -1;
}
private void a(ServoOrientationState servoOrientationState, ImageView imageView) {
if (imageView == null) {
return;
}
imageView.setVisibility(0);
int i = AnonymousClass3.a[servoOrientationState.ordinal()];
if (i == 1) {
imageView.setVisibility(8);
return;
}
if (i == 2) {
imageView.setBackgroundResource(R.mipmap.orientation_clockwise_onclick);
return;
}
if (i == 3) {
imageView.setBackgroundResource(R.mipmap.orientation_clockwise_forbid);
} else if (i == 4) {
imageView.setBackgroundResource(R.mipmap.orientation_anticlockwise_onclick);
} else {
if (i != 5) {
return;
}
imageView.setBackgroundResource(R.mipmap.orientation_anticlockwise_forbid);
}
}
@Override // com.ubt.jimu.controller.view.IBaseControllerView
public void a(final String str, final RobotActiveException robotActiveException, final List<Integer> list, final boolean z) {
runOnUiThread(new Runnable() { // from class: com.ubt.jimu.controller.l0
@Override // java.lang.Runnable
public final void run() {
JockstickSettingActivity.this.b(str, robotActiveException, list, z);
}
});
}
public /* synthetic */ void a(RobotActiveException robotActiveException, List list, DialogInterface dialogInterface, int i) {
this.E.a(robotActiveException, (List<Integer>) list);
dialogInterface.dismiss();
}
@Override // com.ubt.jimu.controller.view.IBaseControllerView
public void a(boolean z) {
XLog.a("woo", "loading: %b", Boolean.valueOf(z));
if (z) {
JAlertDialog jAlertDialog = this.I;
if ((jAlertDialog != null && jAlertDialog.isShowing()) || isFinishing() || isDestroyed()) {
return;
}
F0();
return;
}
H0();
}
@Override // com.ubt.jimu.controller.view.IBaseControllerView
public void a(Throwable th) {
th.printStackTrace();
ToastView.a(this, R.string.control_request_error).a();
}
@Override // com.ubt.jimu.controller.view.IBaseControllerView
public void a(List<Component> list) {
if (list == null || list.size() <= 0) {
return;
}
new SimpleDialog.Builder(this).a((CharSequence) this.E.a(this, list)).d(R.string.ok).a(R.string.cancel, true).b(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.controller.m0
@Override // android.content.DialogInterface.OnClickListener
public final void onClick(DialogInterface dialogInterface, int i) {
JockstickSettingActivity.this.a(dialogInterface, i);
}
}).a(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.controller.g0
@Override // android.content.DialogInterface.OnClickListener
public final void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
}).a().show();
}
public /* synthetic */ void a(DialogInterface dialogInterface, int i) {
this.E.f();
dialogInterface.dismiss();
}
}