363 lines
14 KiB
Java
363 lines
14 KiB
Java
package com.ubt.jimu.controller;
|
|
|
|
import android.content.DialogInterface;
|
|
import android.os.Build;
|
|
import android.os.Bundle;
|
|
import android.view.View;
|
|
import android.view.ViewStub;
|
|
import android.widget.Button;
|
|
import android.widget.ImageView;
|
|
import android.widget.TextView;
|
|
import com.alibaba.android.arouter.launcher.ARouter;
|
|
import com.ubt.jimu.BaseActivity;
|
|
import com.ubt.jimu.R;
|
|
import com.ubt.jimu.base.EngineManager;
|
|
import com.ubt.jimu.base.cache.Cache;
|
|
import com.ubt.jimu.base.data.Servo;
|
|
import com.ubt.jimu.base.data.ServoMode;
|
|
import com.ubt.jimu.base.db.diy.DiyDBModel;
|
|
import com.ubt.jimu.base.db.diy.DiyHelper;
|
|
import com.ubt.jimu.base.entities.RobotLite;
|
|
import com.ubt.jimu.base.http.ApiResponse;
|
|
import com.ubt.jimu.controller.view.DragRecycleView;
|
|
import com.ubt.jimu.transport3.DiyTransportServiceImpl;
|
|
import com.ubt.jimu.transport3.bean.response.SaveOrUpdateModelBean;
|
|
import com.ubt.jimu.transport3.dao.DiyDBModelDBHandler;
|
|
import com.ubt.jimu.utils.SystemUtils;
|
|
import com.ubtech.utils.XLog;
|
|
import com.ubtech.view.dialog.SimpleDialog;
|
|
import io.reactivex.Observer;
|
|
import io.reactivex.disposables.Disposable;
|
|
import java.util.ArrayList;
|
|
import java.util.Collections;
|
|
import java.util.List;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class ServoModeSettingActivity extends BaseActivity {
|
|
private TextView a;
|
|
private ImageView b;
|
|
private ImageView c;
|
|
private ImageView d;
|
|
private View e;
|
|
private View f;
|
|
private Button g;
|
|
private EngineManager h;
|
|
private List<Servo> i;
|
|
private List<Servo> j;
|
|
private DragRecycleView k;
|
|
private DragRecycleView l;
|
|
RobotLite mRobotLite;
|
|
private View o;
|
|
private boolean m = false;
|
|
private int n = -1;
|
|
|
|
private void D0() {
|
|
e(false);
|
|
this.b.setOnClickListener(new View.OnClickListener() { // from class: com.ubt.jimu.controller.o0
|
|
@Override // android.view.View.OnClickListener
|
|
public final void onClick(View view) {
|
|
ServoModeSettingActivity.this.a(view);
|
|
}
|
|
});
|
|
}
|
|
|
|
private void E0() {
|
|
this.b.setBackgroundResource(R.mipmap.btn_cancel);
|
|
this.e.setVisibility(8);
|
|
this.c.setVisibility(0);
|
|
this.d.setVisibility(0);
|
|
this.a.setVisibility(0);
|
|
this.f = ((ViewStub) findViewById(R.id.vs_mode_setting)).inflate();
|
|
}
|
|
|
|
private void F0() {
|
|
this.b = (ImageView) findViewById(R.id.iv_left);
|
|
this.b.setOnClickListener(new View.OnClickListener() { // from class: com.ubt.jimu.controller.t0
|
|
@Override // android.view.View.OnClickListener
|
|
public final void onClick(View view) {
|
|
ServoModeSettingActivity.this.b(view);
|
|
}
|
|
});
|
|
this.d = (ImageView) findViewById(R.id.iv_right);
|
|
this.d.setOnClickListener(new View.OnClickListener() { // from class: com.ubt.jimu.controller.r0
|
|
@Override // android.view.View.OnClickListener
|
|
public final void onClick(View view) {
|
|
ServoModeSettingActivity.this.c(view);
|
|
}
|
|
});
|
|
this.c = (ImageView) findViewById(R.id.iv_help);
|
|
this.c.setOnClickListener(new View.OnClickListener() { // from class: com.ubt.jimu.controller.s0
|
|
@Override // android.view.View.OnClickListener
|
|
public final void onClick(View view) {
|
|
ServoModeSettingActivity.this.d(view);
|
|
}
|
|
});
|
|
this.a = (TextView) findViewById(R.id.tv_subhead);
|
|
this.e = findViewById(R.id.servo_mode_des);
|
|
this.g = (Button) findViewById(R.id.btn_mode_config);
|
|
this.g.setOnClickListener(new View.OnClickListener() { // from class: com.ubt.jimu.controller.u0
|
|
@Override // android.view.View.OnClickListener
|
|
public final void onClick(View view) {
|
|
ServoModeSettingActivity.this.e(view);
|
|
}
|
|
});
|
|
}
|
|
|
|
private void G0() {
|
|
if (this.h == null) {
|
|
RobotLite robotLite = this.mRobotLite;
|
|
if (robotLite == null) {
|
|
return;
|
|
} else {
|
|
this.h = new EngineManager(this, robotLite);
|
|
}
|
|
}
|
|
List<Servo> servoList = this.h.getServoList(Cache.getInstance().getUserId());
|
|
if (servoList == null || servoList.size() <= 0) {
|
|
XLog.c("woo", "Has no servos!");
|
|
return;
|
|
}
|
|
this.i = new ArrayList();
|
|
this.j = new ArrayList();
|
|
for (Servo servo : servoList) {
|
|
if (ServoMode.SERVO_MODE_TURN == servo.getModeType()) {
|
|
this.j.add(servo);
|
|
} else {
|
|
this.i.add(servo);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void H0() {
|
|
new SimpleDialog.Builder(this).b(R.string.servo_mode_tips_title).a(R.string.cancel, true).d(R.string.ok).a(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.controller.p0
|
|
@Override // android.content.DialogInterface.OnClickListener
|
|
public final void onClick(DialogInterface dialogInterface, int i) {
|
|
dialogInterface.dismiss();
|
|
}
|
|
}).b(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.controller.v0
|
|
@Override // android.content.DialogInterface.OnClickListener
|
|
public final void onClick(DialogInterface dialogInterface, int i) {
|
|
ServoModeSettingActivity.this.a(dialogInterface, i);
|
|
}
|
|
}).a().show();
|
|
}
|
|
|
|
private void I0() {
|
|
N0();
|
|
EngineManager engineManager = this.h;
|
|
if (engineManager != null) {
|
|
engineManager.save();
|
|
}
|
|
finish();
|
|
}
|
|
|
|
private void J0() {
|
|
this.k = (DragRecycleView) findViewById(R.id.drv_angle);
|
|
this.k.setTitle(R.string.servo_mode_angle);
|
|
this.k.a(R.drawable.ic_angle_null, R.string.servo_mode_angle_tips);
|
|
this.k.a(this.i, new DragRecycleView.OnDragListener() { // from class: com.ubt.jimu.controller.ServoModeSettingActivity.3
|
|
@Override // com.ubt.jimu.controller.view.DragRecycleView.OnDragListener
|
|
public void a(View view, int i) {
|
|
ServoModeSettingActivity servoModeSettingActivity = ServoModeSettingActivity.this;
|
|
servoModeSettingActivity.a(view, i, (List<Servo>) servoModeSettingActivity.i, ServoModeSettingActivity.this.k);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.controller.view.DragRecycleView.OnDragListener
|
|
public void b(Servo servo) {
|
|
ServoModeSettingActivity servoModeSettingActivity = ServoModeSettingActivity.this;
|
|
servoModeSettingActivity.a((List<Servo>) servoModeSettingActivity.i, ServoModeSettingActivity.this.k, servo, ServoMode.SERVO_MODE_ANGLE);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.controller.view.DragRecycleView.OnDragListener
|
|
public void a(Servo servo) {
|
|
ServoModeSettingActivity servoModeSettingActivity = ServoModeSettingActivity.this;
|
|
servoModeSettingActivity.a(servo, (List<Servo>) servoModeSettingActivity.i, ServoModeSettingActivity.this.k, ServoMode.SERVO_MODE_ANGLE);
|
|
}
|
|
});
|
|
}
|
|
|
|
private void K0() {
|
|
e(true);
|
|
this.b.setOnClickListener(new View.OnClickListener() { // from class: com.ubt.jimu.controller.q0
|
|
@Override // android.view.View.OnClickListener
|
|
public final void onClick(View view) {
|
|
ServoModeSettingActivity.this.f(view);
|
|
}
|
|
});
|
|
}
|
|
|
|
private void L0() {
|
|
this.l = (DragRecycleView) findViewById(R.id.drv_turn);
|
|
this.l.setTitle(R.string.servo_mode_turn);
|
|
this.l.a(R.drawable.ic_turn_null, R.string.servo_mode_turn_tips);
|
|
this.l.a(this.j, new DragRecycleView.OnDragListener() { // from class: com.ubt.jimu.controller.ServoModeSettingActivity.2
|
|
@Override // com.ubt.jimu.controller.view.DragRecycleView.OnDragListener
|
|
public void a(View view, int i) {
|
|
ServoModeSettingActivity servoModeSettingActivity = ServoModeSettingActivity.this;
|
|
servoModeSettingActivity.a(view, i, (List<Servo>) servoModeSettingActivity.j, ServoModeSettingActivity.this.l);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.controller.view.DragRecycleView.OnDragListener
|
|
public void b(Servo servo) {
|
|
ServoModeSettingActivity servoModeSettingActivity = ServoModeSettingActivity.this;
|
|
servoModeSettingActivity.a((List<Servo>) servoModeSettingActivity.j, ServoModeSettingActivity.this.l, servo, ServoMode.SERVO_MODE_TURN);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.controller.view.DragRecycleView.OnDragListener
|
|
public void a(Servo servo) {
|
|
ServoModeSettingActivity servoModeSettingActivity = ServoModeSettingActivity.this;
|
|
servoModeSettingActivity.a(servo, (List<Servo>) servoModeSettingActivity.j, ServoModeSettingActivity.this.l, ServoMode.SERVO_MODE_TURN);
|
|
}
|
|
});
|
|
}
|
|
|
|
private void M0() {
|
|
E0();
|
|
G0();
|
|
J0();
|
|
L0();
|
|
}
|
|
|
|
private void N0() {
|
|
DiyDBModel queryForUUid;
|
|
if (this.mRobotLite.isOfficial() || (queryForUUid = DiyHelper.getInstance().queryForUUid(this.mRobotLite.getModelId())) == null || queryForUUid.getStep2state().intValue() == 1) {
|
|
return;
|
|
}
|
|
queryForUUid.setStep2state(1);
|
|
long a = SystemUtils.a();
|
|
queryForUUid.setModifyTime(a);
|
|
queryForUUid.setLastUploadTime(a);
|
|
queryForUUid.setIsModify(true);
|
|
DiyDBModelDBHandler.getInstance().insertOrUpdate(queryForUUid);
|
|
a(queryForUUid);
|
|
}
|
|
|
|
public /* synthetic */ void e(View view) {
|
|
M0();
|
|
}
|
|
|
|
public /* synthetic */ void f(View view) {
|
|
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);
|
|
this.o = View.inflate(this, R.layout.activity_servo_mode_setting, null);
|
|
setContentView(this.o);
|
|
ARouter.b().a(this);
|
|
Object[] objArr = new Object[1];
|
|
RobotLite robotLite = this.mRobotLite;
|
|
objArr[0] = robotLite != null ? robotLite.toString() : "null";
|
|
XLog.a("woo", "mRobot: %s", objArr);
|
|
RobotLite robotLite2 = this.mRobotLite;
|
|
if (robotLite2 != null && robotLite2.isOfficial()) {
|
|
XLog.b("woo", "Official robot shouldn't be here!");
|
|
}
|
|
F0();
|
|
}
|
|
|
|
@Override // com.ubt.jimu.BaseActivity, com.ubt.jimu.ScreenRotationManageActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
|
|
protected void onDestroy() {
|
|
super.onDestroy();
|
|
}
|
|
|
|
@Override // com.ubt.jimu.BaseActivity, com.ubt.jimu.ScreenRotationManageActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
|
|
protected void onResume() {
|
|
super.onResume();
|
|
}
|
|
|
|
private void e(boolean z) {
|
|
this.e.setVisibility(z ? 0 : 8);
|
|
int i = z ? 8 : 0;
|
|
this.f.setVisibility(i);
|
|
this.c.setVisibility(i);
|
|
this.d.setVisibility(i);
|
|
this.a.setVisibility(i);
|
|
this.g.setVisibility(8);
|
|
}
|
|
|
|
public /* synthetic */ void b(View view) {
|
|
finish();
|
|
}
|
|
|
|
public /* synthetic */ void c(View view) {
|
|
H0();
|
|
}
|
|
|
|
public /* synthetic */ void d(View view) {
|
|
K0();
|
|
}
|
|
|
|
public /* synthetic */ void a(View view) {
|
|
finish();
|
|
}
|
|
|
|
public /* synthetic */ void a(DialogInterface dialogInterface, int i) {
|
|
I0();
|
|
}
|
|
|
|
public void a(DiyDBModel diyDBModel) {
|
|
DiyTransportServiceImpl.getInstance().updateModel(diyDBModel, new Observer<ApiResponse<SaveOrUpdateModelBean>>(this) { // from class: com.ubt.jimu.controller.ServoModeSettingActivity.1
|
|
@Override // io.reactivex.Observer
|
|
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
|
public void onNext(ApiResponse<SaveOrUpdateModelBean> apiResponse) {
|
|
XLog.a("Controller", "updateModel onNext");
|
|
}
|
|
|
|
@Override // io.reactivex.Observer
|
|
public void onComplete() {
|
|
XLog.a("Controller", "updateModel complete");
|
|
}
|
|
|
|
@Override // io.reactivex.Observer
|
|
public void onError(Throwable th) {
|
|
th.printStackTrace();
|
|
}
|
|
|
|
@Override // io.reactivex.Observer
|
|
public void onSubscribe(Disposable disposable) {
|
|
}
|
|
});
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void a(List<Servo> list, DragRecycleView dragRecycleView, Servo servo, ServoMode servoMode) {
|
|
if (this.m || servo.getModeType() != servoMode) {
|
|
return;
|
|
}
|
|
list.add(this.n, servo);
|
|
dragRecycleView.a(this.n);
|
|
this.n = -1;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void a(Servo servo, List<Servo> list, DragRecycleView dragRecycleView, ServoMode servoMode) {
|
|
this.m = true;
|
|
this.n = -1;
|
|
servo.setModeType(servoMode);
|
|
list.add(servo);
|
|
EngineManager engineManager = this.h;
|
|
if (engineManager != null) {
|
|
engineManager.updateServoMode(servo);
|
|
}
|
|
Collections.sort(list);
|
|
dragRecycleView.a(list.indexOf(servo));
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void a(View view, int i, List<Servo> list, DragRecycleView dragRecycleView) {
|
|
View.DragShadowBuilder dragShadowBuilder = new View.DragShadowBuilder(view);
|
|
view.performHapticFeedback(0, 2);
|
|
if (Build.VERSION.SDK_INT >= 24) {
|
|
view.startDragAndDrop(null, dragShadowBuilder, list.get(i), 0);
|
|
} else {
|
|
view.startDrag(null, dragShadowBuilder, list.get(i), 0);
|
|
}
|
|
this.m = false;
|
|
this.n = i;
|
|
list.remove(i);
|
|
dragRecycleView.b(i);
|
|
}
|
|
}
|