Initial commit
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package com.ubt.jimu.controller;
|
||||
|
||||
import com.alibaba.android.arouter.facade.service.SerializationService;
|
||||
import com.alibaba.android.arouter.facade.template.ISyringe;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.ubt.jimu.base.entities.RobotLite;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AccumulatorSettingActivity$$ARouter$$Autowired implements ISyringe {
|
||||
private SerializationService serializationService;
|
||||
|
||||
@Override // com.alibaba.android.arouter.facade.template.ISyringe
|
||||
public void inject(Object obj) {
|
||||
this.serializationService = (SerializationService) ARouter.b().a(SerializationService.class);
|
||||
AccumulatorSettingActivity accumulatorSettingActivity = (AccumulatorSettingActivity) obj;
|
||||
accumulatorSettingActivity.mRobotLite = (RobotLite) accumulatorSettingActivity.getIntent().getParcelableExtra("robotLite");
|
||||
accumulatorSettingActivity.mConfigId = accumulatorSettingActivity.getIntent().getStringExtra("config_id_key");
|
||||
}
|
||||
}
|
||||
422
sources/com/ubt/jimu/controller/AccumulatorSettingActivity.java
Normal file
422
sources/com/ubt/jimu/controller/AccumulatorSettingActivity.java
Normal file
@@ -0,0 +1,422 @@
|
||||
package com.ubt.jimu.controller;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
import android.util.SparseArray;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
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.Servo;
|
||||
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.AngleSetListAdapter;
|
||||
import com.ubt.jimu.controller.component.TensionAngleSetView;
|
||||
import com.ubt.jimu.controller.data.config.AccumulatorConfig;
|
||||
import com.ubt.jimu.controller.data.config.WidgetConfig;
|
||||
import com.ubt.jimu.controller.manager.CommandManager;
|
||||
import com.ubt.jimu.controller.manager.MoveConfigManager;
|
||||
import com.ubt.jimu.controller.presenter.AccumulatorSettingPresenter;
|
||||
import com.ubt.jimu.controller.view.IAccumulatorSettingView;
|
||||
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 com.ubtrobot.jimu.robotapi.ServoAngleReadInfo;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AccumulatorSettingActivity extends SuperActivity implements View.OnClickListener, AngleSetListAdapter.SteerEngineListItemOnClickListener, TensionAngleSetView.AngleUpdateListener, IAccumulatorSettingView {
|
||||
private AngleSetListAdapter a;
|
||||
ImageView angle_delete;
|
||||
ImageView angle_ok;
|
||||
TensionAngleSetView angle_set_view;
|
||||
private int b = WidgetConfig.MIN_ANGLE;
|
||||
private int c = 118;
|
||||
private int d;
|
||||
private MoveConfigManager e;
|
||||
private AccumulatorConfig f;
|
||||
private Dialog g;
|
||||
private JAlertDialog h;
|
||||
private AccumulatorSettingPresenter i;
|
||||
ImageView im_back;
|
||||
ImageView im_select_engine;
|
||||
private SparseArray<AccumulatorConfig> j;
|
||||
RelativeLayout layout_default_page;
|
||||
String mConfigId;
|
||||
RobotLite mRobotLite;
|
||||
RecyclerView rv_angle_list;
|
||||
|
||||
private void D0() {
|
||||
JAlertDialog.Builder builder = new JAlertDialog.Builder(this);
|
||||
builder.b(false);
|
||||
builder.a(R.drawable.ic_loading);
|
||||
builder.a(true);
|
||||
this.h = builder.a();
|
||||
this.h.show();
|
||||
}
|
||||
|
||||
private void E0() {
|
||||
UniversalPopupWindow.a(this).c(getResources().getString(R.string.delete_data_remind)).a(getResources().getString(R.string.btn_cancel_publish)).b(getResources().getString(R.string.ok)).a(new UniversalPopupWindow.UniversalPopupWindowListener() { // from class: com.ubt.jimu.controller.AccumulatorSettingActivity.1
|
||||
@Override // com.ubt.jimu.widgets.UniversalPopupWindow.UniversalPopupWindowListener
|
||||
public void a() {
|
||||
AccumulatorSettingActivity.this.i.a(AccumulatorSettingActivity.this.f);
|
||||
AccumulatorSettingActivity accumulatorSettingActivity = AccumulatorSettingActivity.this;
|
||||
ToastView.a(accumulatorSettingActivity, accumulatorSettingActivity.getResources().getString(R.string.delete_success), ToastView.Type.NORMAL).a();
|
||||
AccumulatorSettingActivity.this.G0();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.UniversalPopupWindow.UniversalPopupWindowListener
|
||||
public void onCancel() {
|
||||
}
|
||||
}).a(this.mRootView);
|
||||
}
|
||||
|
||||
private void F0() {
|
||||
JAlertDialog jAlertDialog = this.h;
|
||||
if (jAlertDialog == null || !jAlertDialog.isShowing()) {
|
||||
return;
|
||||
}
|
||||
this.h.dismiss();
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void G0() {
|
||||
if (TextUtils.isEmpty(this.mConfigId)) {
|
||||
setResult(-1);
|
||||
} else {
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra("configId", this.mConfigId);
|
||||
setResult(-1, intent);
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
private void H0() {
|
||||
AccumulatorConfig accumulatorConfig;
|
||||
List<Servo> b = this.i.b(false);
|
||||
if (b == null || b.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
this.j = new SparseArray<>(b.size());
|
||||
for (Servo servo : b) {
|
||||
if (servo != null) {
|
||||
int i = this.d;
|
||||
if (i <= 0 || i != servo.getId()) {
|
||||
accumulatorConfig = new AccumulatorConfig();
|
||||
accumulatorConfig.setServoID((byte) servo.getId());
|
||||
accumulatorConfig.setStartAngle(WidgetConfig.MIN_ANGLE);
|
||||
accumulatorConfig.setLaunchAngle(118);
|
||||
} else {
|
||||
accumulatorConfig = new AccumulatorConfig(this.f.getConfigID(), this.f.getServoID(), this.f.getStartAngle(), this.f.getLaunchAngle());
|
||||
}
|
||||
this.j.put(servo.getId(), accumulatorConfig);
|
||||
}
|
||||
}
|
||||
this.i.a(b.size());
|
||||
}
|
||||
|
||||
private void I0() {
|
||||
int i = this.d;
|
||||
if (i <= 0) {
|
||||
XLog.b("woo", "saveData Servo Id should be %d", Integer.valueOf(i));
|
||||
return;
|
||||
}
|
||||
if (this.f == null) {
|
||||
this.f = new AccumulatorConfig();
|
||||
}
|
||||
this.f.setServoID(this.d);
|
||||
this.f.setStartAngle(this.b);
|
||||
this.f.setLaunchAngle(this.c);
|
||||
this.e.a(this.f);
|
||||
this.e.a(true);
|
||||
}
|
||||
|
||||
private int l(int i) {
|
||||
if (i < -118) {
|
||||
return WidgetConfig.MIN_ANGLE;
|
||||
}
|
||||
if (i > 118) {
|
||||
return 118;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.view.IAccumulatorSettingView
|
||||
public void Y() {
|
||||
ToastView.a(this, getResources().getString(R.string.no_configuration_servo), ToastView.Type.NORMAL).a();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.view.IAccumulatorSettingView
|
||||
public 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.b
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public final void onClick(DialogInterface dialogInterface, int i) {
|
||||
AccumulatorSettingActivity.this.b(dialogInterface, i);
|
||||
}
|
||||
}).a(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.controller.d
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public final void onClick(DialogInterface dialogInterface, int i) {
|
||||
dialogInterface.dismiss();
|
||||
}
|
||||
}).a().show();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.view.IAccumulatorSettingView
|
||||
public void g(List<ServoAngleReadInfo> list) {
|
||||
AccumulatorConfig accumulatorConfig;
|
||||
if (list == null || list.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
for (ServoAngleReadInfo servoAngleReadInfo : list) {
|
||||
if (servoAngleReadInfo != null && servoAngleReadInfo.b() > 0 && this.d != servoAngleReadInfo.b() && (accumulatorConfig = this.j.get(servoAngleReadInfo.b())) != null) {
|
||||
accumulatorConfig.setStartAngle((int) servoAngleReadInfo.a());
|
||||
accumulatorConfig.setLaunchAngle((int) servoAngleReadInfo.a());
|
||||
this.j.put(servoAngleReadInfo.b(), accumulatorConfig);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.SuperActivity
|
||||
public void initData() {
|
||||
ARouter.b().a(this);
|
||||
this.i = new AccumulatorSettingPresenter(this, this.mRobotLite);
|
||||
this.a = new AngleSetListAdapter(this);
|
||||
this.rv_angle_list.setLayoutManager(new LinearLayoutManager(this));
|
||||
this.rv_angle_list.setAdapter(this.a);
|
||||
this.e = MoveConfigManager.a(getApplicationContext());
|
||||
if (TextUtils.isEmpty(this.mConfigId)) {
|
||||
this.f = new AccumulatorConfig();
|
||||
this.angle_delete.setVisibility(8);
|
||||
this.layout_default_page.setVisibility(0);
|
||||
this.i.a(this.mRobotLite);
|
||||
} else {
|
||||
this.f = (AccumulatorConfig) this.e.a(this.mConfigId);
|
||||
if (this.f != null) {
|
||||
this.angle_delete.setVisibility(0);
|
||||
this.layout_default_page.setVisibility(8);
|
||||
this.c = this.f.getLaunchAngle();
|
||||
this.b = this.f.getStartAngle();
|
||||
this.d = this.f.getServoID();
|
||||
this.angle_set_view.a(this.f.getStartAngle(), this.f.getLaunchAngle());
|
||||
}
|
||||
}
|
||||
this.a.a(this.f);
|
||||
this.im_back.setImageResource(R.mipmap.btn_cancel);
|
||||
this.im_select_engine.setBackgroundResource(R.mipmap.select_engine);
|
||||
this.angle_ok.setBackgroundResource(R.mipmap.affirm_controller);
|
||||
this.angle_delete.setBackgroundResource(R.mipmap.control_delete_icon);
|
||||
H0();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.SuperActivity
|
||||
public void initEvent() {
|
||||
this.im_back.setOnClickListener(this);
|
||||
this.angle_ok.setOnClickListener(this);
|
||||
this.a.a(this);
|
||||
this.angle_delete.setOnClickListener(this);
|
||||
this.angle_set_view.setAngleUpdateListener(this);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.SuperActivity
|
||||
public View initView() {
|
||||
return View.inflate(this, R.layout.activity_tension_angle_setting, null);
|
||||
}
|
||||
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.angle_delete /* 2131296319 */:
|
||||
E0();
|
||||
break;
|
||||
case R.id.angle_ok /* 2131296320 */:
|
||||
I0();
|
||||
G0();
|
||||
break;
|
||||
case R.id.im_back /* 2131296709 */:
|
||||
finish();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.BaseActivity, com.ubt.jimu.ScreenRotationManageActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
|
||||
protected void onDestroy() {
|
||||
this.i.h();
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.BaseActivity, com.ubt.jimu.ScreenRotationManageActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
|
||||
protected void onPause() {
|
||||
this.i.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.a.a(this.i.b(true));
|
||||
EngineManager c = this.i.c();
|
||||
if (c != null) {
|
||||
CommandManager.a(getApplicationContext()).a(c);
|
||||
}
|
||||
int i = this.d;
|
||||
if (i > 0) {
|
||||
this.i.a(i, ServoMode.SERVO_MODE_ANGLE);
|
||||
}
|
||||
this.i.g();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.adapter.AngleSetListAdapter.SteerEngineListItemOnClickListener
|
||||
public void a(Servo servo) {
|
||||
this.layout_default_page.setVisibility(8);
|
||||
this.d = (byte) servo.getId();
|
||||
AccumulatorConfig accumulatorConfig = this.j.get(this.d);
|
||||
if (accumulatorConfig != null) {
|
||||
int l = l(accumulatorConfig.getStartAngle());
|
||||
int l2 = l(accumulatorConfig.getLaunchAngle());
|
||||
this.angle_set_view.a(l, l2);
|
||||
this.b = l;
|
||||
this.c = l2;
|
||||
}
|
||||
}
|
||||
|
||||
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.adapter.AngleSetListAdapter.SteerEngineListItemOnClickListener
|
||||
public void b(Servo servo) {
|
||||
if (this.mRobotLite.isOfficial()) {
|
||||
ToastView.a(this, R.string.control_config_official).a();
|
||||
} else {
|
||||
d(getResources().getString(R.string.nonsupport));
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.component.TensionAngleSetView.AngleUpdateListener
|
||||
public void b(double d) {
|
||||
this.b = (int) d;
|
||||
AccumulatorConfig accumulatorConfig = this.j.get(this.d);
|
||||
if (accumulatorConfig != null) {
|
||||
accumulatorConfig.setStartAngle(this.b);
|
||||
}
|
||||
this.i.a(this.mRobotLite, this.d, this.b);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.component.TensionAngleSetView.AngleUpdateListener
|
||||
public void d(double d) {
|
||||
this.c = (int) d;
|
||||
AccumulatorConfig accumulatorConfig = this.j.get(this.d);
|
||||
if (accumulatorConfig != null) {
|
||||
accumulatorConfig.setLaunchAngle(this.c);
|
||||
}
|
||||
this.i.a(this.mRobotLite, this.d, this.c);
|
||||
}
|
||||
|
||||
@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.e
|
||||
@Override // java.lang.Runnable
|
||||
public final void run() {
|
||||
AccumulatorSettingActivity.this.b(str, robotActiveException, list, z);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public /* synthetic */ void a(RobotActiveException robotActiveException, List list, DialogInterface dialogInterface, int i) {
|
||||
this.i.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.h;
|
||||
if ((jAlertDialog != null && jAlertDialog.isShowing()) || isFinishing() || isDestroyed()) {
|
||||
return;
|
||||
}
|
||||
D0();
|
||||
return;
|
||||
}
|
||||
F0();
|
||||
}
|
||||
|
||||
public /* synthetic */ void b(String str, final RobotActiveException robotActiveException, final List list, boolean z) {
|
||||
Dialog dialog = this.g;
|
||||
if (dialog == null || !dialog.isShowing()) {
|
||||
SimpleDialog.Builder builder = new SimpleDialog.Builder(this);
|
||||
SimpleDialog.Builder b = builder.a((CharSequence) str).d(R.string.ok).a(R.string.cancel, true).a(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.controller.h
|
||||
@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.g
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public final void onClick(DialogInterface dialogInterface, int i) {
|
||||
AccumulatorSettingActivity.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.c
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public final void onClick(DialogInterface dialogInterface, int i) {
|
||||
dialogInterface.dismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
this.g = builder.a();
|
||||
this.g.show();
|
||||
}
|
||||
}
|
||||
|
||||
@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.i.a(this, list)).d(R.string.ok).a(R.string.cancel, true).b(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.controller.a
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public final void onClick(DialogInterface dialogInterface, int i) {
|
||||
AccumulatorSettingActivity.this.a(dialogInterface, i);
|
||||
}
|
||||
}).a(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.controller.f
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public final void onClick(DialogInterface dialogInterface, int i) {
|
||||
dialogInterface.dismiss();
|
||||
}
|
||||
}).a().show();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.view.IBaseControllerView
|
||||
public void b(List<Component> list) {
|
||||
this.i.a(list);
|
||||
}
|
||||
|
||||
public /* synthetic */ void a(DialogInterface dialogInterface, int i) {
|
||||
this.i.f();
|
||||
dialogInterface.dismiss();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.ubt.jimu.controller;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import butterknife.Unbinder;
|
||||
import butterknife.internal.Utils;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.controller.component.TensionAngleSetView;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AccumulatorSettingActivity_ViewBinding implements Unbinder {
|
||||
private AccumulatorSettingActivity b;
|
||||
|
||||
public AccumulatorSettingActivity_ViewBinding(AccumulatorSettingActivity accumulatorSettingActivity, View view) {
|
||||
this.b = accumulatorSettingActivity;
|
||||
accumulatorSettingActivity.im_back = (ImageView) Utils.b(view, R.id.im_back, "field 'im_back'", ImageView.class);
|
||||
accumulatorSettingActivity.angle_ok = (ImageView) Utils.b(view, R.id.angle_ok, "field 'angle_ok'", ImageView.class);
|
||||
accumulatorSettingActivity.angle_delete = (ImageView) Utils.b(view, R.id.angle_delete, "field 'angle_delete'", ImageView.class);
|
||||
accumulatorSettingActivity.im_select_engine = (ImageView) Utils.b(view, R.id.im_select_engine, "field 'im_select_engine'", ImageView.class);
|
||||
accumulatorSettingActivity.rv_angle_list = (RecyclerView) Utils.b(view, R.id.rv_angle_list, "field 'rv_angle_list'", RecyclerView.class);
|
||||
accumulatorSettingActivity.layout_default_page = (RelativeLayout) Utils.b(view, R.id.layout_default_page, "field 'layout_default_page'", RelativeLayout.class);
|
||||
accumulatorSettingActivity.angle_set_view = (TensionAngleSetView) Utils.b(view, R.id.angle_set_view, "field 'angle_set_view'", TensionAngleSetView.class);
|
||||
}
|
||||
|
||||
@Override // butterknife.Unbinder
|
||||
public void unbind() {
|
||||
AccumulatorSettingActivity accumulatorSettingActivity = this.b;
|
||||
if (accumulatorSettingActivity == null) {
|
||||
throw new IllegalStateException("Bindings already cleared.");
|
||||
}
|
||||
this.b = null;
|
||||
accumulatorSettingActivity.im_back = null;
|
||||
accumulatorSettingActivity.angle_ok = null;
|
||||
accumulatorSettingActivity.angle_delete = null;
|
||||
accumulatorSettingActivity.im_select_engine = null;
|
||||
accumulatorSettingActivity.rv_angle_list = null;
|
||||
accumulatorSettingActivity.layout_default_page = null;
|
||||
accumulatorSettingActivity.angle_set_view = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.ubt.jimu.controller;
|
||||
|
||||
import com.alibaba.android.arouter.facade.service.SerializationService;
|
||||
import com.alibaba.android.arouter.facade.template.ISyringe;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.ubt.jimu.base.entities.RobotLite;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AddDirectionActivity$$ARouter$$Autowired implements ISyringe {
|
||||
private SerializationService serializationService;
|
||||
|
||||
@Override // com.alibaba.android.arouter.facade.template.ISyringe
|
||||
public void inject(Object obj) {
|
||||
this.serializationService = (SerializationService) ARouter.b().a(SerializationService.class);
|
||||
AddDirectionActivity addDirectionActivity = (AddDirectionActivity) obj;
|
||||
addDirectionActivity.mRobotLite = (RobotLite) addDirectionActivity.getIntent().getParcelableExtra("robotLite");
|
||||
}
|
||||
}
|
||||
255
sources/com/ubt/jimu/controller/AddDirectionActivity.java
Normal file
255
sources/com/ubt/jimu/controller/AddDirectionActivity.java
Normal file
@@ -0,0 +1,255 @@
|
||||
package com.ubt.jimu.controller;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
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.cache.Cache;
|
||||
import com.ubt.jimu.base.data.Engine;
|
||||
import com.ubt.jimu.base.data.Servo;
|
||||
import com.ubt.jimu.base.entities.RobotLite;
|
||||
import com.ubt.jimu.controller.adapter.AddDirectionViewAdapter;
|
||||
import com.ubt.jimu.controller.data.bean.AddDirectionItemBean;
|
||||
import com.ubt.jimu.controller.data.config.HSliderConfig;
|
||||
import com.ubt.jimu.controller.manager.MoveConfigManager;
|
||||
import com.ubt.jimu.utils.LogUtils;
|
||||
import com.ubtech.utils.XLog;
|
||||
import com.ubtech.view.widget.ToastView;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AddDirectionActivity extends SuperActivity implements View.OnClickListener {
|
||||
private AddDirectionViewAdapter a;
|
||||
private EngineManager b;
|
||||
ImageView im_back;
|
||||
RobotLite mRobotLite;
|
||||
RecyclerView re_select_direction;
|
||||
|
||||
/* renamed from: com.ubt.jimu.controller.AddDirectionActivity$2, reason: invalid class name */
|
||||
static /* synthetic */ class AnonymousClass2 {
|
||||
static final /* synthetic */ int[] a = new int[AddDirectionItemBean.ItemType.values().length];
|
||||
|
||||
static {
|
||||
try {
|
||||
a[AddDirectionItemBean.ItemType.TOW_WHEEL.ordinal()] = 1;
|
||||
} catch (NoSuchFieldError unused) {
|
||||
}
|
||||
try {
|
||||
a[AddDirectionItemBean.ItemType.FOUR_WHEEL.ordinal()] = 2;
|
||||
} catch (NoSuchFieldError unused2) {
|
||||
}
|
||||
try {
|
||||
a[AddDirectionItemBean.ItemType.SIX_WHEEL.ordinal()] = 3;
|
||||
} catch (NoSuchFieldError unused3) {
|
||||
}
|
||||
try {
|
||||
a[AddDirectionItemBean.ItemType.H_SLIDER.ordinal()] = 4;
|
||||
} catch (NoSuchFieldError unused4) {
|
||||
}
|
||||
try {
|
||||
a[AddDirectionItemBean.ItemType.V_SLIDER.ordinal()] = 5;
|
||||
} catch (NoSuchFieldError unused5) {
|
||||
}
|
||||
try {
|
||||
a[AddDirectionItemBean.ItemType.ACCUMULATOR.ordinal()] = 6;
|
||||
} catch (NoSuchFieldError unused6) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<Engine> D0() {
|
||||
this.b = new EngineManager(this, this.mRobotLite);
|
||||
return this.b.getEngineList(Cache.getInstance().getUserId());
|
||||
}
|
||||
|
||||
private List<Servo> E0() {
|
||||
this.b = new EngineManager(this, this.mRobotLite);
|
||||
List<Servo> servoList = this.b.getServoList(Cache.getInstance().getUserId());
|
||||
if (servoList != null && servoList.size() > 0) {
|
||||
XLog.a("woo", "servolist: %s", servoList.toString());
|
||||
List<HSliderConfig> c = MoveConfigManager.a(getApplicationContext()).c();
|
||||
if (c != null && c.size() > 0) {
|
||||
Iterator<HSliderConfig> it = c.iterator();
|
||||
while (it.hasNext()) {
|
||||
int servoID = it.next().getServoID();
|
||||
for (Servo servo : servoList) {
|
||||
if (servoID == servo.getId()) {
|
||||
servo.setConfigged(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return servoList;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.SuperActivity
|
||||
protected void initData() {
|
||||
ARouter.b().a(this);
|
||||
this.re_select_direction.setLayoutManager(new GridLayoutManager(this, 4));
|
||||
ArrayList arrayList = new ArrayList();
|
||||
AddDirectionItemBean addDirectionItemBean = new AddDirectionItemBean();
|
||||
addDirectionItemBean.a(R.drawable.add_direction_wheel);
|
||||
addDirectionItemBean.a(AddDirectionItemBean.ItemType.TOW_WHEEL);
|
||||
addDirectionItemBean.a(getResources().getString(R.string.two_drive));
|
||||
AddDirectionItemBean addDirectionItemBean2 = new AddDirectionItemBean();
|
||||
addDirectionItemBean2.a(R.drawable.add_direction_wheel);
|
||||
addDirectionItemBean2.a(getResources().getString(R.string.four_drive));
|
||||
addDirectionItemBean2.a(AddDirectionItemBean.ItemType.FOUR_WHEEL);
|
||||
AddDirectionItemBean addDirectionItemBean3 = new AddDirectionItemBean();
|
||||
addDirectionItemBean3.a(R.drawable.add_direction_accumulator);
|
||||
addDirectionItemBean3.a(getResources().getString(R.string.accumulator));
|
||||
addDirectionItemBean3.a(AddDirectionItemBean.ItemType.ACCUMULATOR);
|
||||
AddDirectionItemBean addDirectionItemBean4 = new AddDirectionItemBean();
|
||||
addDirectionItemBean4.a(R.drawable.add_h_slider);
|
||||
addDirectionItemBean4.a(getResources().getString(R.string.h_slider));
|
||||
addDirectionItemBean4.a(AddDirectionItemBean.ItemType.H_SLIDER);
|
||||
AddDirectionItemBean addDirectionItemBean5 = new AddDirectionItemBean();
|
||||
addDirectionItemBean5.a(R.drawable.add_v_slider);
|
||||
addDirectionItemBean5.a(getResources().getString(R.string.v_slider));
|
||||
addDirectionItemBean5.a(AddDirectionItemBean.ItemType.V_SLIDER);
|
||||
AddDirectionItemBean addDirectionItemBean6 = new AddDirectionItemBean();
|
||||
addDirectionItemBean6.a(R.drawable.add_direction_wheel);
|
||||
addDirectionItemBean6.a(getResources().getString(R.string.six_drive));
|
||||
addDirectionItemBean6.a(AddDirectionItemBean.ItemType.SIX_WHEEL);
|
||||
arrayList.add(addDirectionItemBean);
|
||||
arrayList.add(addDirectionItemBean2);
|
||||
arrayList.add(addDirectionItemBean6);
|
||||
arrayList.add(addDirectionItemBean3);
|
||||
arrayList.add(addDirectionItemBean4);
|
||||
arrayList.add(addDirectionItemBean5);
|
||||
this.a = new AddDirectionViewAdapter(this, arrayList);
|
||||
this.a.a(new AddDirectionViewAdapter.OnItemClickListener() { // from class: com.ubt.jimu.controller.AddDirectionActivity.1
|
||||
@Override // com.ubt.jimu.controller.adapter.AddDirectionViewAdapter.OnItemClickListener
|
||||
public void a(AddDirectionItemBean addDirectionItemBean7, int i) {
|
||||
AddDirectionActivity.this.a(addDirectionItemBean7.c());
|
||||
}
|
||||
});
|
||||
this.re_select_direction.setAdapter(this.a);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.SuperActivity
|
||||
protected void initEvent() {
|
||||
this.re_select_direction.setOnClickListener(this);
|
||||
this.im_back.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.SuperActivity
|
||||
public View initView() {
|
||||
return View.inflate(this, R.layout.activity_add_direction, null);
|
||||
}
|
||||
|
||||
@Override // androidx.fragment.app.FragmentActivity, android.app.Activity
|
||||
protected void onActivityResult(int i, int i2, Intent intent) {
|
||||
super.onActivityResult(i, i2, intent);
|
||||
LogUtils.c("requestCode:" + i + " resultCode:" + i2);
|
||||
if (i2 == -1 && i == 103) {
|
||||
a(intent);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view) {
|
||||
if (view.getId() != R.id.im_back) {
|
||||
return;
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
public void a(Intent intent) {
|
||||
setResult(-1);
|
||||
setIntent(intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void a(AddDirectionItemBean.ItemType itemType) {
|
||||
switch (AnonymousClass2.a[itemType.ordinal()]) {
|
||||
case 1:
|
||||
List<Engine> D0 = D0();
|
||||
if (D0 != null && D0.size() != 0) {
|
||||
Postcard a = ARouter.b().a("/controller/jocksticksettings");
|
||||
a.a("robotLite", this.mRobotLite);
|
||||
a.a("jock_type", 2);
|
||||
a.a(this, 103);
|
||||
break;
|
||||
} else {
|
||||
ToastView.a(this, getResources().getString(R.string.no_configuration_engines)).a();
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
List<Engine> D02 = D0();
|
||||
if (D02 != null && D02.size() != 0) {
|
||||
Postcard a2 = ARouter.b().a("/controller/jocksticksettings");
|
||||
a2.a("robotLite", this.mRobotLite);
|
||||
a2.a("jock_type", 4);
|
||||
a2.a(this, 103);
|
||||
break;
|
||||
} else {
|
||||
ToastView.a(this, getResources().getString(R.string.no_configuration_engines)).a();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
List<Engine> D03 = D0();
|
||||
if (D03 != null && D03.size() != 0) {
|
||||
Postcard a3 = ARouter.b().a("/controller/jocksticksettings");
|
||||
a3.a("robotLite", this.mRobotLite);
|
||||
a3.a("jock_type", 6);
|
||||
a3.a(this, 103);
|
||||
break;
|
||||
} else {
|
||||
ToastView.a(this, getResources().getString(R.string.no_configuration_engines)).a();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
List<Servo> E0 = E0();
|
||||
if (E0 != null && E0.size() != 0) {
|
||||
Postcard a4 = ARouter.b().a("/controller/anglesettings");
|
||||
a4.a("robotLite", this.mRobotLite);
|
||||
a4.a(this, 103);
|
||||
break;
|
||||
} else {
|
||||
ToastView.a(this, getResources().getString(R.string.no_configuration_servo)).a();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
List<Engine> D04 = D0();
|
||||
if (D04 != null && D04.size() != 0) {
|
||||
Postcard a5 = ARouter.b().a("/controller/vslidersettings");
|
||||
a5.a("robotLite", this.mRobotLite);
|
||||
a5.a(this, 103);
|
||||
break;
|
||||
} else {
|
||||
ToastView.a(this, getResources().getString(R.string.no_configuration_engines)).a();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
List<Servo> E02 = E0();
|
||||
if (E02 != null && E02.size() != 0) {
|
||||
Postcard a6 = ARouter.b().a("/controller/accumulatorsettings");
|
||||
a6.a("robotLite", this.mRobotLite);
|
||||
a6.a(this, 103);
|
||||
break;
|
||||
} else {
|
||||
ToastView.a(this, getResources().getString(R.string.no_configuration_servo)).a();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
XLog.b("woo", "Shoudn't be here! itemType: %s", itemType.toString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.ubt.jimu.controller;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import butterknife.Unbinder;
|
||||
import butterknife.internal.Utils;
|
||||
import com.ubt.jimu.R;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AddDirectionActivity_ViewBinding implements Unbinder {
|
||||
private AddDirectionActivity b;
|
||||
|
||||
public AddDirectionActivity_ViewBinding(AddDirectionActivity addDirectionActivity, View view) {
|
||||
this.b = addDirectionActivity;
|
||||
addDirectionActivity.re_select_direction = (RecyclerView) Utils.b(view, R.id.re_select_direction, "field 're_select_direction'", RecyclerView.class);
|
||||
addDirectionActivity.im_back = (ImageView) Utils.b(view, R.id.im_back, "field 'im_back'", ImageView.class);
|
||||
}
|
||||
|
||||
@Override // butterknife.Unbinder
|
||||
public void unbind() {
|
||||
AddDirectionActivity addDirectionActivity = this.b;
|
||||
if (addDirectionActivity == null) {
|
||||
throw new IllegalStateException("Bindings already cleared.");
|
||||
}
|
||||
this.b = null;
|
||||
addDirectionActivity.re_select_direction = null;
|
||||
addDirectionActivity.im_back = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.ubt.jimu.controller;
|
||||
|
||||
import com.alibaba.android.arouter.facade.service.SerializationService;
|
||||
import com.alibaba.android.arouter.facade.template.ISyringe;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.ubt.jimu.base.entities.RobotLite;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AngleSettingActivity$$ARouter$$Autowired implements ISyringe {
|
||||
private SerializationService serializationService;
|
||||
|
||||
@Override // com.alibaba.android.arouter.facade.template.ISyringe
|
||||
public void inject(Object obj) {
|
||||
this.serializationService = (SerializationService) ARouter.b().a(SerializationService.class);
|
||||
AngleSettingActivity angleSettingActivity = (AngleSettingActivity) obj;
|
||||
angleSettingActivity.mRobotLite = (RobotLite) angleSettingActivity.getIntent().getParcelableExtra("robotLite");
|
||||
angleSettingActivity.mConfigId = angleSettingActivity.getIntent().getStringExtra("config_id_key");
|
||||
}
|
||||
}
|
||||
433
sources/com/ubt/jimu/controller/AngleSettingActivity.java
Normal file
433
sources/com/ubt/jimu/controller/AngleSettingActivity.java
Normal file
@@ -0,0 +1,433 @@
|
||||
package com.ubt.jimu.controller;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
import android.util.SparseArray;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
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.Servo;
|
||||
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.AngleSetListAdapter;
|
||||
import com.ubt.jimu.controller.component.AngleSetView;
|
||||
import com.ubt.jimu.controller.data.config.HSliderConfig;
|
||||
import com.ubt.jimu.controller.data.config.WidgetConfig;
|
||||
import com.ubt.jimu.controller.manager.CommandManager;
|
||||
import com.ubt.jimu.controller.manager.MoveConfigManager;
|
||||
import com.ubt.jimu.controller.presenter.AngleSettingPresenter;
|
||||
import com.ubt.jimu.controller.view.IAngleSettingView;
|
||||
import com.ubt.jimu.utils.LogUtils;
|
||||
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 com.ubtrobot.jimu.robotapi.ServoAngleReadInfo;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AngleSettingActivity extends SuperActivity implements View.OnClickListener, AngleSetListAdapter.SteerEngineListItemOnClickListener, AngleSetView.AngleUpdateListener, IAngleSettingView {
|
||||
private AngleSetListAdapter a;
|
||||
ImageView angle_delete;
|
||||
ImageView angle_ok;
|
||||
AngleSetView angle_set_view;
|
||||
private HSliderConfig b;
|
||||
private int c = 118;
|
||||
private int d = WidgetConfig.MIN_ANGLE;
|
||||
private int e;
|
||||
private MoveConfigManager f;
|
||||
private View g;
|
||||
private Dialog h;
|
||||
private JAlertDialog i;
|
||||
ImageView im_back;
|
||||
ImageView im_select_engine;
|
||||
private AngleSettingPresenter j;
|
||||
private SparseArray<HSliderConfig> k;
|
||||
RelativeLayout layout_default_page;
|
||||
String mConfigId;
|
||||
RobotLite mRobotLite;
|
||||
RecyclerView rv_angle_list;
|
||||
|
||||
private boolean D0() {
|
||||
List<Servo> b = this.j.b(true);
|
||||
for (int i = 0; i < b.size(); i++) {
|
||||
if (!b.get(i).isConfigged()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void E0() {
|
||||
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 F0() {
|
||||
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.AngleSettingActivity.1
|
||||
@Override // com.ubt.jimu.widgets.UniversalPopupWindow.UniversalPopupWindowListener
|
||||
public void a() {
|
||||
AngleSettingActivity.this.j.a(AngleSettingActivity.this.b);
|
||||
AngleSettingActivity angleSettingActivity = AngleSettingActivity.this;
|
||||
ToastView.a(angleSettingActivity, angleSettingActivity.getResources().getString(R.string.delete_success), ToastView.Type.NORMAL).a();
|
||||
AngleSettingActivity.this.H0();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.UniversalPopupWindow.UniversalPopupWindowListener
|
||||
public void onCancel() {
|
||||
}
|
||||
}).a(this.g);
|
||||
}
|
||||
|
||||
private void G0() {
|
||||
JAlertDialog jAlertDialog = this.i;
|
||||
if (jAlertDialog == null || !jAlertDialog.isShowing()) {
|
||||
return;
|
||||
}
|
||||
this.i.dismiss();
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void H0() {
|
||||
if (TextUtils.isEmpty(this.mConfigId)) {
|
||||
setResult(-1);
|
||||
} else {
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra("configId", this.mConfigId);
|
||||
setResult(-1, intent);
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
private void I0() {
|
||||
HSliderConfig hSliderConfig;
|
||||
List<Servo> b = this.j.b(false);
|
||||
if (b == null || b.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
this.k = new SparseArray<>(b.size());
|
||||
for (Servo servo : b) {
|
||||
if (servo != null) {
|
||||
int i = this.e;
|
||||
if (i <= 0 || i != servo.getId()) {
|
||||
hSliderConfig = new HSliderConfig();
|
||||
hSliderConfig.setServoID((byte) servo.getId());
|
||||
hSliderConfig.setMinAngle(WidgetConfig.MIN_ANGLE);
|
||||
hSliderConfig.setMaxAngle(118);
|
||||
} else {
|
||||
hSliderConfig = new HSliderConfig(this.b.getConfigID(), this.b.getServoID(), this.b.getMinAngle(), this.b.getMaxAngle());
|
||||
}
|
||||
this.k.put(servo.getId(), hSliderConfig);
|
||||
}
|
||||
}
|
||||
this.j.a(b.size());
|
||||
}
|
||||
|
||||
private void J0() {
|
||||
int i = this.e;
|
||||
if (i <= 0) {
|
||||
XLog.b("woo", "saveData Servo Id should be %d", Integer.valueOf(i));
|
||||
return;
|
||||
}
|
||||
this.b.setMaxAngle(this.c);
|
||||
this.b.setMinAngle(this.d);
|
||||
this.b.setServoID(this.e);
|
||||
this.f.a(this.b);
|
||||
this.f.a(true);
|
||||
}
|
||||
|
||||
private int l(int i) {
|
||||
if (i < -118) {
|
||||
return WidgetConfig.MIN_ANGLE;
|
||||
}
|
||||
if (i > 118) {
|
||||
return 118;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.view.IAngleSettingView
|
||||
public 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.n
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public final void onClick(DialogInterface dialogInterface, int i) {
|
||||
AngleSettingActivity.this.b(dialogInterface, i);
|
||||
}
|
||||
}).a(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.controller.j
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public final void onClick(DialogInterface dialogInterface, int i) {
|
||||
dialogInterface.dismiss();
|
||||
}
|
||||
}).a().show();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.view.IAngleSettingView
|
||||
public void g(List<ServoAngleReadInfo> list) {
|
||||
HSliderConfig hSliderConfig;
|
||||
if (list == null || list.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
for (ServoAngleReadInfo servoAngleReadInfo : list) {
|
||||
if (servoAngleReadInfo != null && servoAngleReadInfo.b() > 0 && this.e != servoAngleReadInfo.b() && (hSliderConfig = this.k.get(servoAngleReadInfo.b())) != null) {
|
||||
hSliderConfig.setMinAngle((int) servoAngleReadInfo.a());
|
||||
hSliderConfig.setMaxAngle((int) servoAngleReadInfo.a());
|
||||
this.k.put(servoAngleReadInfo.b(), hSliderConfig);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.SuperActivity
|
||||
public void initData() {
|
||||
ARouter.b().a(this);
|
||||
this.j = new AngleSettingPresenter(this, this.mRobotLite);
|
||||
this.f = MoveConfigManager.a(getApplicationContext());
|
||||
if (TextUtils.isEmpty(this.mConfigId)) {
|
||||
this.b = new HSliderConfig();
|
||||
this.angle_delete.setVisibility(8);
|
||||
this.layout_default_page.setVisibility(0);
|
||||
if (!D0()) {
|
||||
LogUtils.c("没有可配置的舵机");
|
||||
ToastView.a(this, getResources().getString(R.string.no_configuration_servo), ToastView.Type.NORMAL).a();
|
||||
}
|
||||
} else {
|
||||
this.b = (HSliderConfig) this.f.a(this.mConfigId);
|
||||
if (this.b != null) {
|
||||
this.angle_delete.setVisibility(0);
|
||||
this.layout_default_page.setVisibility(8);
|
||||
this.c = this.b.getMaxAngle();
|
||||
this.d = this.b.getMinAngle();
|
||||
this.e = this.b.getServoID();
|
||||
this.angle_set_view.a(this.d, this.c);
|
||||
}
|
||||
LogUtils.c("configId:" + this.mConfigId + " " + this.b);
|
||||
}
|
||||
this.a = new AngleSetListAdapter(this);
|
||||
this.rv_angle_list.setLayoutManager(new LinearLayoutManager(this));
|
||||
this.rv_angle_list.setAdapter(this.a);
|
||||
this.a.a(this.b);
|
||||
this.im_back.setBackgroundResource(R.mipmap.btn_cancel);
|
||||
this.im_select_engine.setBackgroundResource(R.mipmap.select_engine);
|
||||
this.angle_ok.setBackgroundResource(R.mipmap.affirm_controller);
|
||||
this.angle_delete.setBackgroundResource(R.mipmap.control_delete_icon);
|
||||
I0();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.SuperActivity
|
||||
public void initEvent() {
|
||||
this.im_back.setOnClickListener(this);
|
||||
this.angle_ok.setOnClickListener(this);
|
||||
this.a.a(this);
|
||||
this.angle_set_view.setAngleUpdateListener(this);
|
||||
this.angle_delete.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.SuperActivity
|
||||
public View initView() {
|
||||
this.g = View.inflate(this, R.layout.activity_angle_setting, null);
|
||||
return this.g;
|
||||
}
|
||||
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.angle_delete /* 2131296319 */:
|
||||
F0();
|
||||
break;
|
||||
case R.id.angle_ok /* 2131296320 */:
|
||||
J0();
|
||||
H0();
|
||||
break;
|
||||
case R.id.im_back /* 2131296709 */:
|
||||
finish();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.BaseActivity, com.ubt.jimu.ScreenRotationManageActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
|
||||
protected void onDestroy() {
|
||||
this.j.h();
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.BaseActivity, com.ubt.jimu.ScreenRotationManageActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
|
||||
protected void onPause() {
|
||||
this.j.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.a.a(this.j.b(true));
|
||||
EngineManager c = this.j.c();
|
||||
if (c != null) {
|
||||
CommandManager.a(getApplicationContext()).a(c);
|
||||
}
|
||||
int i = this.e;
|
||||
if (i > 0) {
|
||||
this.j.a(i, ServoMode.SERVO_MODE_ANGLE);
|
||||
}
|
||||
this.j.g();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.adapter.AngleSetListAdapter.SteerEngineListItemOnClickListener
|
||||
public void a(Servo servo) {
|
||||
if (servo != null) {
|
||||
this.layout_default_page.setVisibility(8);
|
||||
this.e = (byte) servo.getId();
|
||||
HSliderConfig hSliderConfig = this.k.get(this.e);
|
||||
if (hSliderConfig != null) {
|
||||
int l = l(hSliderConfig.getMinAngle());
|
||||
int l2 = l(hSliderConfig.getMaxAngle());
|
||||
this.angle_set_view.a(l, l2);
|
||||
this.d = l;
|
||||
this.c = l2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.adapter.AngleSetListAdapter.SteerEngineListItemOnClickListener
|
||||
public void b(Servo servo) {
|
||||
if (this.mRobotLite.isOfficial()) {
|
||||
ToastView.a(this, R.string.control_config_official).a();
|
||||
} else {
|
||||
d(getResources().getString(R.string.nonsupport));
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.component.AngleSetView.AngleUpdateListener
|
||||
public void c(double d) {
|
||||
this.d = (int) d;
|
||||
HSliderConfig hSliderConfig = this.k.get(this.e);
|
||||
if (hSliderConfig != null) {
|
||||
hSliderConfig.setMinAngle(this.d);
|
||||
}
|
||||
this.j.a(this.mRobotLite, this.e, this.d);
|
||||
}
|
||||
|
||||
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.IBaseControllerView
|
||||
public void b(List<Component> list) {
|
||||
this.j.a(list);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.component.AngleSetView.AngleUpdateListener
|
||||
public void a(double d) {
|
||||
this.c = (int) d;
|
||||
HSliderConfig hSliderConfig = this.k.get(this.e);
|
||||
if (hSliderConfig != null) {
|
||||
hSliderConfig.setMaxAngle(this.c);
|
||||
}
|
||||
this.j.a(this.mRobotLite, this.e, this.c);
|
||||
}
|
||||
|
||||
@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.m
|
||||
@Override // java.lang.Runnable
|
||||
public final void run() {
|
||||
AngleSettingActivity.this.a(str, z, robotActiveException, list);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public /* synthetic */ void a(String str, boolean z, final RobotActiveException robotActiveException, final List list) {
|
||||
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).a(R.string.cancel, z).a(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.controller.i
|
||||
@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.l
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public final void onClick(DialogInterface dialogInterface, int i) {
|
||||
AngleSettingActivity.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.k
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public final void onClick(DialogInterface dialogInterface, int i) {
|
||||
dialogInterface.dismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
this.h = builder.a();
|
||||
this.h.show();
|
||||
}
|
||||
}
|
||||
|
||||
public /* synthetic */ void a(RobotActiveException robotActiveException, List list, DialogInterface dialogInterface, int i) {
|
||||
this.j.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;
|
||||
}
|
||||
E0();
|
||||
return;
|
||||
}
|
||||
G0();
|
||||
}
|
||||
|
||||
@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.j.a(this, list)).d(R.string.ok).a(R.string.cancel, true).b(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.controller.p
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public final void onClick(DialogInterface dialogInterface, int i) {
|
||||
AngleSettingActivity.this.a(dialogInterface, i);
|
||||
}
|
||||
}).a(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.controller.o
|
||||
@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.j.f();
|
||||
dialogInterface.dismiss();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.ubt.jimu.controller;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import butterknife.Unbinder;
|
||||
import butterknife.internal.Utils;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.controller.component.AngleSetView;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AngleSettingActivity_ViewBinding implements Unbinder {
|
||||
private AngleSettingActivity b;
|
||||
|
||||
public AngleSettingActivity_ViewBinding(AngleSettingActivity angleSettingActivity, View view) {
|
||||
this.b = angleSettingActivity;
|
||||
angleSettingActivity.im_back = (ImageView) Utils.b(view, R.id.im_back, "field 'im_back'", ImageView.class);
|
||||
angleSettingActivity.rv_angle_list = (RecyclerView) Utils.b(view, R.id.rv_angle_list, "field 'rv_angle_list'", RecyclerView.class);
|
||||
angleSettingActivity.layout_default_page = (RelativeLayout) Utils.b(view, R.id.layout_default_page, "field 'layout_default_page'", RelativeLayout.class);
|
||||
angleSettingActivity.angle_set_view = (AngleSetView) Utils.b(view, R.id.angle_set_view, "field 'angle_set_view'", AngleSetView.class);
|
||||
angleSettingActivity.angle_ok = (ImageView) Utils.b(view, R.id.angle_ok, "field 'angle_ok'", ImageView.class);
|
||||
angleSettingActivity.angle_delete = (ImageView) Utils.b(view, R.id.angle_delete, "field 'angle_delete'", ImageView.class);
|
||||
angleSettingActivity.im_select_engine = (ImageView) Utils.b(view, R.id.im_select_engine, "field 'im_select_engine'", ImageView.class);
|
||||
}
|
||||
|
||||
@Override // butterknife.Unbinder
|
||||
public void unbind() {
|
||||
AngleSettingActivity angleSettingActivity = this.b;
|
||||
if (angleSettingActivity == null) {
|
||||
throw new IllegalStateException("Bindings already cleared.");
|
||||
}
|
||||
this.b = null;
|
||||
angleSettingActivity.im_back = null;
|
||||
angleSettingActivity.rv_angle_list = null;
|
||||
angleSettingActivity.layout_default_page = null;
|
||||
angleSettingActivity.angle_set_view = null;
|
||||
angleSettingActivity.angle_ok = null;
|
||||
angleSettingActivity.angle_delete = null;
|
||||
angleSettingActivity.im_select_engine = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.ubt.jimu.controller;
|
||||
|
||||
import com.alibaba.android.arouter.facade.service.SerializationService;
|
||||
import com.alibaba.android.arouter.facade.template.ISyringe;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.ubt.jimu.base.entities.RobotLite;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ControllerActivity$$ARouter$$Autowired implements ISyringe {
|
||||
private SerializationService serializationService;
|
||||
|
||||
@Override // com.alibaba.android.arouter.facade.template.ISyringe
|
||||
public void inject(Object obj) {
|
||||
this.serializationService = (SerializationService) ARouter.b().a(SerializationService.class);
|
||||
ControllerActivity controllerActivity = (ControllerActivity) obj;
|
||||
controllerActivity.mRobotLite = (RobotLite) controllerActivity.getIntent().getParcelableExtra("robotLite");
|
||||
}
|
||||
}
|
||||
1376
sources/com/ubt/jimu/controller/ControllerActivity.java
Normal file
1376
sources/com/ubt/jimu/controller/ControllerActivity.java
Normal file
File diff suppressed because it is too large
Load Diff
41
sources/com/ubt/jimu/controller/DraggableInfo.java
Normal file
41
sources/com/ubt/jimu/controller/DraggableInfo.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package com.ubt.jimu.controller;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class DraggableInfo implements Serializable {
|
||||
public static final int TYPE_ACTION = 1;
|
||||
public static final int TYPE_HSLIDER = 4;
|
||||
public static final int TYPE_ROCKER = 2;
|
||||
public static final int TYPE_SLIDER = 3;
|
||||
private int actionId;
|
||||
private int resID;
|
||||
private int type;
|
||||
|
||||
public DraggableInfo(int i, int i2) {
|
||||
this(i, i2, -1);
|
||||
}
|
||||
|
||||
public int getActionId() {
|
||||
return this.actionId;
|
||||
}
|
||||
|
||||
public int getResID() {
|
||||
return this.resID;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public void setActionId(int i) {
|
||||
this.actionId = i;
|
||||
}
|
||||
|
||||
public DraggableInfo(int i, int i2, int i3) {
|
||||
this.actionId = -1;
|
||||
this.type = i;
|
||||
this.resID = i2;
|
||||
this.actionId = i3;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.ubt.jimu.controller;
|
||||
|
||||
import com.alibaba.android.arouter.facade.service.SerializationService;
|
||||
import com.alibaba.android.arouter.facade.template.ISyringe;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.ubt.jimu.base.entities.RobotLite;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class JockstickSettingActivity$$ARouter$$Autowired implements ISyringe {
|
||||
private SerializationService serializationService;
|
||||
|
||||
@Override // com.alibaba.android.arouter.facade.template.ISyringe
|
||||
public void inject(Object obj) {
|
||||
this.serializationService = (SerializationService) ARouter.b().a(SerializationService.class);
|
||||
JockstickSettingActivity jockstickSettingActivity = (JockstickSettingActivity) obj;
|
||||
jockstickSettingActivity.mJockType = jockstickSettingActivity.getIntent().getIntExtra("jock_type", jockstickSettingActivity.mJockType);
|
||||
jockstickSettingActivity.mRobotLite = (RobotLite) jockstickSettingActivity.getIntent().getParcelableExtra("robotLite");
|
||||
jockstickSettingActivity.mConfigId = jockstickSettingActivity.getIntent().getStringExtra("config_id_key");
|
||||
}
|
||||
}
|
||||
937
sources/com/ubt/jimu/controller/JockstickSettingActivity.java
Normal file
937
sources/com/ubt/jimu/controller/JockstickSettingActivity.java
Normal file
@@ -0,0 +1,937 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.ubt.jimu.controller;
|
||||
|
||||
import android.view.View;
|
||||
import android.view.ViewStub;
|
||||
import android.widget.ImageView;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import butterknife.Unbinder;
|
||||
import butterknife.internal.Utils;
|
||||
import com.ubt.jimu.R;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class JockstickSettingActivity_ViewBinding implements Unbinder {
|
||||
private JockstickSettingActivity b;
|
||||
|
||||
public JockstickSettingActivity_ViewBinding(JockstickSettingActivity jockstickSettingActivity, View view) {
|
||||
this.b = jockstickSettingActivity;
|
||||
jockstickSettingActivity.rv_engine_list = (RecyclerView) Utils.b(view, R.id.rv_engine_list, "field 'rv_engine_list'", RecyclerView.class);
|
||||
jockstickSettingActivity.btn_back = (ImageView) Utils.b(view, R.id.btn_back, "field 'btn_back'", ImageView.class);
|
||||
jockstickSettingActivity.im_control_affirm = (ImageView) Utils.b(view, R.id.im_control_affirm, "field 'im_control_affirm'", ImageView.class);
|
||||
jockstickSettingActivity.vs_two_servo = (ViewStub) Utils.b(view, R.id.vs_two_servo, "field 'vs_two_servo'", ViewStub.class);
|
||||
jockstickSettingActivity.vs_four_servo = (ViewStub) Utils.b(view, R.id.vs_four_servo, "field 'vs_four_servo'", ViewStub.class);
|
||||
jockstickSettingActivity.vs_six_servo = (ViewStub) Utils.b(view, R.id.vs_six_servo, "field 'vs_six_servo'", ViewStub.class);
|
||||
jockstickSettingActivity.im_control_delete = (ImageView) Utils.b(view, R.id.im_control_delete, "field 'im_control_delete'", ImageView.class);
|
||||
}
|
||||
|
||||
@Override // butterknife.Unbinder
|
||||
public void unbind() {
|
||||
JockstickSettingActivity jockstickSettingActivity = this.b;
|
||||
if (jockstickSettingActivity == null) {
|
||||
throw new IllegalStateException("Bindings already cleared.");
|
||||
}
|
||||
this.b = null;
|
||||
jockstickSettingActivity.rv_engine_list = null;
|
||||
jockstickSettingActivity.btn_back = null;
|
||||
jockstickSettingActivity.im_control_affirm = null;
|
||||
jockstickSettingActivity.vs_two_servo = null;
|
||||
jockstickSettingActivity.vs_four_servo = null;
|
||||
jockstickSettingActivity.vs_six_servo = null;
|
||||
jockstickSettingActivity.im_control_delete = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.ubt.jimu.controller;
|
||||
|
||||
import com.alibaba.android.arouter.facade.service.SerializationService;
|
||||
import com.alibaba.android.arouter.facade.template.ISyringe;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.ubt.jimu.base.entities.RobotLite;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ServoModeSettingActivity$$ARouter$$Autowired implements ISyringe {
|
||||
private SerializationService serializationService;
|
||||
|
||||
@Override // com.alibaba.android.arouter.facade.template.ISyringe
|
||||
public void inject(Object obj) {
|
||||
this.serializationService = (SerializationService) ARouter.b().a(SerializationService.class);
|
||||
ServoModeSettingActivity servoModeSettingActivity = (ServoModeSettingActivity) obj;
|
||||
servoModeSettingActivity.mRobotLite = (RobotLite) servoModeSettingActivity.getIntent().getParcelableExtra("robotLite");
|
||||
}
|
||||
}
|
||||
362
sources/com/ubt/jimu/controller/ServoModeSettingActivity.java
Normal file
362
sources/com/ubt/jimu/controller/ServoModeSettingActivity.java
Normal file
@@ -0,0 +1,362 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.ubt.jimu.controller;
|
||||
|
||||
import com.alibaba.android.arouter.facade.service.SerializationService;
|
||||
import com.alibaba.android.arouter.facade.template.ISyringe;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.ubt.jimu.base.entities.RobotLite;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ServoModeSettingNewActivity$$ARouter$$Autowired implements ISyringe {
|
||||
private SerializationService serializationService;
|
||||
|
||||
@Override // com.alibaba.android.arouter.facade.template.ISyringe
|
||||
public void inject(Object obj) {
|
||||
this.serializationService = (SerializationService) ARouter.b().a(SerializationService.class);
|
||||
ServoModeSettingNewActivity servoModeSettingNewActivity = (ServoModeSettingNewActivity) obj;
|
||||
servoModeSettingNewActivity.mRobotLite = (RobotLite) servoModeSettingNewActivity.getIntent().getParcelableExtra("robotLite");
|
||||
servoModeSettingNewActivity.mIsFromUnity = servoModeSettingNewActivity.getIntent().getBooleanExtra("isFromUnity", servoModeSettingNewActivity.mIsFromUnity);
|
||||
}
|
||||
}
|
||||
282
sources/com/ubt/jimu/controller/ServoModeSettingNewActivity.java
Normal file
282
sources/com/ubt/jimu/controller/ServoModeSettingNewActivity.java
Normal file
@@ -0,0 +1,282 @@
|
||||
package com.ubt.jimu.controller;
|
||||
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.kyleduo.switchbutton.SwitchButton;
|
||||
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.db.user.UserDbHandler;
|
||||
import com.ubt.jimu.base.entities.RobotLite;
|
||||
import com.ubt.jimu.base.entities.User;
|
||||
import com.ubt.jimu.base.mvp.HbBaseActivity;
|
||||
import com.ubt.jimu.controller.presenter.ServoModeSettingPresenter;
|
||||
import com.ubt.jimu.transport3.dao.DiyDBModelDBHandler;
|
||||
import com.ubt.jimu.utils.SystemUtils;
|
||||
import com.ubtech.view.dialog.SimpleDialog;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ServoModeSettingNewActivity extends HbBaseActivity<ServoModeSettingPresenter> implements ServoModeSettingPresenter.ServoModeView {
|
||||
private RecyclerView a;
|
||||
private ImageView b;
|
||||
private ImageView c;
|
||||
private EngineManager d;
|
||||
private BaseQuickAdapter<Servo, BaseViewHolder> e;
|
||||
private RelativeLayout f;
|
||||
private RelativeLayout g;
|
||||
private RelativeLayout h;
|
||||
private ImageView i;
|
||||
private RelativeLayout j;
|
||||
boolean mIsFromUnity = false;
|
||||
RobotLite mRobotLite;
|
||||
|
||||
private void D0() {
|
||||
if (this.mIsFromUnity) {
|
||||
List<Servo> servoList = this.d.getServoList(Cache.getInstance().getUserId());
|
||||
StringBuilder sb = new StringBuilder("\"commonServo\":\"");
|
||||
StringBuilder sb2 = new StringBuilder("\"circleServo\":\"");
|
||||
a(servoList, sb, ServoMode.SERVO_MODE_ANGLE);
|
||||
a(servoList, sb2, ServoMode.SERVO_MODE_TURN);
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra("servo_mode", "{" + ((CharSequence) sb) + "," + ((CharSequence) sb2) + "}");
|
||||
setResult(-1, intent);
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
private void E0() {
|
||||
this.b.setOnClickListener(this);
|
||||
this.i.setOnClickListener(this);
|
||||
this.c.setOnClickListener(this);
|
||||
}
|
||||
|
||||
private void F0() {
|
||||
H0();
|
||||
EngineManager engineManager = this.d;
|
||||
if (engineManager != null) {
|
||||
engineManager.save();
|
||||
}
|
||||
D0();
|
||||
}
|
||||
|
||||
private void G0() {
|
||||
}
|
||||
|
||||
private void H0() {
|
||||
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);
|
||||
Integer modelId = queryForUUid.getModelId();
|
||||
User user = UserDbHandler.getUser();
|
||||
if (modelId.intValue() <= 0 || user == null || user.getUserId() <= 0) {
|
||||
return;
|
||||
}
|
||||
((ServoModeSettingPresenter) this.mPresenter).a(queryForUUid);
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
if (this.d == null) {
|
||||
RobotLite robotLite = this.mRobotLite;
|
||||
if (robotLite == null) {
|
||||
return;
|
||||
} else {
|
||||
this.d = new EngineManager(this, robotLite);
|
||||
}
|
||||
}
|
||||
((ServoModeSettingPresenter) this.mPresenter).a(this.d, this.mRobotLite);
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
this.a = (RecyclerView) findViewById(R.id.rcv_content);
|
||||
this.b = (ImageView) findViewById(R.id.iv_servoset_cancle);
|
||||
this.c = (ImageView) findViewById(R.id.img_servo_setting_save);
|
||||
this.f = (RelativeLayout) findViewById(R.id.rl_servo_turntips);
|
||||
this.g = (RelativeLayout) findViewById(R.id.rl_servo_angletips);
|
||||
this.h = (RelativeLayout) findViewById(R.id.rl_noservo);
|
||||
this.i = (ImageView) findViewById(R.id.iv_noservo_cancle);
|
||||
this.j = (RelativeLayout) findViewById(R.id.rl_title);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.presenter.ServoModeSettingPresenter.ServoModeView
|
||||
public void c(List<Servo> list) {
|
||||
if (list == null || list.size() == 0) {
|
||||
this.h.setVisibility(0);
|
||||
this.j.setVisibility(8);
|
||||
this.a.setVisibility(8);
|
||||
return;
|
||||
}
|
||||
this.h.setVisibility(8);
|
||||
this.j.setVisibility(0);
|
||||
this.a.setVisibility(0);
|
||||
BaseQuickAdapter<Servo, BaseViewHolder> baseQuickAdapter = this.e;
|
||||
if (baseQuickAdapter == null) {
|
||||
this.e = new BaseQuickAdapter<Servo, BaseViewHolder>(R.layout.item_servolist, list) { // from class: com.ubt.jimu.controller.ServoModeSettingNewActivity.1
|
||||
/* JADX INFO: Access modifiers changed from: protected */
|
||||
@Override // com.chad.library.adapter.base.BaseQuickAdapter
|
||||
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
||||
public void convert(final BaseViewHolder baseViewHolder, final Servo servo) {
|
||||
baseViewHolder.setText(R.id.item_servo_text, String.format(this.mContext.getResources().getString(R.string.servo_mode_servo_index), Integer.valueOf(servo.getId())));
|
||||
final SwitchButton switchButton = (SwitchButton) baseViewHolder.getView(R.id.item_servo_sb);
|
||||
if (servo.isChoose()) {
|
||||
baseViewHolder.setBackgroundColor(R.id.item_rl_content, ServoModeSettingNewActivity.this.getResources().getColor(R.color.bg_4D24A8FF));
|
||||
} else {
|
||||
baseViewHolder.setBackgroundColor(R.id.item_rl_content, ServoModeSettingNewActivity.this.getResources().getColor(R.color.white));
|
||||
}
|
||||
if (servo.getModeType() == ServoMode.SERVO_MODE_TURN) {
|
||||
switchButton.setCheckedImmediatelyNoEvent(true);
|
||||
baseViewHolder.setImageResource(R.id.item_servo_icon, R.drawable.servo_setting_turn_icon);
|
||||
switchButton.setThumbDrawableRes(R.drawable.servo_circle_mode);
|
||||
} else {
|
||||
switchButton.setCheckedImmediatelyNoEvent(false);
|
||||
switchButton.setThumbDrawableRes(R.drawable.servo_ar_mode);
|
||||
baseViewHolder.setImageResource(R.id.item_servo_icon, R.drawable.servo_setting_angle_icon);
|
||||
}
|
||||
switchButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { // from class: com.ubt.jimu.controller.ServoModeSettingNewActivity.1.1
|
||||
@Override // android.widget.CompoundButton.OnCheckedChangeListener
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean z) {
|
||||
List data = ServoModeSettingNewActivity.this.e.getData();
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
((Servo) data.get(i)).setChoose(false);
|
||||
}
|
||||
servo.setChoose(true);
|
||||
ServoModeSettingNewActivity.this.e.notifyDataSetChanged();
|
||||
if (z) {
|
||||
baseViewHolder.setImageResource(R.id.item_servo_icon, R.mipmap.servo_turn);
|
||||
switchButton.setThumbDrawableRes(R.drawable.servo_circle_mode);
|
||||
ServoModeSettingNewActivity.this.a(ServoMode.SERVO_MODE_TURN);
|
||||
servo.setModeType(ServoMode.SERVO_MODE_TURN);
|
||||
} else {
|
||||
baseViewHolder.setImageResource(R.id.item_servo_icon, R.mipmap.servo_angle);
|
||||
switchButton.setThumbDrawableRes(R.drawable.servo_ar_mode);
|
||||
ServoModeSettingNewActivity.this.a(ServoMode.SERVO_MODE_ANGLE);
|
||||
servo.setModeType(ServoMode.SERVO_MODE_ANGLE);
|
||||
}
|
||||
if (ServoModeSettingNewActivity.this.d != null) {
|
||||
ServoModeSettingNewActivity.this.d.updateServoMode(servo);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
a(list.get(0).getModeType());
|
||||
} else {
|
||||
baseQuickAdapter.notifyDataSetChanged();
|
||||
}
|
||||
this.a.setLayoutManager(new LinearLayoutManager(this));
|
||||
this.a.setAdapter(this.e);
|
||||
this.e.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() { // from class: com.ubt.jimu.controller.ServoModeSettingNewActivity.2
|
||||
@Override // com.chad.library.adapter.base.BaseQuickAdapter.OnItemClickListener
|
||||
public void onItemClick(BaseQuickAdapter baseQuickAdapter2, View view, int i) {
|
||||
List data = baseQuickAdapter2.getData();
|
||||
for (int i2 = 0; i2 < data.size(); i2++) {
|
||||
((Servo) data.get(i2)).setChoose(false);
|
||||
}
|
||||
Servo servo = (Servo) baseQuickAdapter2.getData().get(i);
|
||||
servo.setChoose(true);
|
||||
ServoMode modeType = servo.getModeType();
|
||||
ServoMode servoMode = ServoMode.SERVO_MODE_ANGLE;
|
||||
if (modeType == servoMode) {
|
||||
ServoModeSettingNewActivity.this.a(servoMode);
|
||||
} else {
|
||||
ServoModeSettingNewActivity.this.a(ServoMode.SERVO_MODE_TURN);
|
||||
}
|
||||
ServoModeSettingNewActivity.this.e.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.mvp.HbBaseActivity
|
||||
public int getLayoutResId() {
|
||||
return R.layout.activity_servomodesettingnew;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.mvp.HbBaseActivity, 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);
|
||||
ARouter.b().a(this);
|
||||
initView();
|
||||
initData();
|
||||
E0();
|
||||
G0();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.mvp.SingleClickListener
|
||||
public void onSingleClick(View view) {
|
||||
int id = view.getId();
|
||||
if (id == R.id.iv_servoset_cancle || id == R.id.iv_noservo_cancle || id == R.id.img_noservo_save) {
|
||||
D0();
|
||||
} else if (id == R.id.img_servo_setting_save) {
|
||||
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.w0
|
||||
@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.x0
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public final void onClick(DialogInterface dialogInterface, int i) {
|
||||
ServoModeSettingNewActivity.this.a(dialogInterface, i);
|
||||
}
|
||||
}).a().show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.mvp.HbBaseActivity
|
||||
public ServoModeSettingPresenter createPresenter() {
|
||||
return new ServoModeSettingPresenter();
|
||||
}
|
||||
|
||||
public /* synthetic */ void a(DialogInterface dialogInterface, int i) {
|
||||
F0();
|
||||
}
|
||||
|
||||
private void a(List<Servo> list, StringBuilder sb, ServoMode servoMode) {
|
||||
if (list == null || list.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
boolean z = false;
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Servo servo = list.get(i);
|
||||
if (servo.getModeType() == servoMode) {
|
||||
if (z) {
|
||||
sb.append("|");
|
||||
}
|
||||
sb.append(servo.getId());
|
||||
z = true;
|
||||
}
|
||||
}
|
||||
sb.append("\"");
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void a(ServoMode servoMode) {
|
||||
if (servoMode == ServoMode.SERVO_MODE_TURN) {
|
||||
this.g.setVisibility(8);
|
||||
this.f.setVisibility(0);
|
||||
} else {
|
||||
this.f.setVisibility(8);
|
||||
this.g.setVisibility(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.ubt.jimu.controller;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import com.ubt.jimu.R;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class SetSteeringWheelActivity extends Activity {
|
||||
@Override // android.app.Activity
|
||||
protected void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
setContentView(R.layout.activity_steering_wheel_setting);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.ubt.jimu.controller;
|
||||
|
||||
import com.alibaba.android.arouter.facade.service.SerializationService;
|
||||
import com.alibaba.android.arouter.facade.template.ISyringe;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.ubt.jimu.base.entities.RobotLite;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class VSliderSetActivity$$ARouter$$Autowired implements ISyringe {
|
||||
private SerializationService serializationService;
|
||||
|
||||
@Override // com.alibaba.android.arouter.facade.template.ISyringe
|
||||
public void inject(Object obj) {
|
||||
this.serializationService = (SerializationService) ARouter.b().a(SerializationService.class);
|
||||
VSliderSetActivity vSliderSetActivity = (VSliderSetActivity) obj;
|
||||
vSliderSetActivity.mRobotLite = (RobotLite) vSliderSetActivity.getIntent().getParcelableExtra("robotLite");
|
||||
vSliderSetActivity.mConfigId = vSliderSetActivity.getIntent().getStringExtra("config_id_key");
|
||||
}
|
||||
}
|
||||
406
sources/com/ubt/jimu/controller/VSliderSetActivity.java
Normal file
406
sources/com/ubt/jimu/controller/VSliderSetActivity.java
Normal file
@@ -0,0 +1,406 @@
|
||||
package com.ubt.jimu.controller;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
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.Servo;
|
||||
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.VSliderSetAdapter;
|
||||
import com.ubt.jimu.controller.data.command.Gear;
|
||||
import com.ubt.jimu.controller.data.config.SliderConfig;
|
||||
import com.ubt.jimu.controller.manager.CommandManager;
|
||||
import com.ubt.jimu.controller.manager.MoveConfigManager;
|
||||
import com.ubt.jimu.controller.presenter.VSliderPresenter;
|
||||
import com.ubt.jimu.controller.view.IVSliderView;
|
||||
import com.ubt.jimu.utils.LogUtils;
|
||||
import com.ubt.jimu.widgets.JAlertDialog;
|
||||
import com.ubt.jimu.widgets.UniversalPopupWindow;
|
||||
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.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class VSliderSetActivity extends SuperActivity implements IVSliderView, View.OnClickListener, VSliderSetAdapter.OnItemClickListener {
|
||||
private VSliderSetAdapter a;
|
||||
ImageView angle_affirm;
|
||||
private SliderConfig b;
|
||||
private SliderConfig c;
|
||||
private VSliderPresenter d;
|
||||
private List<SliderConfig> e;
|
||||
private Engine f;
|
||||
private Dialog g;
|
||||
private JAlertDialog h;
|
||||
ImageView im_back;
|
||||
ImageView im_delete;
|
||||
ImageView im_engine_anticlockwise;
|
||||
ImageView im_engine_clockwise;
|
||||
RelativeLayout layout_default_page;
|
||||
String mConfigId;
|
||||
RobotLite mRobotLite;
|
||||
RecyclerView rv_angle_list;
|
||||
|
||||
private boolean E0() {
|
||||
List<Engine> a = this.d.a(true);
|
||||
for (int i = 0; i < a.size(); i++) {
|
||||
if (!a.get(i).isConfigged()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void F0() {
|
||||
JAlertDialog.Builder builder = new JAlertDialog.Builder(this);
|
||||
builder.b(false);
|
||||
builder.a(R.drawable.ic_loading);
|
||||
builder.a(true);
|
||||
this.h = builder.a();
|
||||
this.h.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.VSliderSetActivity.1
|
||||
@Override // com.ubt.jimu.widgets.UniversalPopupWindow.UniversalPopupWindowListener
|
||||
public void a() {
|
||||
VSliderSetActivity.this.d.a(VSliderSetActivity.this.b);
|
||||
VSliderSetActivity vSliderSetActivity = VSliderSetActivity.this;
|
||||
ToastView.a(vSliderSetActivity, vSliderSetActivity.getResources().getString(R.string.delete_success), ToastView.Type.NORMAL).a();
|
||||
VSliderSetActivity.this.D0();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.UniversalPopupWindow.UniversalPopupWindowListener
|
||||
public void onCancel() {
|
||||
}
|
||||
}).a(this.mRootView);
|
||||
}
|
||||
|
||||
private void H0() {
|
||||
JAlertDialog jAlertDialog = this.h;
|
||||
if (jAlertDialog == null || !jAlertDialog.isShowing()) {
|
||||
return;
|
||||
}
|
||||
this.h.dismiss();
|
||||
}
|
||||
|
||||
private void I0() {
|
||||
SliderConfig sliderConfig;
|
||||
List<Engine> a = this.d.a(false);
|
||||
if (a == null || a.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
this.e = new ArrayList(a.size());
|
||||
for (Engine engine : a) {
|
||||
if (engine != null) {
|
||||
SliderConfig sliderConfig2 = this.b;
|
||||
if (sliderConfig2 != null && sliderConfig2.getMotionType() == engine.getMotionType() && this.b.getServoID() == engine.getId()) {
|
||||
sliderConfig = new SliderConfig(this.mConfigId, this.b.getMotionType(), this.b.getServoID(), this.b.isDirectionDisclock());
|
||||
} else {
|
||||
SliderConfig sliderConfig3 = new SliderConfig();
|
||||
sliderConfig3.setServoID((byte) engine.getId());
|
||||
sliderConfig3.setMotionType(engine.getMotionType());
|
||||
sliderConfig3.setDirectionDisclock(false);
|
||||
sliderConfig = sliderConfig3;
|
||||
}
|
||||
this.e.add(sliderConfig);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void D0() {
|
||||
if (TextUtils.isEmpty(this.mConfigId)) {
|
||||
setResult(-1);
|
||||
} else {
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra("configId", this.mConfigId);
|
||||
setResult(-1, intent);
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.adapter.VSliderSetAdapter.OnItemClickListener
|
||||
public void c(Servo servo) {
|
||||
if (this.mRobotLite.isOfficial()) {
|
||||
ToastView.a(this, R.string.control_config_official).a();
|
||||
} else {
|
||||
d(getResources().getString(R.string.control_nonsupport_angle));
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.view.IVSliderView
|
||||
public 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.e1
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public final void onClick(DialogInterface dialogInterface, int i) {
|
||||
VSliderSetActivity.this.b(dialogInterface, i);
|
||||
}
|
||||
}).a(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.controller.b1
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public final void onClick(DialogInterface dialogInterface, int i) {
|
||||
dialogInterface.dismiss();
|
||||
}
|
||||
}).a().show();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.SuperActivity
|
||||
public void initData() {
|
||||
ARouter.b().a(this);
|
||||
this.d = new VSliderPresenter(this, this.mRobotLite);
|
||||
this.a = new VSliderSetAdapter(this);
|
||||
this.rv_angle_list.setLayoutManager(new LinearLayoutManager(this));
|
||||
this.rv_angle_list.setAdapter(this.a);
|
||||
if (TextUtils.isEmpty(this.mConfigId)) {
|
||||
this.c = new SliderConfig();
|
||||
this.im_delete.setVisibility(8);
|
||||
this.angle_affirm.setVisibility(8);
|
||||
this.im_engine_anticlockwise.setBackgroundResource(R.drawable.disclock_default);
|
||||
this.im_engine_clockwise.setBackgroundResource(R.drawable.clockwise_selected);
|
||||
this.b = this.c;
|
||||
if (!E0()) {
|
||||
LogUtils.c("没有可配置的舵机");
|
||||
ToastView.a(this, getResources().getString(R.string.no_configuration_engines), ToastView.Type.NORMAL).a();
|
||||
}
|
||||
} else {
|
||||
this.b = (SliderConfig) MoveConfigManager.a(getApplicationContext()).a(this.mConfigId);
|
||||
this.c = new SliderConfig(this.mConfigId, this.b.getMotionType(), this.b.getServoID(), this.b.isDirectionDisclock());
|
||||
this.im_delete.setVisibility(0);
|
||||
this.angle_affirm.setVisibility(0);
|
||||
a(this.b);
|
||||
}
|
||||
this.a.a(this.c);
|
||||
this.im_back.setBackgroundResource(R.mipmap.btn_cancel);
|
||||
this.angle_affirm.setBackgroundResource(R.mipmap.affirm_controller);
|
||||
this.im_delete.setBackgroundResource(R.mipmap.control_delete_icon);
|
||||
I0();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.SuperActivity
|
||||
public void initEvent() {
|
||||
this.im_back.setOnClickListener(this);
|
||||
this.im_engine_anticlockwise.setOnClickListener(this);
|
||||
this.im_engine_clockwise.setOnClickListener(this);
|
||||
this.angle_affirm.setOnClickListener(this);
|
||||
this.im_delete.setOnClickListener(this);
|
||||
this.a.a(this);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.SuperActivity
|
||||
public View initView() {
|
||||
return View.inflate(this, R.layout.activity_v_slider, null);
|
||||
}
|
||||
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.angle_affirm /* 2131296318 */:
|
||||
this.b.setDirectionDisclock(this.c.isDirectionDisclock());
|
||||
this.b.setMotionType(this.c.getMotionType());
|
||||
this.b.setServoID(this.c.getServoID());
|
||||
this.d.b(this.b);
|
||||
D0();
|
||||
break;
|
||||
case R.id.im_back /* 2131296709 */:
|
||||
finish();
|
||||
break;
|
||||
case R.id.im_delete /* 2131296724 */:
|
||||
G0();
|
||||
break;
|
||||
case R.id.im_engine_anticlockwise /* 2131296731 */:
|
||||
this.im_engine_anticlockwise.setBackgroundResource(R.drawable.disclock_selected);
|
||||
this.im_engine_clockwise.setBackgroundResource(R.drawable.clockwise_default);
|
||||
this.c.setDirectionDisclock(true);
|
||||
SliderConfig a = a(this.f);
|
||||
if (a != null) {
|
||||
a.setDirectionDisclock(true);
|
||||
this.d.a(this.c.getMotionType(), this.c.getServoID(), Gear.FIFTH, -1);
|
||||
this.angle_affirm.setVisibility(0);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case R.id.im_engine_clockwise /* 2131296732 */:
|
||||
this.im_engine_anticlockwise.setBackgroundResource(R.drawable.disclock_default);
|
||||
this.im_engine_clockwise.setBackgroundResource(R.drawable.clockwise_selected);
|
||||
this.c.setDirectionDisclock(false);
|
||||
SliderConfig a2 = a(this.f);
|
||||
if (a2 != null) {
|
||||
a2.setDirectionDisclock(false);
|
||||
this.d.a(this.c.getMotionType(), this.c.getServoID(), Gear.FIFTH, 1);
|
||||
this.angle_affirm.setVisibility(0);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.BaseActivity, com.ubt.jimu.ScreenRotationManageActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
|
||||
protected void onPause() {
|
||||
this.d.j();
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.BaseActivity, com.ubt.jimu.ScreenRotationManageActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
|
||||
protected void onResume() {
|
||||
int servoID;
|
||||
super.onResume();
|
||||
this.a.a(this.d.a(true));
|
||||
EngineManager c = this.d.c();
|
||||
if (c != null) {
|
||||
CommandManager.a(getApplicationContext()).a(c);
|
||||
}
|
||||
if (!TextUtils.isEmpty(this.mConfigId) && this.c.getMotionType() == CtrlMotionType.servo && (servoID = this.c.getServoID()) > 0) {
|
||||
this.d.a(servoID, ServoMode.SERVO_MODE_TURN);
|
||||
}
|
||||
this.d.g();
|
||||
}
|
||||
|
||||
private void a(SliderConfig sliderConfig) {
|
||||
if (sliderConfig.isDirectionDisclock()) {
|
||||
this.im_engine_anticlockwise.setBackgroundResource(R.drawable.disclock_selected);
|
||||
this.im_engine_clockwise.setBackgroundResource(R.drawable.clockwise_default);
|
||||
} else {
|
||||
this.im_engine_anticlockwise.setBackgroundResource(R.drawable.disclock_default);
|
||||
this.im_engine_clockwise.setBackgroundResource(R.drawable.clockwise_selected);
|
||||
}
|
||||
}
|
||||
|
||||
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.IBaseControllerView
|
||||
public void b(List<Component> list) {
|
||||
this.d.a(list);
|
||||
}
|
||||
|
||||
private SliderConfig a(Engine engine) {
|
||||
List<SliderConfig> list;
|
||||
if (engine == null || (list = this.e) == null || list.size() <= 0) {
|
||||
return null;
|
||||
}
|
||||
for (SliderConfig sliderConfig : this.e) {
|
||||
if (sliderConfig.getMotionType() == engine.getMotionType() && sliderConfig.getServoID() == engine.getId()) {
|
||||
return sliderConfig;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.adapter.VSliderSetAdapter.OnItemClickListener
|
||||
public void a(Engine engine, int i) {
|
||||
this.layout_default_page.setVisibility(8);
|
||||
this.f = engine;
|
||||
SliderConfig a = a(engine);
|
||||
if (a != null) {
|
||||
a(a);
|
||||
}
|
||||
this.c.setServoID((byte) engine.getId());
|
||||
this.c.setMotionType(engine.getMotionType());
|
||||
this.angle_affirm.setVisibility(0);
|
||||
}
|
||||
|
||||
@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.z0
|
||||
@Override // java.lang.Runnable
|
||||
public final void run() {
|
||||
VSliderSetActivity.this.a(str, z, robotActiveException, list);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public /* synthetic */ void a(String str, boolean z, final RobotActiveException robotActiveException, final List list) {
|
||||
Dialog dialog = this.g;
|
||||
if (dialog == null || !dialog.isShowing()) {
|
||||
SimpleDialog.Builder builder = new SimpleDialog.Builder(this);
|
||||
SimpleDialog.Builder b = builder.a((CharSequence) str).d(R.string.ok).a(R.string.cancel, z).a(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.controller.y0
|
||||
@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.a1
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public final void onClick(DialogInterface dialogInterface, int i) {
|
||||
VSliderSetActivity.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.c1
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public final void onClick(DialogInterface dialogInterface, int i) {
|
||||
dialogInterface.dismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
this.g = builder.a();
|
||||
this.g.show();
|
||||
}
|
||||
}
|
||||
|
||||
public /* synthetic */ void a(RobotActiveException robotActiveException, List list, DialogInterface dialogInterface, int i) {
|
||||
this.d.a(robotActiveException, (List<Integer>) list);
|
||||
dialogInterface.dismiss();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.view.IBaseControllerView
|
||||
public void a(boolean z) {
|
||||
if (z) {
|
||||
JAlertDialog jAlertDialog = this.h;
|
||||
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.d.a(this, list)).d(R.string.ok).a(R.string.cancel, true).b(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.controller.d1
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public final void onClick(DialogInterface dialogInterface, int i) {
|
||||
VSliderSetActivity.this.a(dialogInterface, i);
|
||||
}
|
||||
}).a(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.controller.f1
|
||||
@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.d.f();
|
||||
dialogInterface.dismiss();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.ubt.jimu.controller;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import butterknife.Unbinder;
|
||||
import butterknife.internal.Utils;
|
||||
import com.ubt.jimu.R;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class VSliderSetActivity_ViewBinding implements Unbinder {
|
||||
private VSliderSetActivity b;
|
||||
|
||||
public VSliderSetActivity_ViewBinding(VSliderSetActivity vSliderSetActivity, View view) {
|
||||
this.b = vSliderSetActivity;
|
||||
vSliderSetActivity.im_engine_anticlockwise = (ImageView) Utils.b(view, R.id.im_engine_anticlockwise, "field 'im_engine_anticlockwise'", ImageView.class);
|
||||
vSliderSetActivity.im_engine_clockwise = (ImageView) Utils.b(view, R.id.im_engine_clockwise, "field 'im_engine_clockwise'", ImageView.class);
|
||||
vSliderSetActivity.rv_angle_list = (RecyclerView) Utils.b(view, R.id.rv_angle_list, "field 'rv_angle_list'", RecyclerView.class);
|
||||
vSliderSetActivity.im_back = (ImageView) Utils.b(view, R.id.im_back, "field 'im_back'", ImageView.class);
|
||||
vSliderSetActivity.im_delete = (ImageView) Utils.b(view, R.id.im_delete, "field 'im_delete'", ImageView.class);
|
||||
vSliderSetActivity.angle_affirm = (ImageView) Utils.b(view, R.id.angle_affirm, "field 'angle_affirm'", ImageView.class);
|
||||
vSliderSetActivity.layout_default_page = (RelativeLayout) Utils.b(view, R.id.layout_default_page, "field 'layout_default_page'", RelativeLayout.class);
|
||||
}
|
||||
|
||||
@Override // butterknife.Unbinder
|
||||
public void unbind() {
|
||||
VSliderSetActivity vSliderSetActivity = this.b;
|
||||
if (vSliderSetActivity == null) {
|
||||
throw new IllegalStateException("Bindings already cleared.");
|
||||
}
|
||||
this.b = null;
|
||||
vSliderSetActivity.im_engine_anticlockwise = null;
|
||||
vSliderSetActivity.im_engine_clockwise = null;
|
||||
vSliderSetActivity.rv_angle_list = null;
|
||||
vSliderSetActivity.im_back = null;
|
||||
vSliderSetActivity.im_delete = null;
|
||||
vSliderSetActivity.angle_affirm = null;
|
||||
vSliderSetActivity.layout_default_page = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
package com.ubt.jimu.controller.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.controller.component.MenuItemView;
|
||||
import com.ubt.jimu.controller.data.action.ActionSequence;
|
||||
import com.ubt.jimu.controller.data.widget.ActionWidgetData;
|
||||
import com.ubt.jimu.controller.util.SvgUtils;
|
||||
import com.ubt.jimu.utils.LocaleUtils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ActionRecyclerViewAdapter extends RecyclerView.Adapter<MenuViewHolder> {
|
||||
private Context b;
|
||||
private ActionWidgetData c;
|
||||
private MenuItemView d;
|
||||
private ItemDragListener e;
|
||||
private List<ActionWidgetData> a = new ArrayList();
|
||||
private int f = -1;
|
||||
|
||||
class MenuViewHolder extends RecyclerView.ViewHolder {
|
||||
public MenuItemView a;
|
||||
public TextView b;
|
||||
public RelativeLayout c;
|
||||
public ImageView d;
|
||||
public View e;
|
||||
|
||||
public MenuViewHolder(View view) {
|
||||
super(view);
|
||||
this.a = (MenuItemView) view.findViewById(R.id.im_control_icon);
|
||||
this.d = (ImageView) view.findViewById(R.id.im_item_bg);
|
||||
this.b = (TextView) view.findViewById(R.id.tv_name);
|
||||
this.c = (RelativeLayout) view.findViewById(R.id.layout_control_icon);
|
||||
this.e = view.findViewById(R.id.view_bottom_interval);
|
||||
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) this.a.getLayoutParams();
|
||||
layoutParams.width = (int) ActionRecyclerViewAdapter.this.b.getResources().getDimension(R.dimen.control_action_width);
|
||||
layoutParams.height = (int) ActionRecyclerViewAdapter.this.b.getResources().getDimension(R.dimen.control_action_width);
|
||||
this.d.setBackgroundResource(R.mipmap.btn_shadow);
|
||||
a();
|
||||
this.a.setBackgroundColor(R.mipmap.control_add_icon);
|
||||
}
|
||||
|
||||
private void a() {
|
||||
this.a.setMenuItemOnTouchListener(new MenuItemView.MenuItemOnTouchListener<ActionWidgetData>() { // from class: com.ubt.jimu.controller.adapter.ActionRecyclerViewAdapter.MenuViewHolder.1
|
||||
@Override // com.ubt.jimu.controller.component.MenuItemView.MenuItemOnTouchListener
|
||||
/* renamed from: a, reason: avoid collision after fix types in other method and merged with bridge method [inline-methods] */
|
||||
public void b(ActionWidgetData actionWidgetData, MenuItemView menuItemView) {
|
||||
if (ActionRecyclerViewAdapter.this.e != null) {
|
||||
if (actionWidgetData.getActionSequence() == null) {
|
||||
ActionRecyclerViewAdapter.this.e.b(menuItemView, actionWidgetData);
|
||||
} else {
|
||||
ActionRecyclerViewAdapter.this.e.b(actionWidgetData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.component.MenuItemView.MenuItemOnTouchListener
|
||||
/* renamed from: b, reason: avoid collision after fix types in other method and merged with bridge method [inline-methods] */
|
||||
public void a(ActionWidgetData actionWidgetData, MenuItemView menuItemView) {
|
||||
ActionRecyclerViewAdapter.this.c = actionWidgetData;
|
||||
ActionRecyclerViewAdapter.this.d = menuItemView;
|
||||
if (ActionRecyclerViewAdapter.this.e != null) {
|
||||
ActionRecyclerViewAdapter.this.e.c(MenuViewHolder.this.a, actionWidgetData);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public ActionRecyclerViewAdapter(List<ActionWidgetData> list, Context context) {
|
||||
this.a.clear();
|
||||
this.b = context;
|
||||
ActionWidgetData actionWidgetData = new ActionWidgetData();
|
||||
actionWidgetData.setActionNm(this.b.getResources().getString(R.string.control_add));
|
||||
this.a.add(actionWidgetData);
|
||||
if (list == null || list.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
this.a.addAll(list);
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
||||
public int getItemCount() {
|
||||
List<ActionWidgetData> list = this.a;
|
||||
if (list == null) {
|
||||
return 0;
|
||||
}
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public void b(int i) {
|
||||
this.f = i;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
||||
public MenuViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
|
||||
return new MenuViewHolder(LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_control_action_menu, viewGroup, false));
|
||||
}
|
||||
|
||||
public void a(List<ActionWidgetData> list) {
|
||||
this.a.clear();
|
||||
ActionWidgetData actionWidgetData = new ActionWidgetData();
|
||||
actionWidgetData.setActionNm(this.b.getResources().getString(R.string.control_add));
|
||||
this.a.add(actionWidgetData);
|
||||
if (list != null && list.size() > 0) {
|
||||
this.a.addAll(list);
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void a() {
|
||||
int i = this.f;
|
||||
this.f = -1;
|
||||
notifyItemChanged(i);
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
||||
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
||||
public void onBindViewHolder(MenuViewHolder menuViewHolder, int i) {
|
||||
ActionWidgetData actionWidgetData = this.a.get(i);
|
||||
if (this.f == i) {
|
||||
menuViewHolder.c.setBackgroundResource(R.drawable.shape_12dp);
|
||||
} else {
|
||||
menuViewHolder.c.setBackgroundResource(R.color.translucent);
|
||||
}
|
||||
if (i != 0) {
|
||||
ActionSequence actionSequence = actionWidgetData.getActionSequence();
|
||||
Drawable a = SvgUtils.a(this.b).a(actionWidgetData.getImageViewId());
|
||||
menuViewHolder.a.setImageBitmap(null);
|
||||
menuViewHolder.a.setBackground(a);
|
||||
menuViewHolder.b.setTextColor(actionSequence.j() ? this.b.getResources().getColor(R.color.bg_92A7B6) : this.b.getResources().getColor(R.color.bg_596F80));
|
||||
} else {
|
||||
menuViewHolder.a.setImageResource(R.mipmap.control_add_icon);
|
||||
menuViewHolder.a.setBackground(null);
|
||||
menuViewHolder.b.setTextColor(this.b.getResources().getColor(R.color.bg_596F80));
|
||||
}
|
||||
menuViewHolder.b.setText(actionWidgetData.getShowName(LocaleUtils.b()));
|
||||
menuViewHolder.a.setData(actionWidgetData);
|
||||
if (i == 0) {
|
||||
menuViewHolder.a.setMenuItemType(MenuItemView.MenuItemType.ACTION_ADD_ITEM);
|
||||
} else {
|
||||
menuViewHolder.a.setMenuItemType(MenuItemView.MenuItemType.ACTION_ITEM);
|
||||
}
|
||||
if (i == this.a.size() - 1) {
|
||||
menuViewHolder.e.setVisibility(0);
|
||||
} else {
|
||||
menuViewHolder.e.setVisibility(8);
|
||||
}
|
||||
}
|
||||
|
||||
public void a(ItemDragListener itemDragListener) {
|
||||
this.e = itemDragListener;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.ubt.jimu.controller.adapter;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.controller.data.bean.AddDirectionItemBean;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AddDirectionViewAdapter extends RecyclerView.Adapter<AddDirectionHolder> {
|
||||
private List<AddDirectionItemBean> a;
|
||||
private OnItemClickListener b;
|
||||
|
||||
class AddDirectionHolder extends RecyclerView.ViewHolder {
|
||||
private ImageView a;
|
||||
private TextView b;
|
||||
|
||||
public AddDirectionHolder(AddDirectionViewAdapter addDirectionViewAdapter, View view) {
|
||||
super(view);
|
||||
this.a = (ImageView) view.findViewById(R.id.im_add_wheel);
|
||||
this.b = (TextView) view.findViewById(R.id.txt_name);
|
||||
}
|
||||
}
|
||||
|
||||
public interface OnItemClickListener {
|
||||
void a(AddDirectionItemBean addDirectionItemBean, int i);
|
||||
}
|
||||
|
||||
public AddDirectionViewAdapter(Activity activity, List<AddDirectionItemBean> list) {
|
||||
this.a = list;
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
||||
public int getItemCount() {
|
||||
List<AddDirectionItemBean> list = this.a;
|
||||
if (list == null) {
|
||||
return 0;
|
||||
}
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public void a(OnItemClickListener onItemClickListener) {
|
||||
this.b = onItemClickListener;
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
||||
public AddDirectionHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
|
||||
return new AddDirectionHolder(this, LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_add_direction, viewGroup, false));
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
||||
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
||||
public void onBindViewHolder(AddDirectionHolder addDirectionHolder, final int i) {
|
||||
final AddDirectionItemBean addDirectionItemBean = this.a.get(i);
|
||||
addDirectionHolder.a.setBackgroundResource(addDirectionItemBean.a());
|
||||
addDirectionHolder.b.setText(addDirectionItemBean.b());
|
||||
addDirectionHolder.a.setOnClickListener(new View.OnClickListener() { // from class: com.ubt.jimu.controller.adapter.AddDirectionViewAdapter.1
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view) {
|
||||
if (AddDirectionViewAdapter.this.b != null) {
|
||||
AddDirectionViewAdapter.this.b.a(addDirectionItemBean, i);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
142
sources/com/ubt/jimu/controller/adapter/AngleSetListAdapter.java
Normal file
142
sources/com/ubt/jimu/controller/adapter/AngleSetListAdapter.java
Normal file
@@ -0,0 +1,142 @@
|
||||
package com.ubt.jimu.controller.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.base.data.Servo;
|
||||
import com.ubt.jimu.base.data.ServoMode;
|
||||
import com.ubt.jimu.controller.data.config.AccumulatorConfig;
|
||||
import com.ubt.jimu.controller.data.config.HSliderConfig;
|
||||
import com.ubt.jimu.controller.data.config.WidgetConfig;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AngleSetListAdapter extends RecyclerView.Adapter<AngleViewHolder> {
|
||||
private Context a;
|
||||
private View b;
|
||||
private SteerEngineListItemOnClickListener c;
|
||||
private List<Servo> d;
|
||||
private WidgetConfig e;
|
||||
private int f;
|
||||
|
||||
public class AngleViewHolder extends RecyclerView.ViewHolder {
|
||||
public TextView a;
|
||||
public ImageView b;
|
||||
|
||||
public AngleViewHolder(AngleSetListAdapter angleSetListAdapter, View view) {
|
||||
super(view);
|
||||
this.a = (TextView) view.findViewById(R.id.tv_engine_name);
|
||||
this.b = (ImageView) view.findViewById(R.id.im_engine_icon);
|
||||
}
|
||||
}
|
||||
|
||||
public interface SteerEngineListItemOnClickListener {
|
||||
void a(Servo servo);
|
||||
|
||||
void b(Servo servo);
|
||||
}
|
||||
|
||||
public AngleSetListAdapter(Context context) {
|
||||
this.a = context;
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
||||
public int getItemCount() {
|
||||
List<Servo> list = this.d;
|
||||
if (list == null) {
|
||||
return 0;
|
||||
}
|
||||
return list.size();
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
||||
public AngleViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
|
||||
return new AngleViewHolder(this, LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_angle_set, viewGroup, false));
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public boolean b(int i) {
|
||||
return this.e != null && a() == i;
|
||||
}
|
||||
|
||||
public void a(WidgetConfig widgetConfig) {
|
||||
this.e = widgetConfig;
|
||||
this.f = a();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void a(List<Servo> list) {
|
||||
this.d = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
||||
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
||||
public void onBindViewHolder(AngleViewHolder angleViewHolder, int i) {
|
||||
Servo servo = this.d.get(i);
|
||||
if (servo == null) {
|
||||
return;
|
||||
}
|
||||
int id = servo.getId();
|
||||
ServoMode modeType = servo.getModeType();
|
||||
if (modeType == ServoMode.SERVO_MODE_TURN) {
|
||||
angleViewHolder.b.setBackgroundResource(R.mipmap.ic_servo_turn);
|
||||
} else {
|
||||
angleViewHolder.b.setBackgroundResource(R.mipmap.ic_servo_angle);
|
||||
}
|
||||
if (this.e != null && this.f == id) {
|
||||
angleViewHolder.itemView.setBackgroundColor(this.a.getResources().getColor(R.color.bg_4D24A8FF));
|
||||
this.b = angleViewHolder.itemView;
|
||||
} else {
|
||||
angleViewHolder.itemView.setBackgroundColor(this.a.getResources().getColor(R.color.color_FFFFFF));
|
||||
}
|
||||
if (servo.isConfigged() && !b(id)) {
|
||||
angleViewHolder.b.setAlpha(0.65f);
|
||||
angleViewHolder.a.setAlpha(0.65f);
|
||||
} else {
|
||||
angleViewHolder.b.setAlpha(1.0f);
|
||||
angleViewHolder.a.setAlpha(1.0f);
|
||||
}
|
||||
angleViewHolder.a.setText(String.format(this.a.getResources().getString(R.string.servo_mode_servo_index), Integer.valueOf(id)));
|
||||
a(angleViewHolder, servo, modeType);
|
||||
}
|
||||
|
||||
private int a() {
|
||||
WidgetConfig widgetConfig = this.e;
|
||||
int servoID = widgetConfig instanceof HSliderConfig ? ((HSliderConfig) widgetConfig).getServoID() : -1;
|
||||
WidgetConfig widgetConfig2 = this.e;
|
||||
return widgetConfig2 instanceof AccumulatorConfig ? ((AccumulatorConfig) widgetConfig2).getServoID() : servoID;
|
||||
}
|
||||
|
||||
private void a(final AngleViewHolder angleViewHolder, final Servo servo, final ServoMode servoMode) {
|
||||
angleViewHolder.itemView.setOnClickListener(new View.OnClickListener() { // from class: com.ubt.jimu.controller.adapter.AngleSetListAdapter.1
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view) {
|
||||
if (AngleSetListAdapter.this.c != null) {
|
||||
if (servoMode != ServoMode.SERVO_MODE_ANGLE) {
|
||||
AngleSetListAdapter.this.c.b(servo);
|
||||
return;
|
||||
}
|
||||
if (!servo.isConfigged() || AngleSetListAdapter.this.b(servo.getId())) {
|
||||
AngleSetListAdapter.this.c.a(servo);
|
||||
AngleSetListAdapter.this.f = servo.getId();
|
||||
if (AngleSetListAdapter.this.b != null) {
|
||||
AngleSetListAdapter.this.b.setBackgroundColor(AngleSetListAdapter.this.a.getResources().getColor(R.color.color_FFFFFF));
|
||||
}
|
||||
angleViewHolder.itemView.setBackgroundColor(AngleSetListAdapter.this.a.getResources().getColor(R.color.bg_4D24A8FF));
|
||||
AngleSetListAdapter.this.b = angleViewHolder.itemView;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void a(SteerEngineListItemOnClickListener steerEngineListItemOnClickListener) {
|
||||
this.c = steerEngineListItemOnClickListener;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.ubt.jimu.controller.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.viewpager.widget.PagerAdapter;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ControlMenuPagerAdapter extends PagerAdapter {
|
||||
private List<View> a;
|
||||
|
||||
public ControlMenuPagerAdapter(Context context, List<View> list) {
|
||||
this.a = list;
|
||||
}
|
||||
|
||||
@Override // androidx.viewpager.widget.PagerAdapter
|
||||
public void destroyItem(ViewGroup viewGroup, int i, Object obj) {
|
||||
viewGroup.removeView((View) obj);
|
||||
}
|
||||
|
||||
@Override // androidx.viewpager.widget.PagerAdapter
|
||||
public int getCount() {
|
||||
List<View> list = this.a;
|
||||
if (list == null) {
|
||||
return 0;
|
||||
}
|
||||
return list.size();
|
||||
}
|
||||
|
||||
@Override // androidx.viewpager.widget.PagerAdapter
|
||||
public boolean isViewFromObject(View view, Object obj) {
|
||||
return view == obj;
|
||||
}
|
||||
|
||||
@Override // androidx.viewpager.widget.PagerAdapter
|
||||
public View instantiateItem(ViewGroup viewGroup, int i) {
|
||||
View view = this.a.get(i);
|
||||
viewGroup.addView(view);
|
||||
return view;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
package com.ubt.jimu.controller.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.controller.component.MenuItemView;
|
||||
import com.ubt.jimu.controller.data.widget.AddViewData;
|
||||
import com.ubt.jimu.controller.data.widget.MoveBaseData;
|
||||
import com.ubt.jimu.controller.view.MenuItemDataManage;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class DirectionRecyclerViewAdapter extends RecyclerView.Adapter<MenuViewHolder> {
|
||||
private Context b;
|
||||
private MoveBaseData c;
|
||||
private MenuItemView d;
|
||||
private ItemDragListener e;
|
||||
private List<MoveBaseData> a = new ArrayList();
|
||||
private int f = -1;
|
||||
|
||||
class MenuViewHolder extends RecyclerView.ViewHolder {
|
||||
public MenuItemView a;
|
||||
public TextView b;
|
||||
public View c;
|
||||
|
||||
public MenuViewHolder(View view) {
|
||||
super(view);
|
||||
this.a = (MenuItemView) view.findViewById(R.id.im_control_icon);
|
||||
this.b = (TextView) view.findViewById(R.id.tv_name);
|
||||
this.c = view.findViewById(R.id.view_bottom_interval);
|
||||
a();
|
||||
}
|
||||
|
||||
private void a() {
|
||||
this.a.setMenuItemOnTouchListener(new MenuItemView.MenuItemOnTouchListener<MoveBaseData>() { // from class: com.ubt.jimu.controller.adapter.DirectionRecyclerViewAdapter.MenuViewHolder.1
|
||||
@Override // com.ubt.jimu.controller.component.MenuItemView.MenuItemOnTouchListener
|
||||
/* renamed from: a, reason: avoid collision after fix types in other method and merged with bridge method [inline-methods] */
|
||||
public void b(MoveBaseData moveBaseData, MenuItemView menuItemView) {
|
||||
MenuViewHolder.this.a(moveBaseData, menuItemView);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.component.MenuItemView.MenuItemOnTouchListener
|
||||
/* renamed from: b, reason: avoid collision after fix types in other method and merged with bridge method [inline-methods] */
|
||||
public void a(MoveBaseData moveBaseData, MenuItemView menuItemView) {
|
||||
DirectionRecyclerViewAdapter.this.c = moveBaseData;
|
||||
DirectionRecyclerViewAdapter.this.d = menuItemView;
|
||||
if (DirectionRecyclerViewAdapter.this.e != null) {
|
||||
DirectionRecyclerViewAdapter.this.e.c(MenuViewHolder.this.a, moveBaseData);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void a(MoveBaseData moveBaseData, MenuItemView menuItemView) {
|
||||
MenuItemView.MenuItemType menuItemType = menuItemView.getMenuItemType();
|
||||
moveBaseData.getConfig();
|
||||
if (menuItemType == MenuItemView.MenuItemType.WIDGET_ADD_ITEM) {
|
||||
if (DirectionRecyclerViewAdapter.this.e != null) {
|
||||
DirectionRecyclerViewAdapter.this.e.b(this.a, moveBaseData);
|
||||
}
|
||||
} else if (DirectionRecyclerViewAdapter.this.e != null) {
|
||||
DirectionRecyclerViewAdapter.this.e.a(menuItemView, moveBaseData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public DirectionRecyclerViewAdapter(List<MoveBaseData> list, Context context) {
|
||||
this.b = context;
|
||||
this.a.add(new AddViewData());
|
||||
if (list == null || list.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
this.a.addAll(list);
|
||||
}
|
||||
|
||||
public void b(int i) {
|
||||
this.f = i;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
||||
public int getItemCount() {
|
||||
List<MoveBaseData> list = this.a;
|
||||
if (list == null) {
|
||||
return 0;
|
||||
}
|
||||
return list.size();
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
||||
public MenuViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
|
||||
return new MenuViewHolder(LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_control_menu, viewGroup, false));
|
||||
}
|
||||
|
||||
public void a() {
|
||||
int i = this.f;
|
||||
this.f = -1;
|
||||
notifyItemChanged(i);
|
||||
}
|
||||
|
||||
public void a(List<MoveBaseData> list) {
|
||||
this.a.clear();
|
||||
this.a.add(new AddViewData());
|
||||
if (list == null) {
|
||||
notifyDataSetChanged();
|
||||
} else {
|
||||
this.a.addAll(list);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
||||
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
||||
public void onBindViewHolder(MenuViewHolder menuViewHolder, int i) {
|
||||
Resources resources;
|
||||
MoveBaseData moveBaseData = this.a.get(i);
|
||||
boolean isOfficial = moveBaseData.isOfficial();
|
||||
if (this.f == i) {
|
||||
menuViewHolder.a.setBackgroundResource(R.drawable.shape_12dp);
|
||||
} else {
|
||||
menuViewHolder.a.setBackgroundResource(R.color.translucent);
|
||||
}
|
||||
int b = MenuItemDataManage.a(this.b).b(moveBaseData);
|
||||
float[] a = MenuItemDataManage.a(this.b).a(moveBaseData);
|
||||
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) menuViewHolder.a.getLayoutParams();
|
||||
layoutParams.width = (int) a[0];
|
||||
layoutParams.height = (int) a[1];
|
||||
menuViewHolder.a.setImageBitmap(BitmapFactory.decodeResource(this.b.getResources(), b));
|
||||
int i2 = R.color.bg_596F80;
|
||||
if (i == 0) {
|
||||
menuViewHolder.a.setMenuItemType(MenuItemView.MenuItemType.WIDGET_ADD_ITEM);
|
||||
menuViewHolder.b.setText(this.b.getResources().getString(R.string.control_add_component));
|
||||
menuViewHolder.b.setTextColor(this.b.getResources().getColor(R.color.bg_596F80));
|
||||
} else {
|
||||
menuViewHolder.a.setMenuItemType(MenuItemView.MenuItemType.WIDGET_ITEM);
|
||||
menuViewHolder.b.setText(moveBaseData.getShowName(this.b));
|
||||
TextView textView = menuViewHolder.b;
|
||||
if (isOfficial) {
|
||||
resources = this.b.getResources();
|
||||
i2 = R.color.bg_92A7B6;
|
||||
} else {
|
||||
resources = this.b.getResources();
|
||||
}
|
||||
textView.setTextColor(resources.getColor(i2));
|
||||
}
|
||||
menuViewHolder.a.setData(moveBaseData);
|
||||
if (i == this.a.size() - 1) {
|
||||
menuViewHolder.c.setVisibility(0);
|
||||
} else {
|
||||
menuViewHolder.c.setVisibility(8);
|
||||
}
|
||||
}
|
||||
|
||||
public void a(ItemDragListener itemDragListener) {
|
||||
this.e = itemDragListener;
|
||||
}
|
||||
}
|
||||
95
sources/com/ubt/jimu/controller/adapter/DragAdapter.java
Normal file
95
sources/com/ubt/jimu/controller/adapter/DragAdapter.java
Normal file
@@ -0,0 +1,95 @@
|
||||
package com.ubt.jimu.controller.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.base.data.Servo;
|
||||
import com.ubt.jimu.base.data.ServoMode;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class DragAdapter extends RecyclerView.Adapter<ViewHolder> {
|
||||
private Context a;
|
||||
private OnDragListener b;
|
||||
private List<Servo> c;
|
||||
|
||||
public interface OnDragListener {
|
||||
void a(View view, int i);
|
||||
}
|
||||
|
||||
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
private ImageView a;
|
||||
private TextView b;
|
||||
|
||||
interface OnLongClickListener {
|
||||
void a(View view, int i);
|
||||
}
|
||||
|
||||
public ViewHolder(View view, final OnLongClickListener onLongClickListener) {
|
||||
super(view);
|
||||
this.a = (ImageView) view.findViewById(R.id.iv_icon);
|
||||
this.b = (TextView) view.findViewById(R.id.tv_name);
|
||||
this.a.setOnLongClickListener(new View.OnLongClickListener() { // from class: com.ubt.jimu.controller.adapter.DragAdapter.ViewHolder.1
|
||||
@Override // android.view.View.OnLongClickListener
|
||||
public boolean onLongClick(View view2) {
|
||||
OnLongClickListener onLongClickListener2 = onLongClickListener;
|
||||
if (onLongClickListener2 == null) {
|
||||
return true;
|
||||
}
|
||||
onLongClickListener2.a(view2, ViewHolder.this.getAdapterPosition());
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public DragAdapter(Context context, List<Servo> list, OnDragListener onDragListener) {
|
||||
this.a = context;
|
||||
this.b = onDragListener;
|
||||
this.c = list;
|
||||
}
|
||||
|
||||
public /* synthetic */ void a(View view, int i) {
|
||||
OnDragListener onDragListener = this.b;
|
||||
if (onDragListener != null) {
|
||||
onDragListener.a(view, i);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
||||
public int getItemCount() {
|
||||
List<Servo> list = this.c;
|
||||
if (list != null) {
|
||||
return list.size();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
||||
public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
|
||||
return new ViewHolder(LayoutInflater.from(this.a).inflate(R.layout.drag_item, viewGroup, false), new ViewHolder.OnLongClickListener() { // from class: com.ubt.jimu.controller.adapter.a
|
||||
@Override // com.ubt.jimu.controller.adapter.DragAdapter.ViewHolder.OnLongClickListener
|
||||
public final void a(View view, int i2) {
|
||||
DragAdapter.this.a(view, i2);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
||||
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
||||
public void onBindViewHolder(ViewHolder viewHolder, int i) {
|
||||
Servo servo = this.c.get(i);
|
||||
if (servo.getModeType() == ServoMode.SERVO_MODE_TURN) {
|
||||
viewHolder.a.setImageResource(R.mipmap.servo_turn);
|
||||
} else {
|
||||
viewHolder.a.setImageResource(R.mipmap.servo_angle);
|
||||
}
|
||||
viewHolder.a.setTag(servo);
|
||||
viewHolder.b.setText(String.format(this.a.getResources().getString(R.string.servo_mode_servo_index), Integer.valueOf(servo.getId())));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.ubt.jimu.controller.adapter;
|
||||
|
||||
import com.ubt.jimu.controller.component.MenuItemView;
|
||||
import com.ubt.jimu.controller.data.widget.ActionWidgetData;
|
||||
import com.ubt.jimu.controller.data.widget.ItemBaseData;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface ItemDragListener {
|
||||
void a(MenuItemView menuItemView, ItemBaseData itemBaseData);
|
||||
|
||||
void b(MenuItemView menuItemView, ItemBaseData itemBaseData);
|
||||
|
||||
void b(ActionWidgetData actionWidgetData);
|
||||
|
||||
void c(MenuItemView menuItemView, ItemBaseData itemBaseData);
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
package com.ubt.jimu.controller.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.base.data.Engine;
|
||||
import com.ubt.jimu.base.data.Motor;
|
||||
import com.ubt.jimu.base.data.Servo;
|
||||
import com.ubt.jimu.base.data.ServoMode;
|
||||
import com.ubt.jimu.controller.data.config.JockstickConfig;
|
||||
import com.ubt.jimu.controller.data.config.Wheel;
|
||||
import com.ubt.jimu.utils.LogUtils;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class SelectEngineListAdapter extends RecyclerView.Adapter<SelectEngineViewHolder> {
|
||||
private Context a;
|
||||
private JockstickConfig b;
|
||||
private List<Engine> c;
|
||||
private int d = -1;
|
||||
private OnItemClickListener e;
|
||||
|
||||
public interface OnItemClickListener {
|
||||
void A0();
|
||||
|
||||
void a(Engine engine, int i);
|
||||
}
|
||||
|
||||
class SelectEngineViewHolder extends RecyclerView.ViewHolder {
|
||||
LinearLayout a;
|
||||
ImageView b;
|
||||
TextView c;
|
||||
String d;
|
||||
String e;
|
||||
|
||||
public SelectEngineViewHolder(SelectEngineListAdapter selectEngineListAdapter, View view) {
|
||||
super(view);
|
||||
this.d = "";
|
||||
this.e = "";
|
||||
this.a = (LinearLayout) view.findViewById(R.id.ll_engine_select);
|
||||
this.b = (ImageView) view.findViewById(R.id.im_engine_icon);
|
||||
this.c = (TextView) view.findViewById(R.id.tv_engine_name);
|
||||
this.d = selectEngineListAdapter.a.getResources().getString(R.string.servo_mode_servo_index);
|
||||
this.e = selectEngineListAdapter.a.getResources().getString(R.string.control_motor_index);
|
||||
}
|
||||
}
|
||||
|
||||
public SelectEngineListAdapter(Context context) {
|
||||
this.a = context;
|
||||
}
|
||||
|
||||
private boolean c(int i) {
|
||||
return this.d == i;
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
||||
public int getItemCount() {
|
||||
List<Engine> list = this.c;
|
||||
if (list == null || list.size() <= 0) {
|
||||
return 0;
|
||||
}
|
||||
return this.c.size();
|
||||
}
|
||||
|
||||
public void a(List<Engine> list) {
|
||||
this.c = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void b(int i) {
|
||||
this.d = i;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
||||
public SelectEngineViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
|
||||
return new SelectEngineViewHolder(this, View.inflate(this.a, R.layout.item_engine_select, null));
|
||||
}
|
||||
|
||||
public void a(JockstickConfig jockstickConfig) {
|
||||
this.b = jockstickConfig;
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
||||
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
||||
public void onBindViewHolder(SelectEngineViewHolder selectEngineViewHolder, final int i) {
|
||||
final Engine engine = this.c.get(i);
|
||||
if (engine == null) {
|
||||
return;
|
||||
}
|
||||
selectEngineViewHolder.c.setTextColor(this.a.getResources().getColor(R.color.txt_798487));
|
||||
JockstickConfig jockstickConfig = this.b;
|
||||
if (jockstickConfig != null && jockstickConfig.getWheelList() != null) {
|
||||
for (Wheel wheel : this.b.getWheelList()) {
|
||||
if (engine.getMotionType() != this.b.getMotionType()) {
|
||||
break;
|
||||
} else if (engine.getId() == wheel.getId()) {
|
||||
selectEngineViewHolder.c.setTextColor(this.a.getResources().getColor(R.color.color_00C4C9));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (engine instanceof Servo) {
|
||||
Servo servo = (Servo) engine;
|
||||
selectEngineViewHolder.c.setText(String.format(selectEngineViewHolder.d, Integer.valueOf(servo.getId())));
|
||||
if (servo.getModeType() == ServoMode.SERVO_MODE_TURN) {
|
||||
if (c(i)) {
|
||||
selectEngineViewHolder.b.setBackgroundResource(R.drawable.engine_select);
|
||||
} else {
|
||||
selectEngineViewHolder.b.setBackgroundResource(R.drawable.bg_engine_2);
|
||||
}
|
||||
} else if (c(i)) {
|
||||
selectEngineViewHolder.b.setBackgroundResource(R.drawable.ic_engine_servo_angle_select);
|
||||
} else {
|
||||
selectEngineViewHolder.b.setBackgroundResource(R.drawable.ic_engine_servo_angle);
|
||||
}
|
||||
} else if (engine instanceof Motor) {
|
||||
selectEngineViewHolder.c.setText(String.format(selectEngineViewHolder.e, Integer.valueOf(engine.getId())));
|
||||
if (c(i)) {
|
||||
selectEngineViewHolder.b.setBackgroundResource(R.drawable.motor_s);
|
||||
} else {
|
||||
selectEngineViewHolder.b.setBackgroundResource(R.drawable.motor_d);
|
||||
}
|
||||
}
|
||||
selectEngineViewHolder.a.setOnClickListener(new View.OnClickListener() { // from class: com.ubt.jimu.controller.adapter.SelectEngineListAdapter.1
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view) {
|
||||
if (SelectEngineListAdapter.this.e != null) {
|
||||
Engine engine2 = engine;
|
||||
if ((engine2 instanceof Servo) && ((Servo) engine2).getModeType() == ServoMode.SERVO_MODE_ANGLE) {
|
||||
LogUtils.c("角度模式");
|
||||
SelectEngineListAdapter.this.e.A0();
|
||||
} else {
|
||||
SelectEngineListAdapter.this.e.a(engine, i);
|
||||
SelectEngineListAdapter.this.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void a(OnItemClickListener onItemClickListener) {
|
||||
this.e = onItemClickListener;
|
||||
}
|
||||
}
|
||||
148
sources/com/ubt/jimu/controller/adapter/VSliderSetAdapter.java
Normal file
148
sources/com/ubt/jimu/controller/adapter/VSliderSetAdapter.java
Normal file
@@ -0,0 +1,148 @@
|
||||
package com.ubt.jimu.controller.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.base.data.CtrlMotionType;
|
||||
import com.ubt.jimu.base.data.Engine;
|
||||
import com.ubt.jimu.base.data.Motor;
|
||||
import com.ubt.jimu.base.data.Servo;
|
||||
import com.ubt.jimu.base.data.ServoMode;
|
||||
import com.ubt.jimu.controller.data.config.SliderConfig;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class VSliderSetAdapter extends RecyclerView.Adapter<AngleViewHolder> {
|
||||
private Context a;
|
||||
private View b;
|
||||
private OnItemClickListener c;
|
||||
private List<Engine> d;
|
||||
private SliderConfig e;
|
||||
private int f;
|
||||
private CtrlMotionType g;
|
||||
|
||||
public class AngleViewHolder extends RecyclerView.ViewHolder {
|
||||
public TextView a;
|
||||
public ImageView b;
|
||||
|
||||
public AngleViewHolder(VSliderSetAdapter vSliderSetAdapter, View view) {
|
||||
super(view);
|
||||
this.a = (TextView) view.findViewById(R.id.tv_engine_name);
|
||||
this.b = (ImageView) view.findViewById(R.id.im_engine_icon);
|
||||
}
|
||||
}
|
||||
|
||||
public interface OnItemClickListener {
|
||||
void a(Engine engine, int i);
|
||||
|
||||
void c(Servo servo);
|
||||
}
|
||||
|
||||
public VSliderSetAdapter(Context context) {
|
||||
this.a = context;
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
||||
public int getItemCount() {
|
||||
List<Engine> list = this.d;
|
||||
if (list == null || list.size() <= 0) {
|
||||
return 0;
|
||||
}
|
||||
return this.d.size();
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public boolean b(Engine engine) {
|
||||
return this.e != null && engine.getId() == this.f && this.g == engine.getMotionType();
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
||||
public AngleViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
|
||||
return new AngleViewHolder(this, LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_angle_set, viewGroup, false));
|
||||
}
|
||||
|
||||
public void a(List<Engine> list) {
|
||||
this.d = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void a(SliderConfig sliderConfig) {
|
||||
this.e = sliderConfig;
|
||||
SliderConfig sliderConfig2 = this.e;
|
||||
if (sliderConfig2 != null) {
|
||||
this.f = sliderConfig2.getServoID();
|
||||
this.g = this.e.getMotionType();
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
||||
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
||||
public void onBindViewHolder(final AngleViewHolder angleViewHolder, final int i) {
|
||||
final Engine engine = this.d.get(i);
|
||||
if (engine != null) {
|
||||
if (engine instanceof Servo) {
|
||||
Servo servo = (Servo) engine;
|
||||
angleViewHolder.a.setText(String.format(this.a.getResources().getString(R.string.servo_mode_servo_index), Integer.valueOf(servo.getId())));
|
||||
if (servo.getModeType() == ServoMode.SERVO_MODE_TURN) {
|
||||
angleViewHolder.b.setBackgroundResource(R.mipmap.ic_servo_turn);
|
||||
} else {
|
||||
angleViewHolder.b.setBackgroundResource(R.mipmap.ic_servo_angle);
|
||||
}
|
||||
} else if (engine instanceof Motor) {
|
||||
angleViewHolder.a.setText(String.format(this.a.getResources().getString(R.string.control_motor_index), Integer.valueOf(engine.getId())));
|
||||
angleViewHolder.b.setBackgroundResource(R.mipmap.ic_motor);
|
||||
}
|
||||
if (a(engine)) {
|
||||
angleViewHolder.itemView.setBackgroundColor(this.a.getResources().getColor(R.color.bg_4D24A8FF));
|
||||
this.b = angleViewHolder.itemView;
|
||||
OnItemClickListener onItemClickListener = this.c;
|
||||
if (onItemClickListener != null) {
|
||||
onItemClickListener.a(engine, i);
|
||||
}
|
||||
} else {
|
||||
angleViewHolder.itemView.setBackgroundColor(this.a.getResources().getColor(R.color.color_FFFFFF));
|
||||
}
|
||||
if (engine.isConfigged() && !b(engine)) {
|
||||
angleViewHolder.b.setAlpha(0.65f);
|
||||
angleViewHolder.a.setAlpha(0.65f);
|
||||
} else {
|
||||
angleViewHolder.b.setAlpha(1.0f);
|
||||
angleViewHolder.a.setAlpha(1.0f);
|
||||
}
|
||||
}
|
||||
angleViewHolder.itemView.setOnClickListener(new View.OnClickListener() { // from class: com.ubt.jimu.controller.adapter.VSliderSetAdapter.1
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view) {
|
||||
Engine engine2 = engine;
|
||||
if ((engine2 instanceof Servo) && ((Servo) engine2).getModeType() != ServoMode.SERVO_MODE_TURN) {
|
||||
VSliderSetAdapter.this.c.c((Servo) engine);
|
||||
return;
|
||||
}
|
||||
if (!engine.isConfigged() || VSliderSetAdapter.this.b(engine)) {
|
||||
if (VSliderSetAdapter.this.b != null) {
|
||||
VSliderSetAdapter.this.b.setBackgroundColor(VSliderSetAdapter.this.a.getResources().getColor(R.color.color_FFFFFF));
|
||||
}
|
||||
angleViewHolder.itemView.setBackgroundColor(VSliderSetAdapter.this.a.getResources().getColor(R.color.bg_4D24A8FF));
|
||||
VSliderSetAdapter.this.b = angleViewHolder.itemView;
|
||||
if (VSliderSetAdapter.this.c != null) {
|
||||
VSliderSetAdapter.this.c.a(engine, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean a(Engine engine) {
|
||||
return this.e != null && engine.getId() == this.e.getServoID() && this.e.getMotionType() == engine.getMotionType();
|
||||
}
|
||||
|
||||
public void a(OnItemClickListener onItemClickListener) {
|
||||
this.c = onItemClickListener;
|
||||
}
|
||||
}
|
||||
565
sources/com/ubt/jimu/controller/component/ActionView.java
Normal file
565
sources/com/ubt/jimu/controller/component/ActionView.java
Normal file
@@ -0,0 +1,565 @@
|
||||
package com.ubt.jimu.controller.component;
|
||||
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.controller.data.widget.ActionWidgetData;
|
||||
import com.ubt.jimu.controller.util.SvgUtils;
|
||||
import com.ubt.jimu.controller.view.control.ControlTouchEvent;
|
||||
import com.ubt.jimu.controller.view.control.OnControllerClickListener;
|
||||
import com.ubt.jimu.controller.view.control.SuperControlView;
|
||||
import com.ubt.jimu.utils.LocaleUtils;
|
||||
import com.ubt.jimu.utils.LogUtils;
|
||||
import com.ubt.jimu.utils.SystemUtils;
|
||||
import com.ubtrobot.log.ALog;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ActionView extends SuperControlView<ActionWidgetData> {
|
||||
private Context B;
|
||||
private float C;
|
||||
private float D;
|
||||
private Paint E;
|
||||
private Paint F;
|
||||
private Paint G;
|
||||
private RectF H;
|
||||
private RectF I;
|
||||
private RectF J;
|
||||
private RectF K;
|
||||
private Bitmap L;
|
||||
private Bitmap M;
|
||||
private String N;
|
||||
private Bitmap O;
|
||||
private Bitmap P;
|
||||
private Bitmap Q;
|
||||
private Bitmap R;
|
||||
private float S;
|
||||
private float T;
|
||||
private float U;
|
||||
private float V;
|
||||
private float W;
|
||||
private float a0;
|
||||
private ValueAnimator b0;
|
||||
private float c0;
|
||||
private float d0;
|
||||
private int e0;
|
||||
private float f0;
|
||||
private float g0;
|
||||
private long h0;
|
||||
private long i0;
|
||||
|
||||
public ActionView(Context context, int i, float f, float f2) {
|
||||
super(context);
|
||||
this.a0 = -360.0f;
|
||||
this.B = context;
|
||||
this.C = f;
|
||||
this.D = f2;
|
||||
this.e0 = i;
|
||||
j();
|
||||
i();
|
||||
}
|
||||
|
||||
private void b(float f, float f2) {
|
||||
this.H.offsetTo(f, f2);
|
||||
this.j.offsetTo(f, f2);
|
||||
float centerX = this.H.centerX();
|
||||
float centerY = this.H.centerY();
|
||||
RectF rectF = this.I;
|
||||
float f3 = this.f0;
|
||||
rectF.offsetTo(centerX - (f3 / 2.0f), centerY - (f3 / 2.0f));
|
||||
this.K.offsetTo(centerX - this.V, centerY - this.W);
|
||||
}
|
||||
|
||||
private void g() {
|
||||
OnControllerClickListener onControllerClickListener = getOnControllerClickListener();
|
||||
if (onControllerClickListener == null || b()) {
|
||||
return;
|
||||
}
|
||||
if (this.z == 0) {
|
||||
long j = this.h0;
|
||||
if (j - this.t > 500 || j - this.i0 < 500) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
float centerY = this.H.centerY();
|
||||
float centerX = this.H.centerX();
|
||||
float f = this.c0;
|
||||
float f2 = this.l;
|
||||
if (f < centerX - (f2 / 2.0f) || f > centerX + (f2 / 2.0f)) {
|
||||
return;
|
||||
}
|
||||
float f3 = this.d0;
|
||||
float f4 = this.m;
|
||||
if (f3 < centerY - (f4 / 2.0f) || f3 > centerY + (f4 / 2.0f)) {
|
||||
return;
|
||||
}
|
||||
onControllerClickListener.a(getData(), this);
|
||||
this.i0 = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
private void h() {
|
||||
if (this.e0 == 0) {
|
||||
this.e0 = R.drawable.icon_loudly;
|
||||
}
|
||||
SvgUtils a = SvgUtils.a(this.B);
|
||||
int i = this.e0;
|
||||
float f = this.f0;
|
||||
this.L = a.a(i, (int) f, (int) f);
|
||||
}
|
||||
|
||||
private void i() {
|
||||
this.l = this.B.getResources().getDimension(R.dimen.grid_view_width) * 4.0f;
|
||||
this.m = this.l;
|
||||
float f = this.D;
|
||||
float f2 = this.m;
|
||||
float f3 = f + (f2 / 2.0f);
|
||||
int i = this.s;
|
||||
if (f3 >= i) {
|
||||
this.D = i - (f2 / 2.0f);
|
||||
}
|
||||
float f4 = this.C;
|
||||
float f5 = this.m;
|
||||
if (f4 - (f5 / 2.0f) <= 0.0f) {
|
||||
this.C = f5 / 2.0f;
|
||||
} else {
|
||||
float f6 = f4 + (f5 / 2.0f);
|
||||
int i2 = this.r;
|
||||
if (f6 >= i2) {
|
||||
this.C = i2 - (f5 / 2.0f);
|
||||
}
|
||||
}
|
||||
this.U = this.B.getResources().getDimension(R.dimen.control_action_width);
|
||||
this.f0 = this.B.getResources().getDimension(R.dimen.control_action_width);
|
||||
this.g0 = this.B.getResources().getDimension(R.dimen.control_action_text_width);
|
||||
h();
|
||||
this.O = BitmapFactory.decodeResource(this.B.getResources(), R.mipmap.btn_shadow);
|
||||
this.R = BitmapFactory.decodeResource(this.B.getResources(), R.mipmap.text_background_normal);
|
||||
this.Q = BitmapFactory.decodeResource(this.B.getResources(), R.mipmap.text_background_pressed);
|
||||
this.P = this.R;
|
||||
this.E = new Paint();
|
||||
this.E.setFlags(3);
|
||||
this.F = new Paint();
|
||||
this.G = new Paint();
|
||||
this.F.setAntiAlias(true);
|
||||
this.F.setColor(this.B.getResources().getColor(R.color.bg_C9EBFE));
|
||||
this.G.setColor(this.B.getResources().getColor(R.color.bg_FFFFFF));
|
||||
float f7 = this.C;
|
||||
float f8 = this.l;
|
||||
float f9 = this.D;
|
||||
float f10 = this.m;
|
||||
this.j = new RectF(f7 - (f8 / 2.0f), f9 - (f10 / 2.0f), f7 + (f8 / 2.0f), f9 + (f10 / 2.0f));
|
||||
float f11 = this.C;
|
||||
float f12 = this.l;
|
||||
float f13 = this.D;
|
||||
float f14 = this.m;
|
||||
this.H = new RectF(f11 - (f12 / 2.0f), f13 - (f14 / 2.0f), f11 + (f12 / 2.0f), f13 + (f14 / 2.0f));
|
||||
this.V = this.B.getResources().getDimension(R.dimen.control_action_text_x_offset);
|
||||
this.W = this.B.getResources().getDimension(R.dimen.control_action_text_y_offset);
|
||||
float[] viewCenterXY = getViewCenterXY();
|
||||
this.K = new RectF(viewCenterXY[0] - this.V, viewCenterXY[1] - this.W, this.C + (this.l / 2.0f), this.D + (this.m / 2.0f));
|
||||
this.J = new RectF();
|
||||
float f15 = this.C;
|
||||
float f16 = this.f0;
|
||||
float f17 = this.D;
|
||||
this.I = new RectF(f15 - (f16 / 2.0f), f17 - (f16 / 2.0f), f15 + (f16 / 2.0f), f17 + (f16 / 2.0f));
|
||||
}
|
||||
|
||||
private void j() {
|
||||
}
|
||||
|
||||
public void a(int i) {
|
||||
this.e0 = i;
|
||||
h();
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public void f() {
|
||||
ALog.a("Test").d("Text:" + this.N);
|
||||
this.N = null;
|
||||
this.M = null;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return this.N;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.view.control.SuperControlView
|
||||
public float[] getViewCenterXY() {
|
||||
return new float[]{this.H.centerX(), this.H.centerY()};
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.view.control.SuperControlView, android.view.View
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
if (b()) {
|
||||
canvas.drawBitmap(this.O, (Rect) null, this.H, this.E);
|
||||
canvas.drawBitmap(this.L, (Rect) null, this.I, this.E);
|
||||
return;
|
||||
}
|
||||
if (getState() == 0) {
|
||||
a();
|
||||
canvas.drawBitmap(this.O, (Rect) null, this.H, this.E);
|
||||
canvas.drawArc(this.J, 270.0f, this.a0, true, this.F);
|
||||
a(canvas);
|
||||
canvas.drawBitmap(this.L, (Rect) null, this.I, this.E);
|
||||
return;
|
||||
}
|
||||
if (c()) {
|
||||
e();
|
||||
}
|
||||
canvas.drawBitmap(this.O, (Rect) null, this.H, this.E);
|
||||
a(canvas);
|
||||
canvas.drawBitmap(this.L, (Rect) null, this.I, this.E);
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public boolean onTouchEvent(MotionEvent motionEvent) {
|
||||
int actionMasked = motionEvent.getActionMasked();
|
||||
if (actionMasked == 0) {
|
||||
this.t = System.currentTimeMillis();
|
||||
this.c0 = motionEvent.getX();
|
||||
this.d0 = motionEvent.getY();
|
||||
d();
|
||||
float centerX = this.H.centerX();
|
||||
float centerY = this.H.centerY();
|
||||
float f = this.c0;
|
||||
float f2 = this.l;
|
||||
if (f >= centerX - (f2 / 2.0f) && f <= (f2 / 2.0f) + centerX) {
|
||||
float f3 = this.d0;
|
||||
float f4 = this.m;
|
||||
if (f3 >= centerY - (f4 / 2.0f) && f3 <= (f4 / 2.0f) + centerY) {
|
||||
this.f = false;
|
||||
setPressed(true);
|
||||
if (b()) {
|
||||
float centerX2 = this.j.centerX();
|
||||
float centerY2 = this.j.centerY();
|
||||
this.S = centerX2 - this.c0;
|
||||
this.T = centerY2 - this.d0;
|
||||
bringToFront();
|
||||
ControlTouchEvent controlTouchEvent = this.i;
|
||||
if (controlTouchEvent != null) {
|
||||
controlTouchEvent.a((View) this);
|
||||
}
|
||||
} else if (getState() == 0) {
|
||||
ValueAnimator valueAnimator = this.b0;
|
||||
if (valueAnimator != null) {
|
||||
valueAnimator.cancel();
|
||||
}
|
||||
this.a0 = -360.0f;
|
||||
RectF rectF = this.J;
|
||||
float f5 = this.U;
|
||||
rectF.set(centerX - (f5 / 2.0f), centerY - (f5 / 2.0f), centerX + (f5 / 2.0f), centerY + (f5 / 2.0f));
|
||||
this.P = this.Q;
|
||||
this.H.set(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
ControlTouchEvent controlTouchEvent2 = this.i;
|
||||
if (controlTouchEvent2 != null) {
|
||||
controlTouchEvent2.a((SuperControlView) this);
|
||||
this.i.a(getData());
|
||||
}
|
||||
invalidate();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return super.onTouchEvent(motionEvent);
|
||||
}
|
||||
if (actionMasked == 1) {
|
||||
setPressed(false);
|
||||
if (!this.f) {
|
||||
LogUtils.c("MotionEvent: 抬起");
|
||||
this.f = true;
|
||||
a(SuperControlView.MotionEventState.STATE_UP);
|
||||
}
|
||||
invalidate();
|
||||
return true;
|
||||
}
|
||||
if (actionMasked != 2) {
|
||||
if (actionMasked != 3) {
|
||||
return super.onTouchEvent(motionEvent);
|
||||
}
|
||||
if (!this.f) {
|
||||
LogUtils.c("MotionEvent:取消");
|
||||
this.f = true;
|
||||
a(SuperControlView.MotionEventState.STATE_CANCEL);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (b()) {
|
||||
float x = motionEvent.getX();
|
||||
float y = motionEvent.getY();
|
||||
b(super.a(motionEvent, this.S), super.b(motionEvent, this.T));
|
||||
boolean a = a(this.j);
|
||||
if (this.i != null) {
|
||||
if (Math.abs(this.c0 - x) <= 20.0f && Math.abs(this.d0 - y) <= 20.0f) {
|
||||
return true;
|
||||
}
|
||||
this.i.b((View) this);
|
||||
if (a) {
|
||||
if (this.e != null && getData() != null) {
|
||||
this.e.setOverlapState(true);
|
||||
this.e.a(String.format(getResources().getString(R.string.control_remove_widget), getData().getWidgetInfo(this.B)));
|
||||
}
|
||||
b(false);
|
||||
this.b.setColor(this.B.getResources().getColor(R.color.color_FF4979));
|
||||
if (!this.n) {
|
||||
SystemUtils.b(this.B);
|
||||
this.n = true;
|
||||
}
|
||||
} else {
|
||||
if (this.e != null && getData() != null) {
|
||||
this.e.setOverlapState(false);
|
||||
this.e.a(String.format(getResources().getString(R.string.control_remove_widget_here), getData().getShowName(LocaleUtils.b())));
|
||||
}
|
||||
RectF rectF2 = this.H;
|
||||
PointF a2 = a(rectF2.left, rectF2.top);
|
||||
this.k.offsetTo(a2.x, a2.y);
|
||||
if (this.i.c((SuperControlView) this)) {
|
||||
b(false);
|
||||
this.b.setColor(this.B.getResources().getColor(R.color.bg_99B8BEC1));
|
||||
} else {
|
||||
b(true);
|
||||
this.b.setColor(this.B.getResources().getColor(this.a));
|
||||
}
|
||||
this.n = false;
|
||||
}
|
||||
}
|
||||
invalidate();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
|
||||
public Bitmap a(String str) {
|
||||
char c;
|
||||
switch (str.hashCode()) {
|
||||
case -1721778389:
|
||||
if (str.equals("DPAD_UP")) {
|
||||
c = '\b';
|
||||
break;
|
||||
}
|
||||
c = 65535;
|
||||
break;
|
||||
case -1067127502:
|
||||
if (str.equals("DPAD_DOWN")) {
|
||||
c = '\t';
|
||||
break;
|
||||
}
|
||||
c = 65535;
|
||||
break;
|
||||
case -1066899305:
|
||||
if (str.equals("DPAD_LEFT")) {
|
||||
c = '\n';
|
||||
break;
|
||||
}
|
||||
c = 65535;
|
||||
break;
|
||||
case 65:
|
||||
if (str.equals("A")) {
|
||||
c = 0;
|
||||
break;
|
||||
}
|
||||
c = 65535;
|
||||
break;
|
||||
case 66:
|
||||
if (str.equals("B")) {
|
||||
c = 1;
|
||||
break;
|
||||
}
|
||||
c = 65535;
|
||||
break;
|
||||
case 88:
|
||||
if (str.equals("X")) {
|
||||
c = 2;
|
||||
break;
|
||||
}
|
||||
c = 65535;
|
||||
break;
|
||||
case 89:
|
||||
if (str.equals("Y")) {
|
||||
c = 3;
|
||||
break;
|
||||
}
|
||||
c = 65535;
|
||||
break;
|
||||
case 2405:
|
||||
if (str.equals("L1")) {
|
||||
c = 4;
|
||||
break;
|
||||
}
|
||||
c = 65535;
|
||||
break;
|
||||
case 2406:
|
||||
if (str.equals("L2")) {
|
||||
c = 5;
|
||||
break;
|
||||
}
|
||||
c = 65535;
|
||||
break;
|
||||
case 2591:
|
||||
if (str.equals("R1")) {
|
||||
c = 6;
|
||||
break;
|
||||
}
|
||||
c = 65535;
|
||||
break;
|
||||
case 2592:
|
||||
if (str.equals("R2")) {
|
||||
c = 7;
|
||||
break;
|
||||
}
|
||||
c = 65535;
|
||||
break;
|
||||
case 1291520876:
|
||||
if (str.equals("DPAD_RIGHT")) {
|
||||
c = 11;
|
||||
break;
|
||||
}
|
||||
c = 65535;
|
||||
break;
|
||||
default:
|
||||
c = 65535;
|
||||
break;
|
||||
}
|
||||
int i = R.drawable.ic_text_x;
|
||||
switch (c) {
|
||||
case 0:
|
||||
i = R.drawable.ic_text_a;
|
||||
break;
|
||||
case 1:
|
||||
i = R.drawable.ic_text_b;
|
||||
break;
|
||||
case 2:
|
||||
break;
|
||||
case 3:
|
||||
i = R.drawable.ic_text_y;
|
||||
break;
|
||||
case 4:
|
||||
i = R.drawable.ic_text_l1;
|
||||
break;
|
||||
case 5:
|
||||
i = R.drawable.ic_text_l2;
|
||||
break;
|
||||
case 6:
|
||||
i = R.drawable.ic_text_r1;
|
||||
break;
|
||||
case 7:
|
||||
i = R.drawable.ic_text_r2;
|
||||
break;
|
||||
case '\b':
|
||||
i = R.drawable.ic_text_direction_up;
|
||||
break;
|
||||
case '\t':
|
||||
i = R.drawable.ic_text_direction_down;
|
||||
break;
|
||||
case '\n':
|
||||
i = R.drawable.ic_text_direction_left;
|
||||
break;
|
||||
case 11:
|
||||
i = R.drawable.ic_text_direction_right;
|
||||
break;
|
||||
default:
|
||||
Log.e("ActionView", "Invalid text, use defaut text X");
|
||||
break;
|
||||
}
|
||||
if (i == 0) {
|
||||
return null;
|
||||
}
|
||||
SvgUtils a = SvgUtils.a(this.B);
|
||||
float f = this.g0;
|
||||
return a.a(i, (int) f, (int) f);
|
||||
}
|
||||
|
||||
private void a(Canvas canvas) {
|
||||
if (this.M != null) {
|
||||
canvas.drawBitmap(this.P, (Rect) null, this.K, this.E);
|
||||
canvas.drawBitmap(this.M, (Rect) null, new RectF(this.K.centerX() - (this.g0 / 2.0f), this.K.centerY() - (this.g0 / 2.0f), this.K.centerX() + (this.g0 / 2.0f), this.K.centerY() + (this.g0 / 2.0f)), this.E);
|
||||
}
|
||||
}
|
||||
|
||||
public void b(String str) {
|
||||
ALog.a("Test").d("Text:" + str);
|
||||
this.N = str;
|
||||
if (TextUtils.isEmpty(str)) {
|
||||
f();
|
||||
}
|
||||
this.M = a(str);
|
||||
invalidate();
|
||||
}
|
||||
|
||||
private void a(SuperControlView.MotionEventState motionEventState) {
|
||||
ActionWidgetData data;
|
||||
this.h0 = System.currentTimeMillis();
|
||||
if (b()) {
|
||||
this.S = 0.0f;
|
||||
this.T = 0.0f;
|
||||
if (a(this.j)) {
|
||||
if (this.i != null && (data = getData()) != null) {
|
||||
this.i.a(this, data.getActionID());
|
||||
this.i.c((View) this);
|
||||
}
|
||||
invalidate();
|
||||
return;
|
||||
}
|
||||
if (this.i != null) {
|
||||
RectF rectF = this.H;
|
||||
PointF a = a(rectF.left, rectF.top);
|
||||
this.k.offsetTo(a.x, a.y);
|
||||
if (this.i.c((SuperControlView) this)) {
|
||||
b(this.o, this.p);
|
||||
this.b.setColor(this.B.getResources().getColor(this.a));
|
||||
} else {
|
||||
b(a.x, a.y);
|
||||
this.i.a(this, this.j.centerX(), this.j.centerY());
|
||||
}
|
||||
this.i.c((View) this);
|
||||
if (System.currentTimeMillis() - this.t < 300) {
|
||||
this.i.a(this, getData());
|
||||
}
|
||||
}
|
||||
b(false);
|
||||
return;
|
||||
}
|
||||
float centerX = this.I.centerX();
|
||||
float centerY = this.I.centerY();
|
||||
RectF rectF2 = this.H;
|
||||
float f = this.l;
|
||||
float f2 = this.m;
|
||||
rectF2.set(centerX - (f / 2.0f), centerY - (f2 / 2.0f), centerX + (f / 2.0f), centerY + (f2 / 2.0f));
|
||||
this.J.set(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
this.P = this.R;
|
||||
int i = this.z;
|
||||
if (i != 0) {
|
||||
if (i != 2) {
|
||||
return;
|
||||
}
|
||||
setSelect(true);
|
||||
g();
|
||||
return;
|
||||
}
|
||||
g();
|
||||
ControlTouchEvent controlTouchEvent = this.i;
|
||||
if (controlTouchEvent != null) {
|
||||
controlTouchEvent.b((SuperControlView) this);
|
||||
this.i.a(getData(), motionEventState);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean a(RectF rectF) {
|
||||
RectF deleteViewRectF = getDeleteViewRectF();
|
||||
if (deleteViewRectF == null) {
|
||||
return false;
|
||||
}
|
||||
return RectF.intersects(deleteViewRectF, rectF);
|
||||
}
|
||||
}
|
||||
785
sources/com/ubt/jimu/controller/component/AngleSetView.java
Normal file
785
sources/com/ubt/jimu/controller/component/AngleSetView.java
Normal file
@@ -0,0 +1,785 @@
|
||||
package com.ubt.jimu.controller.component;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.LinearGradient;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.Shader;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.utils.LogUtils;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AngleSetView extends View {
|
||||
private Bitmap A;
|
||||
private Bitmap B;
|
||||
private Bitmap C;
|
||||
private float D;
|
||||
private float E;
|
||||
private float F;
|
||||
private boolean G;
|
||||
private Paint H;
|
||||
private Paint I;
|
||||
private Paint J;
|
||||
private Paint K;
|
||||
private Paint L;
|
||||
private double M;
|
||||
private double N;
|
||||
private float O;
|
||||
private float P;
|
||||
private String Q;
|
||||
private String R;
|
||||
private float S;
|
||||
private float T;
|
||||
private float U;
|
||||
private float V;
|
||||
private String W;
|
||||
private float a;
|
||||
private String a0;
|
||||
private float b;
|
||||
private float b0;
|
||||
private float c;
|
||||
private AngleUpdateListener c0;
|
||||
private float d;
|
||||
private boolean d0;
|
||||
private float e;
|
||||
private float f;
|
||||
private float g;
|
||||
private float h;
|
||||
private float i;
|
||||
private float j;
|
||||
private Paint k;
|
||||
private Paint l;
|
||||
private Paint m;
|
||||
private Paint n;
|
||||
private Paint o;
|
||||
private RectF p;
|
||||
private RectF q;
|
||||
private RectF r;
|
||||
private RectF s;
|
||||
private RectF t;
|
||||
private RectF u;
|
||||
private RectF v;
|
||||
private RectF x;
|
||||
private Context y;
|
||||
private Bitmap z;
|
||||
|
||||
public interface AngleUpdateListener {
|
||||
void a(double d);
|
||||
|
||||
void c(double d);
|
||||
}
|
||||
|
||||
enum DataType {
|
||||
MIN,
|
||||
MAX
|
||||
}
|
||||
|
||||
public AngleSetView(Context context) {
|
||||
super(context);
|
||||
this.h = 150.0f;
|
||||
this.i = 0.0f;
|
||||
this.j = 0.0f;
|
||||
this.S = -118.0f;
|
||||
this.T = 118.0f;
|
||||
this.U = -118.0f;
|
||||
this.V = 118.0f;
|
||||
this.d0 = false;
|
||||
this.y = context;
|
||||
a();
|
||||
}
|
||||
|
||||
private void b(float f, float f2) {
|
||||
if (f == this.U) {
|
||||
this.J.setAlpha(60);
|
||||
} else {
|
||||
this.J.setAlpha(255);
|
||||
}
|
||||
if (f2 == this.V) {
|
||||
this.K.setAlpha(60);
|
||||
} else {
|
||||
this.K.setAlpha(255);
|
||||
}
|
||||
}
|
||||
|
||||
private void c() {
|
||||
double d = this.N;
|
||||
double d2 = this.M;
|
||||
if (d < 90.0d) {
|
||||
d += 360.0d;
|
||||
}
|
||||
if (d2 < 90.0d) {
|
||||
d2 = this.M + 360.0d;
|
||||
}
|
||||
if (d - d2 > 0.0d) {
|
||||
this.I.setAlpha(255);
|
||||
return;
|
||||
}
|
||||
this.M = this.N;
|
||||
float centerX = this.s.centerX();
|
||||
float centerY = this.s.centerY();
|
||||
RectF rectF = this.r;
|
||||
float f = this.h;
|
||||
rectF.offsetTo(centerX - (f / 2.0f), centerY - (f / 2.0f));
|
||||
this.I.setAlpha(66);
|
||||
}
|
||||
|
||||
private void d(float f, float f2) {
|
||||
this.J.setAlpha(255);
|
||||
double d = this.M;
|
||||
if (d > 152.0d || d < Math.abs(-28.0f)) {
|
||||
return;
|
||||
}
|
||||
if (this.M >= Math.abs(-28.0f) && this.M < 90.0d) {
|
||||
float sin = (float) ((this.g / 2.0f) * Math.sin((Math.abs(-28.0f) * 3.141592653589793d) / 180.0d));
|
||||
float cos = (float) ((this.g / 2.0f) * Math.cos((Math.abs(-28.0f) * 3.141592653589793d) / 180.0d));
|
||||
RectF rectF = this.r;
|
||||
float f3 = this.F;
|
||||
rectF.offsetTo((f + cos) - (f3 / 2.0f), (f2 + sin) - (f3 / 2.0f));
|
||||
this.M = 28.0d;
|
||||
return;
|
||||
}
|
||||
float sin2 = (float) ((this.g / 2.0f) * Math.sin((Math.abs(-28.0f) * 3.141592653589793d) / 180.0d));
|
||||
float cos2 = (float) ((this.g / 2.0f) * Math.cos((Math.abs(-28.0f) * 3.141592653589793d) / 180.0d));
|
||||
RectF rectF2 = this.r;
|
||||
float f4 = this.F;
|
||||
rectF2.offsetTo((f - cos2) - (f4 / 2.0f), (f2 + sin2) - (f4 / 2.0f));
|
||||
this.M = 152.0d;
|
||||
this.J.setAlpha(60);
|
||||
}
|
||||
|
||||
public void a(float f, float f2) {
|
||||
this.S = f;
|
||||
this.T = f2;
|
||||
this.W = ((int) f) + "°";
|
||||
this.a0 = ((int) f2) + "°";
|
||||
b(f, f2);
|
||||
float[] a = a(f, DataType.MIN);
|
||||
float[] a2 = a(f2, DataType.MAX);
|
||||
RectF rectF = this.r;
|
||||
if (rectF != null) {
|
||||
float f3 = a[0];
|
||||
float f4 = this.h;
|
||||
rectF.set(f3 - (f4 / 2.0f), a[1] - (f4 / 2.0f), a[0] + (f4 / 2.0f), a[1] + (f4 / 2.0f));
|
||||
}
|
||||
RectF rectF2 = this.s;
|
||||
if (rectF2 != null) {
|
||||
float f5 = a2[0];
|
||||
float f6 = this.h;
|
||||
rectF2.set(f5 - (f6 / 2.0f), a2[1] - (f6 / 2.0f), a2[0] + (f6 / 2.0f), a2[1] + (f6 / 2.0f));
|
||||
}
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public float getCurrentMax() {
|
||||
return this.E;
|
||||
}
|
||||
|
||||
public float getCurrentMin() {
|
||||
return this.D;
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
protected void onDraw(Canvas canvas) {
|
||||
double d;
|
||||
canvas.drawArc(this.p, 152.0f, 236.0f, false, this.k);
|
||||
LogUtils.c("progressStartAngle:" + this.M + " progressEndAngle:" + this.N);
|
||||
double d2 = this.N;
|
||||
if (d2 == this.M) {
|
||||
d = 0.11d;
|
||||
LogUtils.c("progressEndAngle == progressStartAngle1111");
|
||||
} else {
|
||||
if (d2 <= 152.0d || d2 > 360.0d) {
|
||||
double d3 = this.M;
|
||||
if (d3 < 0.0d || d3 >= 152.0d || d3 >= this.N) {
|
||||
double d4 = this.N;
|
||||
if (d4 >= 0.0d && d4 < 152.0d) {
|
||||
double d5 = this.M;
|
||||
if (d4 != d5) {
|
||||
d = d4 + (360.0d - d5);
|
||||
LogUtils.c("3333");
|
||||
}
|
||||
}
|
||||
d = 0.0d;
|
||||
}
|
||||
}
|
||||
d = this.N - this.M;
|
||||
LogUtils.c("2222222");
|
||||
}
|
||||
double d6 = this.M;
|
||||
if (d < 0.0d) {
|
||||
d = d + 360.0d + 152.0d;
|
||||
LogUtils.c("44444");
|
||||
}
|
||||
LogUtils.c("startAngle:" + d6 + " sweepAngle:" + d);
|
||||
canvas.drawArc(this.q, (float) d6, (float) d, false, this.l);
|
||||
if (this.G) {
|
||||
canvas.drawBitmap(this.A, (Rect) null, this.r, this.m);
|
||||
canvas.drawBitmap(this.z, (Rect) null, this.s, this.m);
|
||||
} else {
|
||||
canvas.drawBitmap(this.z, (Rect) null, this.s, this.m);
|
||||
canvas.drawBitmap(this.A, (Rect) null, this.r, this.m);
|
||||
}
|
||||
canvas.drawBitmap(this.B, (Rect) null, this.t, this.K);
|
||||
canvas.drawBitmap(this.B, (Rect) null, this.u, this.I);
|
||||
canvas.drawBitmap(this.C, (Rect) null, this.v, this.L);
|
||||
canvas.drawBitmap(this.C, (Rect) null, this.x, this.J);
|
||||
canvas.drawText(this.W, this.u.centerX(), this.O - this.f, this.n);
|
||||
canvas.drawText(this.a0, this.t.centerX(), this.O - this.f, this.n);
|
||||
canvas.drawText(this.Q, this.t.centerX(), this.O + this.f, this.o);
|
||||
canvas.drawText(this.R, this.u.centerX(), this.O + this.f, this.o);
|
||||
super.onDraw(canvas);
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public boolean onTouchEvent(MotionEvent motionEvent) {
|
||||
int i;
|
||||
int action = motionEvent.getAction();
|
||||
if (action != 0) {
|
||||
if (action == 2) {
|
||||
float x = motionEvent.getX();
|
||||
float y = motionEvent.getY();
|
||||
float centerX = this.p.centerX();
|
||||
float centerY = this.p.centerY();
|
||||
double sqrt = Math.sqrt((r0 * r0) + (r2 * r2));
|
||||
float f = this.g;
|
||||
double d = (((f / 2.0f) / sqrt) * (x - centerX)) + (f / 2.0f);
|
||||
double d2 = (((f / 2.0f) / sqrt) * (y - centerY)) + (f / 2.0f);
|
||||
if (this.G) {
|
||||
if (this.d0) {
|
||||
return super.onTouchEvent(motionEvent);
|
||||
}
|
||||
this.N = a(centerX, centerY, d, d2);
|
||||
b();
|
||||
if (Math.round(this.N) == 28.0f) {
|
||||
this.K.setAlpha(66);
|
||||
} else {
|
||||
this.K.setAlpha(255);
|
||||
}
|
||||
c(centerX, centerY);
|
||||
double a = a(this.N);
|
||||
this.a0 = ((int) a) + "°";
|
||||
AngleUpdateListener angleUpdateListener = this.c0;
|
||||
if (angleUpdateListener != null) {
|
||||
angleUpdateListener.a(a);
|
||||
}
|
||||
} else {
|
||||
if (this.d0) {
|
||||
return super.onTouchEvent(motionEvent);
|
||||
}
|
||||
this.M = b(centerX, centerY, d, d2);
|
||||
c();
|
||||
d(centerX, centerY);
|
||||
double a2 = a(this.M);
|
||||
this.W = ((int) a2) + "°";
|
||||
AngleUpdateListener angleUpdateListener2 = this.c0;
|
||||
if (angleUpdateListener2 != null) {
|
||||
angleUpdateListener2.c(a2);
|
||||
}
|
||||
}
|
||||
invalidate();
|
||||
}
|
||||
return super.onTouchEvent(motionEvent);
|
||||
}
|
||||
float x2 = motionEvent.getX();
|
||||
float y2 = motionEvent.getY();
|
||||
float centerX2 = this.r.centerX();
|
||||
float centerY2 = this.r.centerY();
|
||||
float centerX3 = this.s.centerX();
|
||||
float centerY3 = this.s.centerY();
|
||||
this.d0 = false;
|
||||
if (this.G) {
|
||||
float f2 = this.h;
|
||||
if (x2 >= centerX3 - (f2 / 2.0f) && x2 <= centerX3 + (f2 / 2.0f) && y2 >= centerY3 - (f2 / 2.0f) && y2 <= centerY3 + (f2 / 2.0f)) {
|
||||
this.G = true;
|
||||
return true;
|
||||
}
|
||||
float f3 = this.h;
|
||||
if (x2 >= centerX2 - (f3 / 2.0f) && x2 <= centerX2 + (f3 / 2.0f) && y2 >= centerY2 - (f3 / 2.0f) && y2 <= centerY2 + (f3 / 2.0f)) {
|
||||
this.G = false;
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
float f4 = this.h;
|
||||
if (x2 >= centerX2 - (f4 / 2.0f) && x2 <= centerX2 + (f4 / 2.0f) && y2 >= centerY2 - (f4 / 2.0f) && y2 <= centerY2 + (f4 / 2.0f)) {
|
||||
this.G = false;
|
||||
return true;
|
||||
}
|
||||
float f5 = this.h;
|
||||
if (x2 >= centerX3 - (f5 / 2.0f) && x2 <= centerX3 + (f5 / 2.0f) && y2 >= centerY3 - (f5 / 2.0f) && y2 <= centerY3 + (f5 / 2.0f)) {
|
||||
this.G = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
float centerX4 = this.u.centerX();
|
||||
float centerY4 = this.u.centerY();
|
||||
float f6 = this.a;
|
||||
float f7 = this.b0;
|
||||
if (x2 >= (centerX4 - (f6 / 2.0f)) - f7 && x2 <= centerX4 + (f6 / 2.0f) + f7) {
|
||||
float f8 = this.b;
|
||||
if (y2 >= (centerY4 - (f8 / 2.0f)) - f7 && y2 <= centerY4 + (f8 / 2.0f) + f7) {
|
||||
this.d0 = true;
|
||||
this.G = false;
|
||||
this.M += 1.0d;
|
||||
double d3 = this.M;
|
||||
if (d3 < 28.0d || d3 >= 152.0d) {
|
||||
double d4 = this.M;
|
||||
double d5 = this.N;
|
||||
if (d4 == d5) {
|
||||
this.M = d5;
|
||||
} else if (d4 < 0.0d) {
|
||||
this.M = 360.0d;
|
||||
} else if (d4 > 360.0d) {
|
||||
this.M = d4 - 360.0d;
|
||||
}
|
||||
} else {
|
||||
this.M = 28.0d;
|
||||
}
|
||||
c();
|
||||
this.J.setAlpha(255);
|
||||
double a3 = a(this.M);
|
||||
this.W = ((int) a3) + "°";
|
||||
float[] a4 = a((float) this.M);
|
||||
RectF rectF = this.r;
|
||||
float f9 = a4[0];
|
||||
float f10 = this.h;
|
||||
rectF.set(f9 - (f10 / 2.0f), a4[1] - (f10 / 2.0f), a4[0] + (f10 / 2.0f), a4[1] + (f10 / 2.0f));
|
||||
invalidate();
|
||||
AngleUpdateListener angleUpdateListener3 = this.c0;
|
||||
if (angleUpdateListener3 != null) {
|
||||
angleUpdateListener3.c(a3);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
float centerX5 = this.x.centerX();
|
||||
float centerY5 = this.x.centerY();
|
||||
float f11 = this.a;
|
||||
float f12 = this.b0;
|
||||
if (x2 >= (centerX5 - (f11 / 2.0f)) - f12 && x2 <= centerX5 + (f11 / 2.0f) + f12) {
|
||||
float f13 = this.b;
|
||||
if (y2 >= (centerY5 - (f13 / 2.0f)) - f12 && y2 <= centerY5 + (f13 / 2.0f) + f12) {
|
||||
this.d0 = true;
|
||||
this.G = false;
|
||||
this.M -= 1.0d;
|
||||
double d6 = this.M;
|
||||
if (d6 <= 28.0d || d6 >= 152.0d) {
|
||||
double d7 = this.M;
|
||||
double d8 = this.N;
|
||||
if (d7 == d8) {
|
||||
this.M = d8;
|
||||
} else if (d7 < 0.0d) {
|
||||
this.M = 360.0d;
|
||||
}
|
||||
} else {
|
||||
this.M = 152.0d;
|
||||
}
|
||||
this.I.setAlpha(255);
|
||||
if (Math.round(this.M) == 152.0f) {
|
||||
this.J.setAlpha(60);
|
||||
} else {
|
||||
this.J.setAlpha(255);
|
||||
}
|
||||
double a5 = a(this.M);
|
||||
this.W = ((int) a5) + "°";
|
||||
float[] a6 = a((float) this.M);
|
||||
RectF rectF2 = this.r;
|
||||
float f14 = a6[0];
|
||||
float f15 = this.h;
|
||||
rectF2.set(f14 - (f15 / 2.0f), a6[1] - (f15 / 2.0f), a6[0] + (f15 / 2.0f), a6[1] + (f15 / 2.0f));
|
||||
invalidate();
|
||||
AngleUpdateListener angleUpdateListener4 = this.c0;
|
||||
if (angleUpdateListener4 != null) {
|
||||
angleUpdateListener4.c(a5);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
float centerX6 = this.v.centerX();
|
||||
float centerY6 = this.v.centerY();
|
||||
float f16 = this.a;
|
||||
float f17 = this.b0;
|
||||
if (x2 >= (centerX6 - (f16 / 2.0f)) - f17 && x2 <= centerX6 + (f16 / 2.0f) + f17) {
|
||||
float f18 = this.b;
|
||||
if (y2 >= (centerY6 - (f18 / 2.0f)) - f17 && y2 <= centerY6 + (f18 / 2.0f) + f17) {
|
||||
this.d0 = true;
|
||||
this.G = true;
|
||||
this.N -= 1.0d;
|
||||
double d9 = this.N;
|
||||
double d10 = this.M;
|
||||
if (d9 == d10) {
|
||||
this.N = d10;
|
||||
} else if (d9 > 28.0d && d9 <= 152.0d) {
|
||||
this.N = 152.0d;
|
||||
} else if (this.N < 0.0d) {
|
||||
this.N = 360.0d;
|
||||
}
|
||||
b();
|
||||
if (this.N == 28.0d) {
|
||||
this.K.setAlpha(60);
|
||||
} else {
|
||||
this.K.setAlpha(255);
|
||||
}
|
||||
double a7 = a(this.N);
|
||||
this.a0 = ((int) a7) + "°";
|
||||
float[] a8 = a((float) this.N);
|
||||
RectF rectF3 = this.s;
|
||||
float f19 = a8[0];
|
||||
float f20 = this.h;
|
||||
rectF3.set(f19 - (f20 / 2.0f), a8[1] - (f20 / 2.0f), a8[0] + (f20 / 2.0f), a8[1] + (f20 / 2.0f));
|
||||
invalidate();
|
||||
AngleUpdateListener angleUpdateListener5 = this.c0;
|
||||
if (angleUpdateListener5 != null) {
|
||||
angleUpdateListener5.a(a7);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
float centerX7 = this.t.centerX();
|
||||
float centerY7 = this.t.centerY();
|
||||
float f21 = this.a;
|
||||
float f22 = this.b0;
|
||||
if (x2 >= (centerX7 - (f21 / 2.0f)) - f22 && x2 <= centerX7 + (f21 / 2.0f) + f22) {
|
||||
float f23 = this.b;
|
||||
if (y2 >= (centerY7 - (f23 / 2.0f)) - f22 && y2 <= centerY7 + (f23 / 2.0f) + f22) {
|
||||
this.d0 = true;
|
||||
this.G = true;
|
||||
this.N += 1.0d;
|
||||
double d11 = this.N;
|
||||
if (d11 > 360.0d) {
|
||||
this.N = d11 - 360.0d;
|
||||
}
|
||||
double d12 = this.N;
|
||||
if (d12 < 28.0d || d12 >= 152.0d) {
|
||||
double d13 = this.N;
|
||||
double d14 = this.M;
|
||||
if (d13 == d14) {
|
||||
this.N = d14;
|
||||
}
|
||||
} else {
|
||||
this.N = 28.0d;
|
||||
}
|
||||
if (this.N == 28.0d) {
|
||||
this.K.setAlpha(60);
|
||||
i = 255;
|
||||
} else {
|
||||
i = 255;
|
||||
this.K.setAlpha(255);
|
||||
}
|
||||
this.L.setAlpha(i);
|
||||
double a9 = a(this.N);
|
||||
this.a0 = ((int) a9) + "°";
|
||||
float[] a10 = a((float) this.N);
|
||||
RectF rectF4 = this.s;
|
||||
float f24 = a10[0];
|
||||
float f25 = this.h;
|
||||
rectF4.set(f24 - (f25 / 2.0f), a10[1] - (f25 / 2.0f), a10[0] + (f25 / 2.0f), a10[1] + (f25 / 2.0f));
|
||||
invalidate();
|
||||
AngleUpdateListener angleUpdateListener6 = this.c0;
|
||||
if (angleUpdateListener6 != null) {
|
||||
angleUpdateListener6.a(a9);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return super.onTouchEvent(motionEvent);
|
||||
}
|
||||
|
||||
public void setAngleUpdateListener(AngleUpdateListener angleUpdateListener) {
|
||||
this.c0 = angleUpdateListener;
|
||||
}
|
||||
|
||||
public void setCurrentMax(float f) {
|
||||
this.E = f;
|
||||
}
|
||||
|
||||
public void setCurrentMin(float f) {
|
||||
this.D = f;
|
||||
}
|
||||
|
||||
private void b() {
|
||||
double d = this.N;
|
||||
double d2 = this.M;
|
||||
if (d < 90.0d) {
|
||||
d += 360.0d;
|
||||
}
|
||||
if (d2 < 90.0d) {
|
||||
d2 = this.M + 360.0d;
|
||||
}
|
||||
if (d - d2 <= 0.0d) {
|
||||
this.N = this.M;
|
||||
float centerX = this.r.centerX();
|
||||
float centerY = this.r.centerY();
|
||||
RectF rectF = this.s;
|
||||
float f = this.h;
|
||||
rectF.offsetTo(centerX - (f / 2.0f), centerY - (f / 2.0f));
|
||||
this.L.setAlpha(60);
|
||||
return;
|
||||
}
|
||||
this.L.setAlpha(255);
|
||||
}
|
||||
|
||||
private void c(float f, float f2) {
|
||||
if (this.N >= Math.abs(-28.0f)) {
|
||||
double d = this.N;
|
||||
if (d < 152.0d) {
|
||||
if (d < 152.0d && d > 90.0d) {
|
||||
float sin = (float) ((this.g / 2.0f) * Math.sin((Math.abs(-28.0f) * 3.141592653589793d) / 180.0d));
|
||||
float cos = (float) ((this.g / 2.0f) * Math.cos((Math.abs(-28.0f) * 3.141592653589793d) / 180.0d));
|
||||
RectF rectF = this.s;
|
||||
float f3 = f - cos;
|
||||
float f4 = this.F;
|
||||
rectF.offsetTo(f3 - (f4 / 2.0f), (f2 + sin) - (f4 / 2.0f));
|
||||
this.N = 152.0d;
|
||||
return;
|
||||
}
|
||||
float sin2 = (float) ((this.g / 2.0f) * Math.sin((Math.abs(-28.0f) * 3.141592653589793d) / 180.0d));
|
||||
float cos2 = (float) ((this.g / 2.0f) * Math.cos((Math.abs(-28.0f) * 3.141592653589793d) / 180.0d));
|
||||
RectF rectF2 = this.s;
|
||||
float f5 = f + cos2;
|
||||
float f6 = this.F;
|
||||
rectF2.offsetTo(f5 - (f6 / 2.0f), (f2 + sin2) - (f6 / 2.0f));
|
||||
this.N = 28.0d;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public AngleSetView(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
this.h = 150.0f;
|
||||
this.i = 0.0f;
|
||||
this.j = 0.0f;
|
||||
this.S = -118.0f;
|
||||
this.T = 118.0f;
|
||||
this.U = -118.0f;
|
||||
this.V = 118.0f;
|
||||
this.d0 = false;
|
||||
this.y = context;
|
||||
a();
|
||||
}
|
||||
|
||||
public void a() {
|
||||
this.W = ((int) this.S) + "°";
|
||||
this.a0 = ((int) this.T) + "°";
|
||||
this.b0 = this.y.getResources().getDimension(R.dimen.arrow_down_offset);
|
||||
this.a = this.y.getResources().getDimension(R.dimen.arrow_width);
|
||||
this.b = this.y.getResources().getDimension(R.dimen.arrow_height);
|
||||
this.c = this.y.getResources().getDimension(R.dimen.arrow_sides_x);
|
||||
this.d = this.y.getResources().getDimension(R.dimen.arrow_sides_y);
|
||||
this.e = this.y.getResources().getDimension(R.dimen.arrow_sides_down_y);
|
||||
this.f = this.y.getResources().getDimension(R.dimen.angle_text_margin_top);
|
||||
this.F = this.y.getResources().getDimension(R.dimen.angle_set_progress_width);
|
||||
float dimension = this.y.getResources().getDimension(R.dimen.angle_set_width);
|
||||
float f = this.F;
|
||||
this.g = dimension - f;
|
||||
this.h = f;
|
||||
Math.toDegrees(Math.asin(this.h / this.g));
|
||||
this.Q = this.y.getResources().getString(R.string.angle_max_txt);
|
||||
this.R = this.y.getResources().getString(R.string.angle_min_txt);
|
||||
LogUtils.c("angleMaxHintText:" + this.Q.length());
|
||||
LogUtils.c("angleMinHintText:" + this.R.length());
|
||||
this.n = new Paint();
|
||||
this.n.setAntiAlias(true);
|
||||
this.n.setColor(this.y.getResources().getColor(R.color.txt_596F80));
|
||||
this.n.setTextSize(this.y.getResources().getDimension(R.dimen.angle_text_size));
|
||||
this.n.setTextAlign(Paint.Align.CENTER);
|
||||
this.o = new Paint();
|
||||
this.o.setAntiAlias(true);
|
||||
this.o.setColor(this.y.getResources().getColor(R.color.txt_596F80));
|
||||
int length = this.Q.length();
|
||||
int length2 = this.R.length();
|
||||
if (length <= 11 && length2 <= 11) {
|
||||
this.o.setTextSize(this.y.getResources().getDimension(R.dimen.angle_text_hint_size));
|
||||
} else {
|
||||
this.o.setTextSize(this.y.getResources().getDimension(R.dimen.angle_text_hint_size_2));
|
||||
}
|
||||
this.o.setTextAlign(Paint.Align.CENTER);
|
||||
this.I = new Paint();
|
||||
this.I.setFlags(3);
|
||||
this.J = new Paint();
|
||||
this.J.setFlags(3);
|
||||
this.K = new Paint();
|
||||
this.K.setFlags(3);
|
||||
this.L = new Paint();
|
||||
this.L.setFlags(3);
|
||||
this.m = new Paint();
|
||||
this.m.setFlags(3);
|
||||
this.H = new Paint();
|
||||
this.H.setColor(-16776961);
|
||||
this.k = new Paint();
|
||||
this.k.setColor(this.y.getResources().getColor(R.color.bg_3396A6B4));
|
||||
this.k.setFlags(3);
|
||||
this.k.setStrokeWidth(this.F);
|
||||
this.k.setStyle(Paint.Style.STROKE);
|
||||
this.k.setStrokeCap(Paint.Cap.ROUND);
|
||||
this.l = new Paint();
|
||||
this.l.setShader(new LinearGradient(0.0f, 0.0f, 500.0f + this.g, 0.0f, new int[]{this.y.getResources().getColor(R.color.bg_0AEEFE), this.y.getResources().getColor(R.color.bg_4AACF5)}, (float[]) null, Shader.TileMode.CLAMP));
|
||||
this.l.setAntiAlias(true);
|
||||
this.l.setStrokeWidth(this.F);
|
||||
this.l.setStyle(Paint.Style.STROKE);
|
||||
this.l.setStrokeCap(Paint.Cap.ROUND);
|
||||
float f2 = this.i;
|
||||
float f3 = this.F;
|
||||
float f4 = this.j;
|
||||
float f5 = this.g;
|
||||
this.p = new RectF((f3 / 2.0f) + f2, (f3 / 2.0f) + f4, f2 + f5 + (f3 / 2.0f), f4 + f5 + (f3 / 2.0f));
|
||||
float f6 = this.i;
|
||||
float f7 = this.F;
|
||||
float f8 = this.j;
|
||||
float f9 = this.g;
|
||||
this.q = new RectF((f7 / 2.0f) + f6, (f7 / 2.0f) + f8, f6 + f9 + (f7 / 2.0f), f8 + f9 + (f7 / 2.0f));
|
||||
this.P = this.p.centerX();
|
||||
this.O = this.p.centerY();
|
||||
float[] a = a(this.S, DataType.MIN);
|
||||
float f10 = a[0];
|
||||
float f11 = a[1];
|
||||
float[] a2 = a(this.T, DataType.MAX);
|
||||
float f12 = a2[0];
|
||||
float f13 = a2[1];
|
||||
float f14 = this.h;
|
||||
this.r = new RectF(f10 - (f14 / 2.0f), f11 - (f14 / 2.0f), f10 + (f14 / 2.0f), f11 + (f14 / 2.0f));
|
||||
float f15 = this.h;
|
||||
this.s = new RectF(f12 - (f15 / 2.0f), f13 - (f15 / 2.0f), f12 + (f15 / 2.0f), f13 + (f15 / 2.0f));
|
||||
float f16 = this.P;
|
||||
float f17 = this.c;
|
||||
float f18 = this.a;
|
||||
float f19 = this.O;
|
||||
float f20 = this.d;
|
||||
float f21 = this.b;
|
||||
this.t = new RectF((f16 + f17) - (f18 / 2.0f), (f19 - f20) - (f21 / 2.0f), f16 + f17 + (f18 / 2.0f), (f19 - f20) + (f21 / 2.0f));
|
||||
float f22 = this.P;
|
||||
float f23 = this.c;
|
||||
float f24 = this.a;
|
||||
float f25 = this.O;
|
||||
float f26 = this.d;
|
||||
float f27 = this.b;
|
||||
this.u = new RectF((f22 - f23) - (f24 / 2.0f), (f25 - f26) - (f27 / 2.0f), (f22 - f23) + (f24 / 2.0f), (f25 - f26) + (f27 / 2.0f));
|
||||
float f28 = this.P;
|
||||
float f29 = this.c;
|
||||
float f30 = this.a;
|
||||
float f31 = this.O;
|
||||
float f32 = this.e;
|
||||
float f33 = this.b;
|
||||
this.v = new RectF((f28 + f29) - (f30 / 2.0f), (f31 + f32) - (f33 / 2.0f), f28 + f29 + (f30 / 2.0f), f31 + f32 + (f33 / 2.0f));
|
||||
float f34 = this.P;
|
||||
float f35 = this.c;
|
||||
float f36 = this.a;
|
||||
float f37 = this.O;
|
||||
float f38 = this.e;
|
||||
float f39 = this.b;
|
||||
this.x = new RectF((f34 - f35) - (f36 / 2.0f), (f37 + f38) - (f39 / 2.0f), (f34 - f35) + (f36 / 2.0f), f37 + f38 + (f39 / 2.0f));
|
||||
this.z = BitmapFactory.decodeResource(this.y.getResources(), R.mipmap.angle_max);
|
||||
this.A = BitmapFactory.decodeResource(this.y.getResources(), R.mipmap.angle_min);
|
||||
this.B = BitmapFactory.decodeResource(this.y.getResources(), R.mipmap.arrow_up);
|
||||
this.C = BitmapFactory.decodeResource(this.y.getResources(), R.mipmap.arrow_down);
|
||||
b(this.S, this.T);
|
||||
}
|
||||
|
||||
private double b(float f, float f2, double d, double d2) {
|
||||
RectF rectF = this.r;
|
||||
float f3 = this.h;
|
||||
float f4 = this.F;
|
||||
rectF.offsetTo((float) ((d - (f3 / 2.0f)) + (f4 / 2.0f)), (float) ((d2 - (f3 / 2.0f)) + (f4 / 2.0f)));
|
||||
float centerX = this.r.centerX();
|
||||
double atan2 = ((Math.atan2(f2 - this.r.centerY(), f - centerX) * 180.0d) / 3.141592653589793d) + 180.0d;
|
||||
if (centerX < f && atan2 < 152.0d) {
|
||||
return 152.0d;
|
||||
}
|
||||
if (centerX <= f || atan2 < 28.0d || atan2 >= 152.0d) {
|
||||
return atan2;
|
||||
}
|
||||
return 28.0d;
|
||||
}
|
||||
|
||||
private float[] a(float f, DataType dataType) {
|
||||
float abs = (((Math.abs(this.U) + Math.abs(this.V)) / 236.0f) * (f - this.U)) + 152.0f;
|
||||
if (dataType == DataType.MIN) {
|
||||
this.M = abs;
|
||||
double d = this.M;
|
||||
if (d > 360.0d) {
|
||||
this.M = d - 360.0d;
|
||||
}
|
||||
} else {
|
||||
this.N = abs;
|
||||
double d2 = this.N;
|
||||
if (d2 > 360.0d) {
|
||||
this.N = d2 - 360.0d;
|
||||
}
|
||||
}
|
||||
if (abs >= 90.0f && abs <= 180.0f) {
|
||||
double radians = Math.toRadians(180.0f - abs);
|
||||
return new float[]{(float) (this.P - (Math.cos(radians) * (this.g / 2.0f))), (float) (this.O + (Math.sin(radians) * (this.g / 2.0f)))};
|
||||
}
|
||||
if (abs > 180.0f && abs <= 270.0f) {
|
||||
double radians2 = Math.toRadians(abs - 180.0f);
|
||||
return new float[]{(float) (this.P - (Math.cos(radians2) * (this.g / 2.0f))), (float) (this.O - (Math.sin(radians2) * (this.g / 2.0f)))};
|
||||
}
|
||||
if (abs > 270.0f && abs <= 360.0f) {
|
||||
double radians3 = Math.toRadians(abs - 270.0f);
|
||||
return new float[]{(float) (this.P + (Math.sin(radians3) * (this.g / 2.0f))), (float) (this.O - (Math.cos(radians3) * (this.g / 2.0f)))};
|
||||
}
|
||||
if (abs >= 360.0f) {
|
||||
double radians4 = Math.toRadians(abs - 360.0f);
|
||||
return new float[]{(float) (this.P + (Math.cos(radians4) * (this.g / 2.0f))), (float) (this.O + (Math.sin(radians4) * (this.g / 2.0f)))};
|
||||
}
|
||||
double radians5 = Math.toRadians(28.0f);
|
||||
double sin = Math.sin(radians5) * (this.g / 2.0f);
|
||||
float cos = (float) (this.P - (Math.cos(radians5) * (this.g / 2.0f)));
|
||||
float f2 = (float) (sin + this.O);
|
||||
this.M = 152.0d;
|
||||
this.N = 28.0d;
|
||||
return new float[]{cos, f2};
|
||||
}
|
||||
|
||||
private float[] a(float f) {
|
||||
if (f >= 90.0f && f <= 180.0f) {
|
||||
double radians = Math.toRadians(180.0f - f);
|
||||
return new float[]{(float) (this.P - (Math.cos(radians) * (this.g / 2.0f))), (float) (this.O + (Math.sin(radians) * (this.g / 2.0f)))};
|
||||
}
|
||||
if (f > 180.0f && f <= 270.0f) {
|
||||
double radians2 = Math.toRadians(f - 180.0f);
|
||||
return new float[]{(float) (this.P - (Math.cos(radians2) * (this.g / 2.0f))), (float) (this.O - (Math.sin(radians2) * (this.g / 2.0f)))};
|
||||
}
|
||||
if (f > 270.0f && f <= 360.0f) {
|
||||
double radians3 = Math.toRadians(f - 270.0f);
|
||||
return new float[]{(float) (this.P + (Math.sin(radians3) * (this.g / 2.0f))), (float) (this.O - (Math.cos(radians3) * (this.g / 2.0f)))};
|
||||
}
|
||||
if (f >= 0.0f && f < 90.0f) {
|
||||
double radians4 = Math.toRadians(f);
|
||||
return new float[]{(float) (this.P + (Math.cos(radians4) * (this.g / 2.0f))), (float) (this.O + (Math.sin(radians4) * (this.g / 2.0f)))};
|
||||
}
|
||||
double radians5 = Math.toRadians(28.0f);
|
||||
double sin = Math.sin(radians5) * (this.g / 2.0f);
|
||||
float cos = (float) (this.P - (Math.cos(radians5) * (this.g / 2.0f)));
|
||||
float f2 = (float) (sin + this.O);
|
||||
this.M = 152.0d;
|
||||
this.N = 28.0d;
|
||||
return new float[]{cos, f2};
|
||||
}
|
||||
|
||||
private double a(double d) {
|
||||
if (Math.round(d) < 152.0f) {
|
||||
d += 360.0d;
|
||||
}
|
||||
return Math.round(((d - 152.0d) * 1.0d) + this.U);
|
||||
}
|
||||
|
||||
private double a(float f, float f2, double d, double d2) {
|
||||
RectF rectF = this.s;
|
||||
float f3 = this.h;
|
||||
float f4 = this.F;
|
||||
rectF.offsetTo((float) ((d - (f3 / 2.0f)) + (f4 / 2.0f)), (float) ((d2 - (f3 / 2.0f)) + (f4 / 2.0f)));
|
||||
float centerX = this.s.centerX();
|
||||
double atan2 = ((Math.atan2(f2 - this.s.centerY(), f - centerX) * 180.0d) / 3.141592653589793d) + 180.0d;
|
||||
if (atan2 < 28.0d || atan2 >= 152.0d || centerX <= f) {
|
||||
return atan2;
|
||||
}
|
||||
return 28.0d;
|
||||
}
|
||||
}
|
||||
166
sources/com/ubt/jimu/controller/component/DeleteView.java
Normal file
166
sources/com/ubt/jimu/controller/component/DeleteView.java
Normal file
@@ -0,0 +1,166 @@
|
||||
package com.ubt.jimu.controller.component;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.controller.util.ScreenUtil;
|
||||
import com.ubt.jimu.controller.view.control.SuperControlView;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class DeleteView extends SuperControlView {
|
||||
private Context B;
|
||||
private float C;
|
||||
private float D;
|
||||
private float E;
|
||||
private RectF F;
|
||||
private RectF G;
|
||||
private Paint H;
|
||||
private Paint I;
|
||||
private Bitmap J;
|
||||
private Bitmap K;
|
||||
private Paint L;
|
||||
private boolean M;
|
||||
private RectF N;
|
||||
private String O;
|
||||
private boolean P;
|
||||
private DeleteViewAnimatorListener Q;
|
||||
|
||||
public interface DeleteViewAnimatorListener {
|
||||
void a();
|
||||
}
|
||||
|
||||
public DeleteView(Context context) {
|
||||
super(context);
|
||||
this.C = 0.0f;
|
||||
this.P = false;
|
||||
this.B = context;
|
||||
j();
|
||||
}
|
||||
|
||||
private void i() {
|
||||
int a = ScreenUtil.a(this.B);
|
||||
this.E = this.B.getResources().getDimension(R.dimen.grid_view_width) * 2.0f;
|
||||
this.D = this.B.getResources().getDimension(R.dimen.grid_view_width) * 2.0f;
|
||||
this.H = new Paint();
|
||||
this.I = new Paint();
|
||||
this.I.setAlpha(190);
|
||||
this.I.setFlags(3);
|
||||
this.H.setAntiAlias(true);
|
||||
this.H.setColor(this.B.getResources().getColor(R.color.color_F6B8D4));
|
||||
this.L = new Paint();
|
||||
this.L.setColor(this.B.getResources().getColor(R.color.bg_aaFFFFFF));
|
||||
this.L.setTextSize(this.B.getResources().getDimension(R.dimen.txt_title_1));
|
||||
this.F = new RectF(this.C, -this.D, a, 0.0f);
|
||||
this.J = BitmapFactory.decodeResource(this.B.getResources(), R.mipmap.recycle_close);
|
||||
this.K = BitmapFactory.decodeResource(this.B.getResources(), R.mipmap.recycle_open);
|
||||
this.F.centerX();
|
||||
this.F.centerY();
|
||||
float f = this.C;
|
||||
float f2 = this.D;
|
||||
this.G = new RectF(f, -f2, f2 + f, 0.0f);
|
||||
this.N = new RectF();
|
||||
}
|
||||
|
||||
private void j() {
|
||||
}
|
||||
|
||||
public void a(String str) {
|
||||
if (this.M) {
|
||||
this.O = str;
|
||||
this.F.set(0.0f, 0.0f, ScreenUtil.a(this.B), this.D);
|
||||
RectF rectF = this.G;
|
||||
float f = this.E;
|
||||
rectF.set(0.0f, 0.0f, f, f);
|
||||
RectF rectF2 = this.N;
|
||||
float f2 = this.E;
|
||||
rectF2.set(f2 / 1.2f, f2 / 3.5f, f2, f2);
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public void f() {
|
||||
if (this.M) {
|
||||
this.F.set(0.0f, 0.0f, ScreenUtil.a(this.B), this.D);
|
||||
RectF rectF = this.G;
|
||||
float f = this.E;
|
||||
rectF.set(0.0f, 0.0f, f, f);
|
||||
}
|
||||
this.N.set(-10.0f, -10.0f, -10.0f, -10.0f);
|
||||
this.O = "";
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public void g() {
|
||||
if (this.M) {
|
||||
f();
|
||||
this.F.set(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
this.G.set(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
invalidate();
|
||||
DeleteViewAnimatorListener deleteViewAnimatorListener = this.Q;
|
||||
if (deleteViewAnimatorListener != null) {
|
||||
deleteViewAnimatorListener.a();
|
||||
}
|
||||
this.M = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.view.control.SuperControlView
|
||||
public RectF getDeleteViewRectF() {
|
||||
return this.F;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.view.control.SuperControlView
|
||||
public float[] getViewCenterXY() {
|
||||
return new float[0];
|
||||
}
|
||||
|
||||
public void h() {
|
||||
if (this.M) {
|
||||
return;
|
||||
}
|
||||
this.F.set(0.0f, 0.0f, ScreenUtil.a(this.B), this.D);
|
||||
RectF rectF = this.G;
|
||||
float f = this.E;
|
||||
rectF.set(0.0f, 0.0f, f, f);
|
||||
invalidate();
|
||||
this.M = true;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.view.control.SuperControlView, android.view.View
|
||||
protected void onDraw(Canvas canvas) {
|
||||
canvas.drawRect(this.F, this.H);
|
||||
if (this.P) {
|
||||
canvas.drawBitmap(this.K, (Rect) null, this.G, this.I);
|
||||
} else {
|
||||
canvas.drawBitmap(this.J, (Rect) null, this.G, this.I);
|
||||
}
|
||||
if (!TextUtils.isEmpty(this.O)) {
|
||||
canvas.drawText(this.O, this.N.centerX(), this.N.centerY(), this.L);
|
||||
}
|
||||
super.onDraw(canvas);
|
||||
}
|
||||
|
||||
public void setDeleteViewAnimatorListener(DeleteViewAnimatorListener deleteViewAnimatorListener) {
|
||||
this.Q = deleteViewAnimatorListener;
|
||||
}
|
||||
|
||||
public void setOverlapState(boolean z) {
|
||||
this.P = z;
|
||||
}
|
||||
|
||||
public DeleteView(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
this.C = 0.0f;
|
||||
this.P = false;
|
||||
this.B = context;
|
||||
j();
|
||||
i();
|
||||
}
|
||||
}
|
||||
350
sources/com/ubt/jimu/controller/component/DragShadowView.java
Normal file
350
sources/com/ubt/jimu/controller/component/DragShadowView.java
Normal file
@@ -0,0 +1,350 @@
|
||||
package com.ubt.jimu.controller.component;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.controller.component.MenuItemView;
|
||||
import com.ubt.jimu.controller.data.widget.ItemBaseData;
|
||||
import com.ubt.jimu.controller.util.SvgUtils;
|
||||
import com.ubt.jimu.utils.ScreenUtil;
|
||||
import com.ubtrobot.log.ALog;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class DragShadowView extends View {
|
||||
private RectF a;
|
||||
private RectF b;
|
||||
private RectF c;
|
||||
private Context d;
|
||||
private Bitmap e;
|
||||
private Bitmap f;
|
||||
private float g;
|
||||
private float h;
|
||||
private float i;
|
||||
private float j;
|
||||
private Paint k;
|
||||
private Paint l;
|
||||
private Paint m;
|
||||
private RectF n;
|
||||
private DeleteView o;
|
||||
private MenuItemView.MenuItemType p;
|
||||
private float q;
|
||||
public int r;
|
||||
public int s;
|
||||
private boolean t;
|
||||
private Bitmap u;
|
||||
private float v;
|
||||
private ItemBaseData x;
|
||||
private DragShadowState y;
|
||||
|
||||
/* renamed from: com.ubt.jimu.controller.component.DragShadowView$1, reason: invalid class name */
|
||||
static /* synthetic */ class AnonymousClass1 {
|
||||
static final /* synthetic */ int[] a = new int[DragShadowState.values().length];
|
||||
|
||||
static {
|
||||
try {
|
||||
a[DragShadowState.DRAG_STATE.ordinal()] = 1;
|
||||
} catch (NoSuchFieldError unused) {
|
||||
}
|
||||
try {
|
||||
a[DragShadowState.OVERLAP_STATE.ordinal()] = 2;
|
||||
} catch (NoSuchFieldError unused2) {
|
||||
}
|
||||
try {
|
||||
a[DragShadowState.DELETE_STATE.ordinal()] = 3;
|
||||
} catch (NoSuchFieldError unused3) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum DragShadowState {
|
||||
NONE_STATE,
|
||||
DRAG_STATE,
|
||||
OVERLAP_STATE,
|
||||
DELETE_STATE
|
||||
}
|
||||
|
||||
public DragShadowView(Context context) {
|
||||
super(context);
|
||||
this.g = 0.0f;
|
||||
this.h = 0.0f;
|
||||
this.i = 0.0f;
|
||||
this.j = 0.0f;
|
||||
this.t = false;
|
||||
this.y = DragShadowState.NONE_STATE;
|
||||
this.d = context;
|
||||
c();
|
||||
}
|
||||
|
||||
private void a(Canvas canvas) {
|
||||
if (!this.t || this.c.width() <= 0.0f) {
|
||||
return;
|
||||
}
|
||||
Bitmap bitmap = this.u;
|
||||
RectF rectF = this.c;
|
||||
float f = rectF.left;
|
||||
float f2 = rectF.bottom;
|
||||
float f3 = this.v;
|
||||
canvas.drawBitmap(bitmap, (Rect) null, new RectF(f, f2 - f3, f3 + f, f2), this.m);
|
||||
canvas.save();
|
||||
RectF rectF2 = this.c;
|
||||
float f4 = rectF2.left;
|
||||
float f5 = this.v;
|
||||
canvas.rotate(90.0f, f4 + (f5 / 2.0f), rectF2.top + (f5 / 2.0f));
|
||||
Bitmap bitmap2 = this.u;
|
||||
RectF rectF3 = this.c;
|
||||
float f6 = rectF3.left;
|
||||
float f7 = rectF3.top;
|
||||
float f8 = this.v;
|
||||
canvas.drawBitmap(bitmap2, (Rect) null, new RectF(f6, f7, f6 + f8, f8 + f7), this.m);
|
||||
canvas.restore();
|
||||
canvas.save();
|
||||
RectF rectF4 = this.c;
|
||||
float f9 = rectF4.right;
|
||||
float f10 = this.v;
|
||||
canvas.rotate(180.0f, f9 - (f10 / 2.0f), rectF4.top + (f10 / 2.0f));
|
||||
Bitmap bitmap3 = this.u;
|
||||
RectF rectF5 = this.c;
|
||||
float f11 = rectF5.right;
|
||||
float f12 = this.v;
|
||||
float f13 = rectF5.top;
|
||||
canvas.drawBitmap(bitmap3, (Rect) null, new RectF(f11 - f12, f13, f11, f12 + f13), this.m);
|
||||
canvas.restore();
|
||||
canvas.save();
|
||||
RectF rectF6 = this.c;
|
||||
float f14 = rectF6.right;
|
||||
float f15 = this.v;
|
||||
canvas.rotate(270.0f, f14 - (f15 / 2.0f), rectF6.bottom - (f15 / 2.0f));
|
||||
Bitmap bitmap4 = this.u;
|
||||
RectF rectF7 = this.c;
|
||||
float f16 = rectF7.right;
|
||||
float f17 = this.v;
|
||||
float f18 = rectF7.bottom;
|
||||
canvas.drawBitmap(bitmap4, (Rect) null, new RectF(f16 - f17, f18 - f17, f16, f18), this.m);
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
private void c() {
|
||||
this.k = new Paint();
|
||||
this.k.setFlags(3);
|
||||
this.l = new Paint();
|
||||
this.l.setFlags(3);
|
||||
this.l.setColor(this.d.getResources().getColor(R.color.color_00C4C9));
|
||||
this.m = new Paint();
|
||||
this.m.setFlags(3);
|
||||
this.u = BitmapFactory.decodeResource(getResources(), R.drawable.ic_adsorb_corner);
|
||||
this.a = new RectF();
|
||||
this.b = new RectF();
|
||||
this.c = new RectF();
|
||||
this.q = this.d.getResources().getDimension(R.dimen.shadow_radian);
|
||||
this.r = ScreenUtil.b(this.d);
|
||||
this.s = ScreenUtil.a(this.d);
|
||||
this.v = getContext().getResources().getDimension(R.dimen.grid_view_width);
|
||||
}
|
||||
|
||||
private RectF getDeleteViewRectF() {
|
||||
return this.n;
|
||||
}
|
||||
|
||||
public DragShadowView b(float f, float f2) {
|
||||
this.i = f;
|
||||
this.j = f2;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DragShadowView d(float f, float f2) {
|
||||
this.g = f;
|
||||
this.h = f2;
|
||||
if (this.p == MenuItemView.MenuItemType.WIDGET_ITEM) {
|
||||
this.i = f;
|
||||
this.j = f2;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public float getBgHeight() {
|
||||
return this.j;
|
||||
}
|
||||
|
||||
public float getBgWidth() {
|
||||
return this.i;
|
||||
}
|
||||
|
||||
public MenuItemView.MenuItemType getMenuItemType() {
|
||||
return this.p;
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
protected void onDraw(Canvas canvas) {
|
||||
if (this.e == null) {
|
||||
super.onDraw(canvas);
|
||||
return;
|
||||
}
|
||||
if (this.p == null) {
|
||||
super.onDraw(canvas);
|
||||
return;
|
||||
}
|
||||
super.onDraw(canvas);
|
||||
RectF rectF = this.b;
|
||||
float f = this.q;
|
||||
canvas.drawRoundRect(rectF, f, f, this.l);
|
||||
a(canvas);
|
||||
if (this.p == MenuItemView.MenuItemType.ACTION_ITEM) {
|
||||
canvas.drawBitmap(this.f, (Rect) null, this.b, this.k);
|
||||
}
|
||||
canvas.drawBitmap(this.e, (Rect) null, this.a, this.k);
|
||||
}
|
||||
|
||||
public void setDragShadowState(DragShadowState dragShadowState) {
|
||||
int color;
|
||||
if (dragShadowState.equals(this.y)) {
|
||||
invalidate();
|
||||
return;
|
||||
}
|
||||
int i = AnonymousClass1.a[dragShadowState.ordinal()];
|
||||
if (i == 1) {
|
||||
color = this.d.getResources().getColor(R.color.bg_9900C4C9);
|
||||
this.t = true;
|
||||
if (this.o != null && this.x != null) {
|
||||
String format = String.format(this.d.getResources().getString(R.string.control_remove_widget_here), b(this.x));
|
||||
this.o.setOverlapState(false);
|
||||
this.o.a(format);
|
||||
}
|
||||
} else if (i == 2) {
|
||||
color = this.d.getResources().getColor(R.color.bg_99B8BEC1);
|
||||
this.t = false;
|
||||
if (this.o != null && this.x != null) {
|
||||
String format2 = String.format(this.d.getResources().getString(R.string.control_remove_widget_here), b(this.x));
|
||||
this.o.setOverlapState(false);
|
||||
this.o.a(format2);
|
||||
}
|
||||
} else if (i != 3) {
|
||||
ALog.a("Not Support set this state", new Object[0]);
|
||||
color = 0;
|
||||
} else {
|
||||
this.t = false;
|
||||
color = this.d.getResources().getColor(R.color.color_FF4979);
|
||||
if (this.o != null && this.x != null) {
|
||||
String format3 = String.format(this.d.getResources().getString(R.string.control_remove_widget), b(this.x));
|
||||
this.o.setOverlapState(true);
|
||||
this.o.a(format3);
|
||||
}
|
||||
}
|
||||
this.l.setColor(color);
|
||||
invalidate();
|
||||
}
|
||||
|
||||
private String b(ItemBaseData itemBaseData) {
|
||||
return itemBaseData != null ? itemBaseData.getWidgetInfo(this.d) : "";
|
||||
}
|
||||
|
||||
public void b() {
|
||||
this.a.set(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
this.b.set(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
this.c.set(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
DeleteView deleteView = this.o;
|
||||
if (deleteView != null) {
|
||||
deleteView.f();
|
||||
}
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public DragShadowView(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
this.g = 0.0f;
|
||||
this.h = 0.0f;
|
||||
this.i = 0.0f;
|
||||
this.j = 0.0f;
|
||||
this.t = false;
|
||||
this.y = DragShadowState.NONE_STATE;
|
||||
this.d = context;
|
||||
c();
|
||||
}
|
||||
|
||||
public float b(float f) {
|
||||
float f2 = this.j;
|
||||
if (f - (f2 / 2.0f) <= 0.0f) {
|
||||
return f2 / 2.0f;
|
||||
}
|
||||
float f3 = (f2 / 2.0f) + f;
|
||||
int i = this.s;
|
||||
return f3 >= ((float) i) ? i - (f2 / 2.0f) : f;
|
||||
}
|
||||
|
||||
public DragShadowView a(MenuItemView.MenuItemType menuItemType) {
|
||||
this.p = menuItemType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DragShadowView a(ItemBaseData itemBaseData) {
|
||||
this.x = itemBaseData;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void c(float f, float f2) {
|
||||
float a = a(f);
|
||||
float b = b(f2);
|
||||
RectF rectF = this.a;
|
||||
float f3 = this.g;
|
||||
float f4 = this.h;
|
||||
rectF.set(a - (f3 / 2.0f), b - (f4 / 2.0f), (f3 / 2.0f) + a, (f4 / 2.0f) + b);
|
||||
RectF rectF2 = this.b;
|
||||
float f5 = this.i;
|
||||
float f6 = this.j;
|
||||
rectF2.set(a - (f5 / 2.0f), b - (f6 / 2.0f), a + (f5 / 2.0f), b + (f6 / 2.0f));
|
||||
}
|
||||
|
||||
public DragShadowView a(int i) {
|
||||
MenuItemView.MenuItemType menuItemType = this.p;
|
||||
if (menuItemType != null) {
|
||||
if (menuItemType == MenuItemView.MenuItemType.WIDGET_ITEM) {
|
||||
this.e = BitmapFactory.decodeResource(this.d.getResources(), i);
|
||||
return this;
|
||||
}
|
||||
this.e = SvgUtils.a(this.d).a(i, (int) this.g, (int) this.h);
|
||||
if (this.p == MenuItemView.MenuItemType.ACTION_ITEM) {
|
||||
this.f = BitmapFactory.decodeResource(this.d.getResources(), R.mipmap.btn_shadow);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
throw new RuntimeException("必须先调用 setMenuItemType() 函数设置item类型");
|
||||
}
|
||||
|
||||
public void a(float f, float f2) {
|
||||
RectF rectF = this.c;
|
||||
float f3 = this.i;
|
||||
float f4 = this.j;
|
||||
rectF.set(f - (f3 / 2.0f), f2 - (f4 / 2.0f), f + (f3 / 2.0f), f2 + (f4 / 2.0f));
|
||||
}
|
||||
|
||||
public boolean a() {
|
||||
RectF deleteViewRectF = getDeleteViewRectF();
|
||||
if (deleteViewRectF == null) {
|
||||
return false;
|
||||
}
|
||||
return RectF.intersects(deleteViewRectF, this.b);
|
||||
}
|
||||
|
||||
public void a(DeleteView deleteView) {
|
||||
this.o = deleteView;
|
||||
if (this.o != null) {
|
||||
this.n = deleteView.getDeleteViewRectF();
|
||||
}
|
||||
}
|
||||
|
||||
public float a(float f) {
|
||||
float f2 = this.i;
|
||||
if (f - (f2 / 2.0f) <= 0.0f) {
|
||||
return f2 / 2.0f;
|
||||
}
|
||||
float f3 = (f2 / 2.0f) + f;
|
||||
int i = this.r;
|
||||
return f3 >= ((float) i) ? i - (f2 / 2.0f) : f;
|
||||
}
|
||||
}
|
||||
79
sources/com/ubt/jimu/controller/component/GridView.java
Normal file
79
sources/com/ubt/jimu/controller/component/GridView.java
Normal file
@@ -0,0 +1,79 @@
|
||||
package com.ubt.jimu.controller.component;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.controller.util.ScreenUtil;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class GridView extends View {
|
||||
private float a;
|
||||
private Context b;
|
||||
private int c;
|
||||
private int d;
|
||||
private float e;
|
||||
private int f;
|
||||
private int g;
|
||||
private Paint h;
|
||||
|
||||
public GridView(Context context) {
|
||||
super(context);
|
||||
this.a = 5.0f;
|
||||
this.b = context;
|
||||
b();
|
||||
a();
|
||||
}
|
||||
|
||||
private void a() {
|
||||
this.c = ScreenUtil.a(this.b);
|
||||
this.d = ScreenUtil.b(this.b);
|
||||
this.e = this.b.getResources().getDimension(R.dimen.grid_view_width);
|
||||
float f = this.d;
|
||||
float f2 = this.e;
|
||||
this.f = (int) (f / f2);
|
||||
this.g = (int) (this.c / f2);
|
||||
Log.e("Test", "mScreenWidth:" + this.c + " mScreenHeight:" + this.d + " rowNum:" + this.f + " lengthwaysNum:" + this.g);
|
||||
this.h = new Paint();
|
||||
this.h.setAntiAlias(true);
|
||||
this.h.setColor(this.b.getResources().getColor(R.color.bg_BCEAFF));
|
||||
this.h.setStrokeWidth(this.a);
|
||||
}
|
||||
|
||||
private void b() {
|
||||
}
|
||||
|
||||
public int getColumnNum() {
|
||||
return this.g;
|
||||
}
|
||||
|
||||
public int getRowNum() {
|
||||
return this.f;
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
protected void onDraw(Canvas canvas) {
|
||||
float f = this.e;
|
||||
float f2 = f;
|
||||
for (int i = 0; i < this.f; i++) {
|
||||
canvas.drawLine(0.0f, f2, this.c, f2, this.h);
|
||||
f2 += this.e;
|
||||
}
|
||||
for (int i2 = 0; i2 < this.g; i2++) {
|
||||
canvas.drawLine(f, 0.0f, f, this.d, this.h);
|
||||
f += this.e;
|
||||
}
|
||||
super.onDraw(canvas);
|
||||
}
|
||||
|
||||
public GridView(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
this.a = 5.0f;
|
||||
this.b = context;
|
||||
b();
|
||||
a();
|
||||
}
|
||||
}
|
||||
338
sources/com/ubt/jimu/controller/component/HSliderView.java
Normal file
338
sources/com/ubt/jimu/controller/component/HSliderView.java
Normal file
@@ -0,0 +1,338 @@
|
||||
package com.ubt.jimu.controller.component;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.controller.data.config.HSliderConfig;
|
||||
import com.ubt.jimu.controller.data.widget.HSliderWidgetData;
|
||||
import com.ubt.jimu.controller.manager.CommandSendManager;
|
||||
import com.ubt.jimu.controller.view.control.ControlTouchEvent;
|
||||
import com.ubt.jimu.controller.view.control.SuperControlView;
|
||||
import com.ubt.jimu.utils.SystemUtils;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class HSliderView extends SuperControlView<HSliderWidgetData> {
|
||||
private Context B;
|
||||
private float C;
|
||||
private float D;
|
||||
private float E;
|
||||
private float F;
|
||||
private float G;
|
||||
private float H;
|
||||
private RectF I;
|
||||
private RectF J;
|
||||
private Paint K;
|
||||
private Bitmap L;
|
||||
private Bitmap M;
|
||||
private float N;
|
||||
private CommandSendManager O;
|
||||
private float P;
|
||||
private float Q;
|
||||
private float R;
|
||||
private float S;
|
||||
|
||||
public HSliderView(Context context, float f, float f2) {
|
||||
super(context);
|
||||
this.C = 0.0f;
|
||||
this.D = 0.0f;
|
||||
System.currentTimeMillis();
|
||||
this.B = context;
|
||||
this.C = f;
|
||||
this.D = f2;
|
||||
g();
|
||||
f();
|
||||
}
|
||||
|
||||
private void a(float f, float f2, float f3) {
|
||||
this.O.a(((this.J.centerX() - f3) / (f2 - f)) * 100.0f * 2.0f);
|
||||
this.O.a((CommandSendManager) getData());
|
||||
}
|
||||
|
||||
private void b(float f, float f2) {
|
||||
this.I.offsetTo(f, f2);
|
||||
this.j.offsetTo(f, f2);
|
||||
this.J.offsetTo(this.I.centerX() - (this.G / 2.0f), this.I.centerY() - (this.G / 2.0f));
|
||||
}
|
||||
|
||||
private void f() {
|
||||
this.L = BitmapFactory.decodeResource(this.B.getResources(), R.mipmap.rectangle_hslider);
|
||||
this.M = BitmapFactory.decodeResource(this.B.getResources(), R.mipmap.slider_ball);
|
||||
this.H = this.L.getWidth() / this.L.getHeight();
|
||||
this.l = this.B.getResources().getDimension(R.dimen.grid_view_width) * 8.0f;
|
||||
this.m = this.l / this.H;
|
||||
float f = this.D;
|
||||
float f2 = this.m;
|
||||
float f3 = f + (f2 / 2.0f);
|
||||
int i = this.s;
|
||||
if (f3 >= i) {
|
||||
this.D = i - (f2 / 2.0f);
|
||||
}
|
||||
float f4 = this.C;
|
||||
float f5 = this.l;
|
||||
if (f4 - (f5 / 2.0f) <= 0.0f) {
|
||||
this.C = f5 / 2.0f;
|
||||
} else {
|
||||
float f6 = f4 + (f5 / 2.0f);
|
||||
int i2 = this.r;
|
||||
if (f6 >= i2) {
|
||||
this.C = i2 - (f5 / 2.0f);
|
||||
}
|
||||
}
|
||||
float f7 = this.m;
|
||||
this.G = f7 / 1.8f;
|
||||
this.E = this.l / 2.0f;
|
||||
this.F = f7 / 2.0f;
|
||||
this.K = new Paint();
|
||||
this.K.setFlags(3);
|
||||
float f8 = this.C;
|
||||
float f9 = this.l;
|
||||
float f10 = this.D;
|
||||
float f11 = this.m;
|
||||
this.I = new RectF(f8 - (f9 / 2.0f), f10 - (f11 / 2.0f), f8 + (f9 / 2.0f), f10 + (f11 / 2.0f));
|
||||
float centerX = this.I.centerX();
|
||||
float centerY = this.I.centerY();
|
||||
float f12 = this.G;
|
||||
this.J = new RectF(centerX - (f12 / 2.0f), centerY - (f12 / 2.0f), centerX + (f12 / 2.0f), centerY + (f12 / 2.0f));
|
||||
this.O = new CommandSendManager();
|
||||
}
|
||||
|
||||
private void g() {
|
||||
}
|
||||
|
||||
private void h() {
|
||||
HSliderWidgetData data;
|
||||
HSliderConfig config;
|
||||
if (!b()) {
|
||||
this.O.b();
|
||||
ControlTouchEvent controlTouchEvent = this.i;
|
||||
if (controlTouchEvent != null) {
|
||||
controlTouchEvent.b((SuperControlView) this);
|
||||
}
|
||||
} else {
|
||||
if (a(this.j)) {
|
||||
if (this.i != null && (data = getData()) != null && (config = data.getConfig()) != null) {
|
||||
this.i.a(this, config.getConfigID());
|
||||
this.i.c((View) this);
|
||||
}
|
||||
invalidate();
|
||||
return;
|
||||
}
|
||||
if (this.i != null) {
|
||||
RectF rectF = this.I;
|
||||
PointF a = a(rectF.left, rectF.top);
|
||||
this.k.offsetTo(a.x, a.y);
|
||||
if (this.i.c((SuperControlView) this)) {
|
||||
this.J.offsetTo(this.o + this.N, this.p);
|
||||
this.I.offsetTo(this.o, this.p);
|
||||
this.j.offsetTo(this.o, this.p);
|
||||
this.b.setColor(this.B.getResources().getColor(this.a));
|
||||
} else {
|
||||
b(a.x, a.y);
|
||||
this.i.a(this, this.I.centerX(), this.I.centerY());
|
||||
}
|
||||
this.i.c((View) this);
|
||||
if (System.currentTimeMillis() - this.t < 350) {
|
||||
this.i.a(this, getData());
|
||||
}
|
||||
}
|
||||
b(false);
|
||||
}
|
||||
float centerX = this.I.centerX();
|
||||
float centerY = this.I.centerY();
|
||||
RectF rectF2 = this.J;
|
||||
float f = centerX + this.N;
|
||||
float f2 = this.G;
|
||||
rectF2.offsetTo(f - (f2 / 2.0f), centerY - (f2 / 2.0f));
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.view.control.SuperControlView
|
||||
public float[] getViewCenterXY() {
|
||||
return new float[]{this.I.centerX(), this.I.centerY()};
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.view.control.SuperControlView, android.view.View
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
canvas.drawBitmap(this.L, (Rect) null, this.I, this.K);
|
||||
canvas.drawBitmap(this.M, (Rect) null, this.J, this.K);
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public boolean onTouchEvent(MotionEvent motionEvent) {
|
||||
int action = motionEvent.getAction();
|
||||
if (action == 0) {
|
||||
this.t = System.currentTimeMillis();
|
||||
this.R = motionEvent.getX();
|
||||
this.S = motionEvent.getY();
|
||||
super.d();
|
||||
this.f = false;
|
||||
if (!b()) {
|
||||
float centerX = this.J.centerX();
|
||||
float centerY = this.J.centerY();
|
||||
float f = this.G;
|
||||
float f2 = centerX - (f / 2.0f);
|
||||
float f3 = centerX + (f / 2.0f);
|
||||
float f4 = centerY - (f / 2.0f);
|
||||
float f5 = centerY + (f / 2.0f);
|
||||
float f6 = this.R;
|
||||
if (f6 >= f2 && f6 <= f3) {
|
||||
float f7 = this.S;
|
||||
if (f7 >= f4 && f7 <= f5) {
|
||||
ControlTouchEvent controlTouchEvent = this.i;
|
||||
if (controlTouchEvent != null) {
|
||||
controlTouchEvent.a((SuperControlView) this);
|
||||
}
|
||||
this.O.a();
|
||||
}
|
||||
}
|
||||
return super.onTouchEvent(motionEvent);
|
||||
}
|
||||
float centerX2 = this.I.centerX();
|
||||
float centerY2 = this.I.centerY();
|
||||
float f8 = this.E;
|
||||
float f9 = centerX2 - f8;
|
||||
float f10 = centerX2 + f8;
|
||||
float f11 = this.F;
|
||||
float f12 = centerY2 - f11;
|
||||
float f13 = centerY2 + f11;
|
||||
float f14 = this.R;
|
||||
if (f14 >= f9 && f14 <= f10) {
|
||||
float f15 = this.S;
|
||||
if (f15 >= f12 && f15 <= f13) {
|
||||
this.P = super.a(f14);
|
||||
this.Q = super.b(this.S);
|
||||
bringToFront();
|
||||
ControlTouchEvent controlTouchEvent2 = this.i;
|
||||
if (controlTouchEvent2 != null) {
|
||||
controlTouchEvent2.a((View) this);
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.onTouchEvent(motionEvent);
|
||||
return true;
|
||||
}
|
||||
if (action == 1) {
|
||||
if (!this.f) {
|
||||
this.f = true;
|
||||
h();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (action != 2) {
|
||||
if (action != 3) {
|
||||
return super.onTouchEvent(motionEvent);
|
||||
}
|
||||
if (!this.f) {
|
||||
this.f = true;
|
||||
h();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (b()) {
|
||||
b(super.a(motionEvent, this.P), super.b(motionEvent, this.Q));
|
||||
if (this.i != null) {
|
||||
float abs = Math.abs(motionEvent.getX() - this.R);
|
||||
float abs2 = Math.abs(motionEvent.getY() - this.S);
|
||||
if (abs <= 10.0f && abs2 <= 10.0f) {
|
||||
return true;
|
||||
}
|
||||
this.i.b((View) this);
|
||||
if (a(this.j)) {
|
||||
this.b.setColor(this.B.getResources().getColor(R.color.color_FF4979));
|
||||
if (!this.n) {
|
||||
SystemUtils.b(this.B);
|
||||
this.n = true;
|
||||
}
|
||||
b(false);
|
||||
if (this.e != null && getData() != null) {
|
||||
String format = String.format(this.B.getResources().getString(R.string.control_remove_widget), getData().getWidgetInfo(this.B));
|
||||
this.e.setOverlapState(true);
|
||||
this.e.a(format);
|
||||
}
|
||||
} else {
|
||||
if (this.e != null && getData() != null) {
|
||||
String format2 = String.format(this.B.getResources().getString(R.string.control_remove_widget_here), getData().getWidgetInfo(this.B));
|
||||
this.e.setOverlapState(false);
|
||||
this.e.a(format2);
|
||||
}
|
||||
RectF rectF = this.I;
|
||||
PointF a = a(rectF.left, rectF.top);
|
||||
this.k.offsetTo(a.x, a.y);
|
||||
if (this.i.c((SuperControlView) this)) {
|
||||
b(false);
|
||||
this.b.setColor(this.B.getResources().getColor(R.color.bg_99B8BEC1));
|
||||
} else {
|
||||
b(true);
|
||||
this.b.setColor(this.B.getResources().getColor(this.a));
|
||||
}
|
||||
this.n = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
float x = motionEvent.getX();
|
||||
float centerX3 = this.I.centerX();
|
||||
float centerY3 = this.I.centerY();
|
||||
float f16 = this.E;
|
||||
float f17 = this.G;
|
||||
float f18 = (centerX3 - f16) + (f17 / 2.0f);
|
||||
float f19 = (centerX3 + f16) - (f17 / 2.0f);
|
||||
if (x < f18) {
|
||||
x = f18;
|
||||
}
|
||||
if (x > f19) {
|
||||
x = f19;
|
||||
}
|
||||
RectF rectF2 = this.J;
|
||||
float f20 = this.G;
|
||||
rectF2.offsetTo(x - (f20 / 2.0f), centerY3 - (f20 / 2.0f));
|
||||
float centerX4 = this.I.centerX();
|
||||
this.N = this.J.centerX() - centerX4;
|
||||
a(f18, f19, centerX4);
|
||||
}
|
||||
invalidate();
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setHSliderViewCommandSendListener(CommandSendManager.HSliderViewCommandSendListener hSliderViewCommandSendListener) {
|
||||
this.O.a(hSliderViewCommandSendListener);
|
||||
}
|
||||
|
||||
public void setStartX(float f) {
|
||||
this.C = f;
|
||||
}
|
||||
|
||||
public void setStartY(float f) {
|
||||
this.D = f;
|
||||
}
|
||||
|
||||
public void setViewHeight(float f) {
|
||||
this.m = f;
|
||||
this.l = f * this.H;
|
||||
this.E = this.l / 2.0f;
|
||||
this.F = this.m / 2.0f;
|
||||
}
|
||||
|
||||
public void setViewWidth(float f) {
|
||||
this.l = f;
|
||||
this.m = f / this.H;
|
||||
this.E = f / 2.0f;
|
||||
this.F = this.m / 2.0f;
|
||||
}
|
||||
|
||||
public boolean a(RectF rectF) {
|
||||
RectF deleteViewRectF = getDeleteViewRectF();
|
||||
if (deleteViewRectF == null) {
|
||||
return false;
|
||||
}
|
||||
return RectF.intersects(deleteViewRectF, rectF);
|
||||
}
|
||||
}
|
||||
108
sources/com/ubt/jimu/controller/component/MenuItemView.java
Normal file
108
sources/com/ubt/jimu/controller/component/MenuItemView.java
Normal file
@@ -0,0 +1,108 @@
|
||||
package com.ubt.jimu.controller.component;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Point;
|
||||
import android.os.Build;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import com.ubt.jimu.controller.view.ItemBaseView;
|
||||
import com.ubtrobot.log.ALog;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class MenuItemView extends ItemBaseView {
|
||||
private boolean d;
|
||||
private MenuItemOnTouchListener e;
|
||||
private float f;
|
||||
private MenuItemType g;
|
||||
|
||||
public interface MenuItemOnTouchListener<T> {
|
||||
void a(T t, MenuItemView menuItemView);
|
||||
|
||||
void b(T t, MenuItemView menuItemView);
|
||||
}
|
||||
|
||||
public enum MenuItemType {
|
||||
ACTION_ADD_ITEM,
|
||||
ACTION_ITEM,
|
||||
WIDGET_ITEM,
|
||||
WIDGET_ADD_ITEM
|
||||
}
|
||||
|
||||
public class MyDragShadowBuilder extends View.DragShadowBuilder {
|
||||
public MyDragShadowBuilder(MenuItemView menuItemView) {
|
||||
}
|
||||
|
||||
@Override // android.view.View.DragShadowBuilder
|
||||
public void onProvideShadowMetrics(Point point, Point point2) {
|
||||
point.set(1, 1);
|
||||
point2.set(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public MenuItemView(Context context) {
|
||||
super(context);
|
||||
a();
|
||||
}
|
||||
|
||||
private void a() {
|
||||
}
|
||||
|
||||
public MenuItemType getMenuItemType() {
|
||||
return this.g;
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public boolean onTouchEvent(MotionEvent motionEvent) {
|
||||
int action = motionEvent.getAction();
|
||||
if (action == 0) {
|
||||
this.f = motionEvent.getX();
|
||||
return true;
|
||||
}
|
||||
if (action == 1) {
|
||||
this.f = 0.0f;
|
||||
this.d = false;
|
||||
MenuItemOnTouchListener menuItemOnTouchListener = this.e;
|
||||
if (menuItemOnTouchListener != null) {
|
||||
menuItemOnTouchListener.b(super.getData(), this);
|
||||
}
|
||||
return super.onTouchEvent(motionEvent);
|
||||
}
|
||||
if (action == 2) {
|
||||
float abs = Math.abs(this.f - motionEvent.getX());
|
||||
if (!this.d) {
|
||||
this.d = true;
|
||||
if (abs > 20.0f) {
|
||||
MenuItemOnTouchListener menuItemOnTouchListener2 = this.e;
|
||||
if (menuItemOnTouchListener2 != null) {
|
||||
menuItemOnTouchListener2.a(super.getData(), this);
|
||||
}
|
||||
ALog.a("DRAG").d("start drag");
|
||||
if (Build.VERSION.SDK_INT >= 24) {
|
||||
startDragAndDrop(null, new MyDragShadowBuilder(this), null, 0);
|
||||
} else {
|
||||
startDrag(null, new MyDragShadowBuilder(this), null, 0);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} else if (action != 3) {
|
||||
return super.onTouchEvent(motionEvent);
|
||||
}
|
||||
this.d = false;
|
||||
return super.onTouchEvent(motionEvent);
|
||||
}
|
||||
|
||||
public void setMenuItemOnTouchListener(MenuItemOnTouchListener menuItemOnTouchListener) {
|
||||
this.e = menuItemOnTouchListener;
|
||||
}
|
||||
|
||||
public void setMenuItemType(MenuItemType menuItemType) {
|
||||
this.g = menuItemType;
|
||||
}
|
||||
|
||||
public MenuItemView(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
a();
|
||||
}
|
||||
}
|
||||
388
sources/com/ubt/jimu/controller/component/SteeringWheelView.java
Normal file
388
sources/com/ubt/jimu/controller/component/SteeringWheelView.java
Normal file
@@ -0,0 +1,388 @@
|
||||
package com.ubt.jimu.controller.component;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.controller.data.config.JockstickConfig;
|
||||
import com.ubt.jimu.controller.data.widget.JockstickData;
|
||||
import com.ubt.jimu.controller.view.control.ControlTouchEvent;
|
||||
import com.ubt.jimu.controller.view.control.OnControllerClickListener;
|
||||
import com.ubt.jimu.controller.view.control.SuperControlView;
|
||||
import com.ubt.jimu.utils.LogUtils;
|
||||
import com.ubt.jimu.utils.SystemUtils;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class SteeringWheelView extends SuperControlView<JockstickData> {
|
||||
private OnSlideListener B;
|
||||
private float C;
|
||||
private float D;
|
||||
private Context E;
|
||||
private int F;
|
||||
private float G;
|
||||
private float H;
|
||||
private float I;
|
||||
private Paint J;
|
||||
private RectF K;
|
||||
private RectF L;
|
||||
private Paint M;
|
||||
private Bitmap N;
|
||||
private Bitmap O;
|
||||
private float P;
|
||||
private long Q;
|
||||
private float R;
|
||||
private float S;
|
||||
private float T;
|
||||
private float U;
|
||||
|
||||
public interface OnSlideListener {
|
||||
void a(float f, float f2, float f3, JockstickData jockstickData);
|
||||
|
||||
void a(JockstickData jockstickData);
|
||||
|
||||
void a(JockstickData jockstickData, SuperControlView.MotionEventState motionEventState);
|
||||
}
|
||||
|
||||
public SteeringWheelView(Context context, float f, float f2) {
|
||||
super(context);
|
||||
this.F = R.color.color_4D00C4C9;
|
||||
this.H = 0.0f;
|
||||
this.I = 0.0f;
|
||||
this.Q = System.currentTimeMillis();
|
||||
this.E = context;
|
||||
this.H = f;
|
||||
this.I = f2;
|
||||
h();
|
||||
g();
|
||||
}
|
||||
|
||||
private void a(SuperControlView.MotionEventState motionEventState) {
|
||||
JockstickConfig config;
|
||||
if (b()) {
|
||||
this.R = 0.0f;
|
||||
this.S = 0.0f;
|
||||
if (a(this.j) && this.i != null && (config = getData().getConfig()) != null) {
|
||||
this.i.a(this, config.getConfigID());
|
||||
}
|
||||
if (this.i != null) {
|
||||
RectF rectF = this.K;
|
||||
PointF a = a(rectF.left, rectF.top);
|
||||
this.k.offsetTo(a.x, a.y);
|
||||
boolean c = this.i.c((SuperControlView) this);
|
||||
Log.e("Test", "isOverlap:" + c);
|
||||
if (c) {
|
||||
b(this.o, this.p);
|
||||
this.b.setColor(this.E.getResources().getColor(this.F));
|
||||
} else {
|
||||
b(a.x, a.y);
|
||||
this.i.a(this, this.K.centerX(), this.K.centerY());
|
||||
}
|
||||
this.i.c((View) this);
|
||||
if (System.currentTimeMillis() - this.t < 350) {
|
||||
this.i.a(this, getData());
|
||||
}
|
||||
}
|
||||
b(false);
|
||||
} else {
|
||||
float centerX = this.K.centerX();
|
||||
float centerY = this.K.centerY();
|
||||
float f = this.G;
|
||||
this.L.offsetTo(centerX - (f / 2.0f), centerY - (f / 2.0f));
|
||||
int state = getState();
|
||||
if (state == 0) {
|
||||
b(motionEventState);
|
||||
} else if (state == 2) {
|
||||
setSelect(true);
|
||||
this.b.setColor(this.E.getResources().getColor(this.F));
|
||||
f();
|
||||
}
|
||||
ControlTouchEvent controlTouchEvent = this.i;
|
||||
if (controlTouchEvent != null) {
|
||||
controlTouchEvent.b((SuperControlView) this);
|
||||
}
|
||||
}
|
||||
invalidate();
|
||||
}
|
||||
|
||||
private void b(SuperControlView.MotionEventState motionEventState) {
|
||||
OnSlideListener onSlideListener = this.B;
|
||||
if (onSlideListener != null) {
|
||||
onSlideListener.a(getData(), motionEventState);
|
||||
}
|
||||
}
|
||||
|
||||
private void c(float f, float f2) {
|
||||
double d;
|
||||
double d2;
|
||||
OnSlideListener onSlideListener;
|
||||
float centerX = this.K.centerX();
|
||||
float centerY = this.K.centerY();
|
||||
double d3 = f - centerX;
|
||||
double d4 = centerY - f2;
|
||||
double sqrt = Math.sqrt((d3 * d3) + (d4 * d4));
|
||||
float f3 = this.P;
|
||||
if (sqrt > f3) {
|
||||
double d5 = ((f3 / sqrt) * d3) + centerX;
|
||||
float f4 = this.G;
|
||||
d = d5 - (f4 / 2.0f);
|
||||
d2 = (((f3 / sqrt) * (f2 - centerY)) + centerY) - (f4 / 2.0f);
|
||||
} else {
|
||||
float f5 = this.G;
|
||||
d = f - (f5 / 2.0f);
|
||||
d2 = f2 - (f5 / 2.0f);
|
||||
}
|
||||
this.L.offsetTo((float) d, (float) d2);
|
||||
if (getState() == 0) {
|
||||
boolean z = Math.abs(d3 - ((double) this.T)) < ((double) getMinXOffset()) || Math.abs(d4 - ((double) this.U)) < ((double) getMinYOffset());
|
||||
if ((System.currentTimeMillis() - this.Q > 200 || z) && (onSlideListener = this.B) != null) {
|
||||
onSlideListener.a((float) d3, (float) d4, this.P, getData());
|
||||
this.Q = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void f() {
|
||||
OnControllerClickListener onControllerClickListener = getOnControllerClickListener();
|
||||
if (onControllerClickListener == null) {
|
||||
return;
|
||||
}
|
||||
onControllerClickListener.a(null, this);
|
||||
}
|
||||
|
||||
private void g() {
|
||||
this.l = this.E.getResources().getDimension(R.dimen.grid_view_width) * 8.0f;
|
||||
this.m = this.l;
|
||||
float f = this.I;
|
||||
float f2 = this.m;
|
||||
float f3 = f + (f2 / 2.0f);
|
||||
int i = this.s;
|
||||
if (f3 >= i) {
|
||||
this.I = i - (f2 / 2.0f);
|
||||
}
|
||||
float f4 = this.H;
|
||||
float f5 = this.m;
|
||||
if (f4 - (f5 / 2.0f) <= 0.0f) {
|
||||
this.H = f5 / 2.0f;
|
||||
} else {
|
||||
float f6 = f4 + (f5 / 2.0f);
|
||||
int i2 = this.r;
|
||||
if (f6 >= i2) {
|
||||
this.H = i2 - (f5 / 2.0f);
|
||||
}
|
||||
}
|
||||
this.G = this.E.getResources().getDimension(R.dimen.wheel_control_ball);
|
||||
this.J = new Paint();
|
||||
this.J.setFlags(3);
|
||||
float f7 = this.H;
|
||||
float f8 = this.l;
|
||||
float f9 = this.I;
|
||||
float f10 = this.m;
|
||||
this.K = new RectF(f7 - (f8 / 2.0f), f9 - (f10 / 2.0f), f7 + (f8 / 2.0f), f9 + (f10 / 2.0f));
|
||||
this.M = new Paint();
|
||||
this.M.setAntiAlias(true);
|
||||
this.M.setFilterBitmap(true);
|
||||
this.N = BitmapFactory.decodeResource(this.E.getResources(), R.mipmap.jockstick);
|
||||
this.O = BitmapFactory.decodeResource(this.E.getResources(), R.mipmap.steering_wheel_thumb);
|
||||
float centerX = this.K.centerX();
|
||||
float centerY = this.K.centerY();
|
||||
float f11 = this.G;
|
||||
this.L = new RectF(centerX - (f11 / 2.0f), centerY - (f11 / 2.0f), centerX + (f11 / 2.0f), centerY + (f11 / 2.0f));
|
||||
this.P = this.l / 2.0f;
|
||||
}
|
||||
|
||||
private float getMinXOffset() {
|
||||
return this.l / 20.0f;
|
||||
}
|
||||
|
||||
private float getMinYOffset() {
|
||||
return this.l / 20.0f;
|
||||
}
|
||||
|
||||
private void h() {
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.view.control.SuperControlView
|
||||
public float[] getViewCenterXY() {
|
||||
return new float[]{this.K.centerX(), this.K.centerY()};
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.view.control.SuperControlView, android.view.View
|
||||
protected void onDraw(Canvas canvas) {
|
||||
if (getState() == 2) {
|
||||
if (c()) {
|
||||
e();
|
||||
} else {
|
||||
a();
|
||||
}
|
||||
}
|
||||
super.onDraw(canvas);
|
||||
canvas.drawBitmap(this.N, (Rect) null, this.K, this.M);
|
||||
canvas.drawBitmap(this.O, (Rect) null, this.L, this.M);
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public boolean onTouchEvent(MotionEvent motionEvent) {
|
||||
OnSlideListener onSlideListener;
|
||||
int action = motionEvent.getAction();
|
||||
if (action == 0) {
|
||||
LogUtils.c("MotionEvent.ACTION_DOWN:");
|
||||
this.t = System.currentTimeMillis();
|
||||
this.C = motionEvent.getX();
|
||||
this.D = motionEvent.getY();
|
||||
super.d();
|
||||
this.f = false;
|
||||
setPressed(true);
|
||||
if (!b()) {
|
||||
float centerX = this.K.centerX();
|
||||
float centerY = this.K.centerY();
|
||||
float f = this.C;
|
||||
float f2 = this.l;
|
||||
if (f >= centerX - (f2 / 2.0f)) {
|
||||
float f3 = this.D;
|
||||
if (f3 >= centerY - (f2 / 2.0f) && f <= centerX + (f2 / 2.0f) && f3 <= centerY + (f2 / 2.0f)) {
|
||||
ControlTouchEvent controlTouchEvent = this.i;
|
||||
if (controlTouchEvent != null) {
|
||||
controlTouchEvent.a((SuperControlView) this);
|
||||
}
|
||||
if (getState() == 0 && (onSlideListener = this.B) != null) {
|
||||
onSlideListener.a(getData());
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.onTouchEvent(motionEvent);
|
||||
}
|
||||
float centerX2 = this.K.centerX();
|
||||
float centerY2 = this.K.centerY();
|
||||
float f4 = this.l;
|
||||
float f5 = centerX2 - (f4 / 2.0f);
|
||||
float f6 = this.m;
|
||||
float f7 = centerY2 - (f6 / 2.0f);
|
||||
float f8 = centerX2 + (f4 / 2.0f);
|
||||
float f9 = centerY2 + (f6 / 2.0f);
|
||||
float f10 = this.C;
|
||||
if (f10 >= f5 && f10 <= f8) {
|
||||
float f11 = this.D;
|
||||
if (f11 >= f7 && f11 <= f9) {
|
||||
this.R = super.a(f10);
|
||||
this.S = super.b(this.D);
|
||||
bringToFront();
|
||||
ControlTouchEvent controlTouchEvent2 = this.i;
|
||||
if (controlTouchEvent2 != null) {
|
||||
controlTouchEvent2.a((View) this);
|
||||
}
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
return super.onTouchEvent(motionEvent);
|
||||
}
|
||||
if (action == 1) {
|
||||
setPressed(false);
|
||||
if (!this.f) {
|
||||
this.f = true;
|
||||
a(SuperControlView.MotionEventState.STATE_UP);
|
||||
LogUtils.c("方向盘:ACTION_UP");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (action != 2) {
|
||||
if (action != 3) {
|
||||
return super.onTouchEvent(motionEvent);
|
||||
}
|
||||
if (!this.f) {
|
||||
LogUtils.c("方向盘:ACTION_CANCEL");
|
||||
this.f = true;
|
||||
a(SuperControlView.MotionEventState.STATE_CANCEL);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
setPressed(true);
|
||||
this.f = false;
|
||||
LogUtils.c("MotionEvent.ACTION_MOVE:");
|
||||
if (b()) {
|
||||
a(motionEvent);
|
||||
if (this.i != null) {
|
||||
float abs = Math.abs(motionEvent.getX() - this.C);
|
||||
float abs2 = Math.abs(motionEvent.getY() - this.D);
|
||||
if (abs <= 10.0f && abs2 <= 10.0f) {
|
||||
return true;
|
||||
}
|
||||
this.i.b((View) this);
|
||||
if (a(this.j)) {
|
||||
b(false);
|
||||
this.b.setColor(this.E.getResources().getColor(R.color.color_FF4979));
|
||||
if (this.e != null && getData() != null) {
|
||||
this.e.setOverlapState(true);
|
||||
this.e.a(String.format(this.E.getResources().getString(R.string.control_remove_widget), getData().getWidgetInfo(this.E)));
|
||||
}
|
||||
if (!this.n) {
|
||||
SystemUtils.b(this.E);
|
||||
this.n = true;
|
||||
}
|
||||
} else {
|
||||
if (this.e != null && getData() != null) {
|
||||
this.e.setOverlapState(false);
|
||||
this.e.a(String.format(this.E.getResources().getString(R.string.control_remove_widget_here), getData().getWidgetInfo(this.E)));
|
||||
}
|
||||
RectF rectF = this.K;
|
||||
PointF a = a(rectF.left, rectF.top);
|
||||
this.k.offsetTo(a.x, a.y);
|
||||
if (this.i.c((SuperControlView) this)) {
|
||||
b(false);
|
||||
this.b.setColor(this.E.getResources().getColor(R.color.bg_99B8BEC1));
|
||||
} else {
|
||||
b(true);
|
||||
this.b.setColor(this.E.getResources().getColor(this.F));
|
||||
}
|
||||
this.n = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
c(motionEvent.getX(), motionEvent.getY());
|
||||
}
|
||||
invalidate();
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setOnSlideListener(OnSlideListener onSlideListener) {
|
||||
this.B = onSlideListener;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.view.control.SuperControlView
|
||||
public void setSelect(boolean z) {
|
||||
super.setSelect(z);
|
||||
}
|
||||
|
||||
public void setSteeringWheelBackgroundStartX(float f) {
|
||||
this.H = f;
|
||||
}
|
||||
|
||||
public void setSteeringWheelBackgroundStartY(float f) {
|
||||
this.I = f;
|
||||
}
|
||||
|
||||
private void b(float f, float f2) {
|
||||
this.K.offsetTo(f, f2);
|
||||
this.j.offsetTo(f, f2);
|
||||
this.L.offsetTo(this.K.centerX() - (this.G / 2.0f), this.K.centerY() - (this.G / 2.0f));
|
||||
}
|
||||
|
||||
private void a(MotionEvent motionEvent) {
|
||||
b(super.a(motionEvent, this.R), super.b(motionEvent, this.S));
|
||||
}
|
||||
|
||||
public boolean a(RectF rectF) {
|
||||
RectF deleteViewRectF = getDeleteViewRectF();
|
||||
if (deleteViewRectF == null) {
|
||||
return false;
|
||||
}
|
||||
return RectF.intersects(deleteViewRectF, rectF);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,818 @@
|
||||
package com.ubt.jimu.controller.component;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.LinearGradient;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.Shader;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.utils.BitmapUtils;
|
||||
import com.ubt.jimu.utils.LogUtils;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class TensionAngleSetView extends View {
|
||||
private RectF A;
|
||||
private RectF B;
|
||||
private RectF C;
|
||||
private Context D;
|
||||
private Bitmap E;
|
||||
private Bitmap F;
|
||||
private Bitmap G;
|
||||
private Bitmap H;
|
||||
private float I;
|
||||
private float J;
|
||||
private float K;
|
||||
private boolean L;
|
||||
private Paint M;
|
||||
private double N;
|
||||
private double O;
|
||||
private float P;
|
||||
private float Q;
|
||||
private String R;
|
||||
private String S;
|
||||
private float T;
|
||||
private float U;
|
||||
private String V;
|
||||
private String W;
|
||||
private float a;
|
||||
private float a0;
|
||||
private float b;
|
||||
private Matrix b0;
|
||||
private float c;
|
||||
private float c0;
|
||||
private float d;
|
||||
private boolean d0;
|
||||
private float e;
|
||||
private AngleUpdateListener e0;
|
||||
private float f;
|
||||
private float g;
|
||||
private float h;
|
||||
private float i;
|
||||
private float j;
|
||||
private float k;
|
||||
private Paint l;
|
||||
private Paint m;
|
||||
private Paint n;
|
||||
private Paint o;
|
||||
private Paint p;
|
||||
private Paint q;
|
||||
private Paint r;
|
||||
private Paint s;
|
||||
private Paint t;
|
||||
private RectF u;
|
||||
private RectF v;
|
||||
private RectF x;
|
||||
private RectF y;
|
||||
private RectF z;
|
||||
|
||||
public interface AngleUpdateListener {
|
||||
void b(double d);
|
||||
|
||||
void d(double d);
|
||||
}
|
||||
|
||||
enum DataType {
|
||||
START,
|
||||
LAUNCH
|
||||
}
|
||||
|
||||
public TensionAngleSetView(Context context) {
|
||||
super(context);
|
||||
this.j = 0.0f;
|
||||
this.k = 0.0f;
|
||||
this.T = -118.0f;
|
||||
this.U = 118.0f;
|
||||
this.D = context;
|
||||
a();
|
||||
}
|
||||
|
||||
private float[] b(float f) {
|
||||
this.O = 388.0f - (((Math.abs(118.0f) + Math.abs(-118.0f)) / 236.0f) * (118.0f - f));
|
||||
double d = this.O;
|
||||
if (d >= 360.0d) {
|
||||
double radians = Math.toRadians((float) (d - 360.0d));
|
||||
return new float[]{(float) (this.Q + (Math.cos(radians) * (this.g / 2.0f))), (float) (this.P + (Math.sin(radians) * (this.g / 2.0f)))};
|
||||
}
|
||||
if (d >= 270.0d && d < 360.0d) {
|
||||
float f2 = (float) (360.0d - d);
|
||||
LogUtils.c("cosAnglecosAngle:" + f2);
|
||||
double radians2 = Math.toRadians((double) f2);
|
||||
return new float[]{(float) (this.Q + (Math.cos(radians2) * (this.g / 2.0f))), (float) (this.P - (Math.sin(radians2) * ((double) (this.g / 2.0f))))};
|
||||
}
|
||||
double d2 = this.O;
|
||||
if (d2 < 270.0d && d2 >= 180.0d) {
|
||||
double radians3 = Math.toRadians((float) (d2 - 180.0d));
|
||||
return new float[]{(float) (this.Q - (Math.cos(radians3) * (this.g / 2.0f))), (float) (this.P - (Math.sin(radians3) * (this.g / 2.0f)))};
|
||||
}
|
||||
double d3 = this.O;
|
||||
if (d3 >= 180.0d || d3 <= 90.0d) {
|
||||
return null;
|
||||
}
|
||||
double radians4 = Math.toRadians((float) (180.0d - d3));
|
||||
return new float[]{(float) (this.Q - (Math.cos(radians4) * (this.g / 2.0f))), (float) (this.P + (Math.sin(radians4) * (this.g / 2.0f)))};
|
||||
}
|
||||
|
||||
private float[] c(float f, float f2) {
|
||||
float b = b(f, f2);
|
||||
if (b < -28.0f) {
|
||||
b = -28.0f;
|
||||
} else if (b >= 208.0f) {
|
||||
b = 208.0f;
|
||||
}
|
||||
double radians = Math.toRadians(b);
|
||||
double sin = Math.sin(radians);
|
||||
double cos = Math.cos(radians);
|
||||
float f3 = this.g;
|
||||
return new float[]{(float) (this.u.centerX() + ((f3 / 2.0f) * cos)), (float) (this.u.centerY() - ((f3 / 2.0f) * sin))};
|
||||
}
|
||||
|
||||
private double d(float f, float f2) {
|
||||
float centerX = this.y.centerX();
|
||||
double atan2 = ((Math.atan2(f2 - this.y.centerY(), f - centerX) * 180.0d) / 3.141592653589793d) + 180.0d;
|
||||
if (atan2 < 28.0d || atan2 >= 152.0d || centerX <= f) {
|
||||
return atan2;
|
||||
}
|
||||
return 28.0d;
|
||||
}
|
||||
|
||||
private void setAngle(float f) {
|
||||
this.b0.reset();
|
||||
float centerX = this.x.centerX();
|
||||
float centerY = this.x.centerY();
|
||||
this.b0.setTranslate(centerX - (this.F.getWidth() / 2.0f), centerY - (this.F.getHeight() / 2.0f));
|
||||
this.b0.postRotate(-f, centerX, centerY);
|
||||
}
|
||||
|
||||
public void a(float f, float f2) {
|
||||
if (this.T == f) {
|
||||
this.r.setAlpha(60);
|
||||
} else {
|
||||
this.r.setAlpha(255);
|
||||
}
|
||||
if (this.U == f2) {
|
||||
this.s.setAlpha(60);
|
||||
} else {
|
||||
this.s.setAlpha(255);
|
||||
}
|
||||
this.T = f;
|
||||
this.U = f2;
|
||||
this.V = ((int) f) + "°";
|
||||
this.W = ((int) f2) + "°";
|
||||
float[] a = a(f, DataType.START);
|
||||
float[] b = b(f2);
|
||||
RectF rectF = this.x;
|
||||
if (rectF != null && b != null) {
|
||||
float f3 = b[0];
|
||||
float f4 = this.i;
|
||||
rectF.set(f3 - (f4 / 2.0f), b[1] - (f4 / 2.0f), b[0] + (f4 / 2.0f), b[1] + (f4 / 2.0f));
|
||||
}
|
||||
RectF rectF2 = this.y;
|
||||
if (rectF2 != null) {
|
||||
float f5 = a[0];
|
||||
float f6 = this.h;
|
||||
rectF2.set(f5 - (f6 / 2.0f), a[1] - (f6 / 2.0f), a[0] + (f6 / 2.0f), a[1] + (f6 / 2.0f));
|
||||
}
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public float getCurrentMax() {
|
||||
return this.J;
|
||||
}
|
||||
|
||||
public float getCurrentMin() {
|
||||
return this.I;
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
protected void onDraw(Canvas canvas) {
|
||||
canvas.drawArc(this.u, 152.0f, 236.0f, false, this.l);
|
||||
double d = this.O;
|
||||
double d2 = this.N;
|
||||
double d3 = 0.0d;
|
||||
if (d == d2) {
|
||||
d3 = 0.11d;
|
||||
setAngle(a(false));
|
||||
} else if (d2 >= 90.0d || d < 360.0d || d - 360.0d < d2) {
|
||||
double d4 = this.N;
|
||||
if (d4 < 90.0d) {
|
||||
double d5 = this.O;
|
||||
if (d5 <= 360.0d) {
|
||||
d3 = (360.0d - d5) + d4;
|
||||
setAngle(a(true));
|
||||
d2 = d5;
|
||||
}
|
||||
}
|
||||
double d6 = this.O;
|
||||
if (d6 >= 360.0d) {
|
||||
double d7 = this.N;
|
||||
if (d7 < 90.0d && d6 - 360.0d <= d7) {
|
||||
setAngle(a(true));
|
||||
d2 = d6 - 360.0d;
|
||||
d3 = d7 - (d6 - 360.0d);
|
||||
}
|
||||
}
|
||||
double d8 = this.N;
|
||||
if (d8 > 90.0d && d8 <= 360.0d) {
|
||||
double d9 = this.O;
|
||||
if (d9 > 90.0d && d8 < d9) {
|
||||
d3 = d9 - d8;
|
||||
setAngle(a(false));
|
||||
d2 = d8;
|
||||
}
|
||||
}
|
||||
double d10 = this.N;
|
||||
double d11 = this.O;
|
||||
if (d10 <= d11 || d10 <= 90.0d || d11 <= 90.0d) {
|
||||
d2 = 0.0d;
|
||||
} else {
|
||||
d3 = d10 - d11;
|
||||
setAngle(a(true));
|
||||
d2 = d11;
|
||||
}
|
||||
} else {
|
||||
d3 = (d - 360.0d) - d2;
|
||||
setAngle(a(false));
|
||||
}
|
||||
canvas.drawArc(this.v, (float) d2, (float) d3, false, this.m);
|
||||
LogUtils.c("isOnClickStartIcon:" + this.L);
|
||||
if (this.L) {
|
||||
canvas.drawBitmap(this.F, this.b0, this.n);
|
||||
canvas.drawBitmap(this.E, (Rect) null, this.y, this.n);
|
||||
} else {
|
||||
canvas.drawBitmap(this.E, (Rect) null, this.y, this.n);
|
||||
canvas.drawBitmap(this.F, this.b0, this.n);
|
||||
}
|
||||
canvas.drawBitmap(this.G, (Rect) null, this.z, this.s);
|
||||
canvas.drawBitmap(this.G, (Rect) null, this.A, this.q);
|
||||
canvas.drawBitmap(this.H, (Rect) null, this.B, this.t);
|
||||
canvas.drawBitmap(this.H, (Rect) null, this.C, this.r);
|
||||
canvas.drawText(this.V, this.A.centerX(), this.P - this.f, this.o);
|
||||
canvas.drawText(this.W, this.z.centerX(), this.P - this.f, this.o);
|
||||
canvas.drawText(this.R, this.z.centerX(), this.P + this.f, this.p);
|
||||
canvas.drawText(this.S, this.A.centerX(), this.P + this.f, this.p);
|
||||
super.onDraw(canvas);
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
protected void onMeasure(int i, int i2) {
|
||||
int makeMeasureSpec = View.MeasureSpec.makeMeasureSpec((int) this.c0, 1073741824);
|
||||
super.onMeasure(makeMeasureSpec, makeMeasureSpec);
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public boolean onTouchEvent(MotionEvent motionEvent) {
|
||||
int action = motionEvent.getAction();
|
||||
if (action != 0) {
|
||||
if (action == 2) {
|
||||
float x = motionEvent.getX();
|
||||
float y = motionEvent.getY();
|
||||
float centerX = this.u.centerX();
|
||||
float centerY = this.u.centerY();
|
||||
if (!this.L) {
|
||||
this.x.centerX();
|
||||
this.x.centerY();
|
||||
if (this.d0) {
|
||||
LogUtils.c("按下微调箭头,不响应滑动计算事件");
|
||||
return super.onTouchEvent(motionEvent);
|
||||
}
|
||||
float[] c = c(x, y);
|
||||
RectF rectF = this.x;
|
||||
float f = c[0];
|
||||
float f2 = this.i;
|
||||
rectF.offsetTo(f - (f2 / 2.0f), c[1] - (f2 / 2.0f));
|
||||
this.O = 360.0f - b(x, y);
|
||||
if (Math.round(this.O) == 152.0f) {
|
||||
this.t.setAlpha(60);
|
||||
} else {
|
||||
this.t.setAlpha(255);
|
||||
}
|
||||
if (Math.round(this.O) == 388.0f) {
|
||||
this.s.setAlpha(60);
|
||||
} else {
|
||||
this.s.setAlpha(255);
|
||||
}
|
||||
double a = a(this.O);
|
||||
this.W = ((int) a) + "°";
|
||||
AngleUpdateListener angleUpdateListener = this.e0;
|
||||
if (angleUpdateListener != null) {
|
||||
angleUpdateListener.d(a);
|
||||
}
|
||||
} else {
|
||||
if (this.d0) {
|
||||
LogUtils.c("按下微调箭头,不响应滑动计算事件");
|
||||
return super.onTouchEvent(motionEvent);
|
||||
}
|
||||
float[] c2 = c(x, y);
|
||||
RectF rectF2 = this.y;
|
||||
float f3 = c2[0];
|
||||
float f4 = this.h;
|
||||
rectF2.offsetTo(f3 - (f4 / 2.0f), c2[1] - (f4 / 2.0f));
|
||||
this.N = d(centerX, centerY);
|
||||
double a2 = a(this.N);
|
||||
if (Math.round(this.N) == 28.0f) {
|
||||
this.q.setAlpha(60);
|
||||
} else {
|
||||
this.q.setAlpha(255);
|
||||
}
|
||||
if (Math.round(this.N) == 152.0f) {
|
||||
this.r.setAlpha(60);
|
||||
} else {
|
||||
this.r.setAlpha(255);
|
||||
}
|
||||
this.V = ((int) a2) + "°";
|
||||
AngleUpdateListener angleUpdateListener2 = this.e0;
|
||||
if (angleUpdateListener2 != null) {
|
||||
angleUpdateListener2.b(a2);
|
||||
}
|
||||
}
|
||||
invalidate();
|
||||
}
|
||||
return super.onTouchEvent(motionEvent);
|
||||
}
|
||||
float x2 = motionEvent.getX();
|
||||
float y2 = motionEvent.getY();
|
||||
float centerX2 = this.x.centerX();
|
||||
float centerY2 = this.x.centerY();
|
||||
float centerX3 = this.y.centerX();
|
||||
float centerY3 = this.y.centerY();
|
||||
this.d0 = false;
|
||||
if (this.L) {
|
||||
float f5 = this.h;
|
||||
if (x2 >= centerX3 - (f5 / 2.0f) && x2 <= centerX3 + (f5 / 2.0f) && y2 >= centerY3 - (f5 / 2.0f) && y2 <= centerY3 + (f5 / 2.0f)) {
|
||||
this.L = true;
|
||||
return true;
|
||||
}
|
||||
float f6 = this.i;
|
||||
if (x2 >= centerX2 - (f6 / 2.0f) && x2 <= centerX2 + (f6 / 2.0f) && y2 >= centerY2 - (f6 / 2.0f) && y2 <= centerY2 + (f6 / 2.0f)) {
|
||||
this.L = false;
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
float f7 = this.i;
|
||||
if (x2 >= centerX2 - (f7 / 2.0f) && x2 <= centerX2 + (f7 / 2.0f) && y2 >= centerY2 - (f7 / 2.0f) && y2 <= centerY2 + (f7 / 2.0f)) {
|
||||
this.L = false;
|
||||
return true;
|
||||
}
|
||||
float f8 = this.h;
|
||||
if (x2 >= centerX3 - (f8 / 2.0f) && x2 <= centerX3 + (f8 / 2.0f) && y2 >= centerY3 - (f8 / 2.0f) && y2 <= centerY3 + (f8 / 2.0f)) {
|
||||
this.L = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
float centerX4 = this.A.centerX();
|
||||
float centerY4 = this.A.centerY();
|
||||
float f9 = this.a;
|
||||
float f10 = this.a0;
|
||||
if (x2 >= (centerX4 - (f9 / 2.0f)) - f10 && x2 <= centerX4 + (f9 / 2.0f) + f10) {
|
||||
float f11 = this.b;
|
||||
if (y2 >= (centerY4 - (f11 / 2.0f)) - f10 && y2 <= centerY4 + (f11 / 2.0f) + f10) {
|
||||
this.L = false;
|
||||
this.d0 = true;
|
||||
this.N += 1.0d;
|
||||
double d = this.N;
|
||||
if (d < 28.0d || d >= 152.0d) {
|
||||
double d2 = this.N;
|
||||
double d3 = this.O;
|
||||
if (d2 == d3) {
|
||||
this.N = d3;
|
||||
} else if (d2 < 0.0d) {
|
||||
this.N = 360.0d;
|
||||
} else if (d2 > 360.0d) {
|
||||
this.N = d2 - 360.0d;
|
||||
}
|
||||
} else {
|
||||
this.N = 28.0d;
|
||||
}
|
||||
double a3 = a(this.N);
|
||||
this.V = ((int) a3) + "°";
|
||||
float[] a4 = a((float) this.N);
|
||||
RectF rectF3 = this.y;
|
||||
float f12 = a4[0];
|
||||
float f13 = this.h;
|
||||
rectF3.set(f12 - (f13 / 2.0f), a4[1] - (f13 / 2.0f), a4[0] + (f13 / 2.0f), a4[1] + (f13 / 2.0f));
|
||||
if (a3 >= 118.0d) {
|
||||
this.q.setAlpha(60);
|
||||
} else {
|
||||
this.q.setAlpha(255);
|
||||
}
|
||||
this.r.setAlpha(225);
|
||||
invalidate();
|
||||
AngleUpdateListener angleUpdateListener3 = this.e0;
|
||||
if (angleUpdateListener3 != null) {
|
||||
angleUpdateListener3.b(a3);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
float centerX5 = this.C.centerX();
|
||||
float centerY5 = this.C.centerY();
|
||||
float f14 = this.a;
|
||||
float f15 = this.a0;
|
||||
if (x2 >= (centerX5 - (f14 / 2.0f)) - f15 && x2 <= centerX5 + (f14 / 2.0f) + f15) {
|
||||
float f16 = this.b;
|
||||
if (y2 >= (centerY5 - (f16 / 2.0f)) - f15 && y2 <= centerY5 + (f16 / 2.0f) + f15) {
|
||||
this.L = false;
|
||||
this.d0 = true;
|
||||
this.N -= 1.0d;
|
||||
double d4 = this.N;
|
||||
if (d4 <= 28.0d || d4 >= 152.0d) {
|
||||
double d5 = this.N;
|
||||
double d6 = this.O;
|
||||
if (d5 == d6) {
|
||||
this.N = d6;
|
||||
} else if (d5 < 0.0d) {
|
||||
this.N = 360.0d;
|
||||
}
|
||||
} else {
|
||||
this.N = 152.0d;
|
||||
}
|
||||
double a5 = a(this.N);
|
||||
this.V = ((int) a5) + "°";
|
||||
float[] a6 = a((float) this.N);
|
||||
RectF rectF4 = this.y;
|
||||
float f17 = a6[0];
|
||||
float f18 = this.h;
|
||||
rectF4.set(f17 - (f18 / 2.0f), a6[1] - (f18 / 2.0f), a6[0] + (f18 / 2.0f), a6[1] + (f18 / 2.0f));
|
||||
if (a5 <= this.T) {
|
||||
this.r.setAlpha(60);
|
||||
} else {
|
||||
this.r.setAlpha(225);
|
||||
}
|
||||
this.q.setAlpha(255);
|
||||
invalidate();
|
||||
AngleUpdateListener angleUpdateListener4 = this.e0;
|
||||
if (angleUpdateListener4 != null) {
|
||||
angleUpdateListener4.b(a5);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
float centerX6 = this.B.centerX();
|
||||
float centerY6 = this.B.centerY();
|
||||
float f19 = this.a;
|
||||
float f20 = this.a0;
|
||||
if (x2 >= (centerX6 - (f19 / 2.0f)) - f20 && x2 <= centerX6 + (f19 / 2.0f) + f20) {
|
||||
float f21 = this.b;
|
||||
if (y2 >= (centerY6 - (f21 / 2.0f)) - f20 && y2 <= centerY6 + (f21 / 2.0f) + f20) {
|
||||
this.L = true;
|
||||
this.d0 = true;
|
||||
this.O -= 1.0d;
|
||||
double d7 = this.O;
|
||||
double d8 = this.N;
|
||||
if (d7 == d8) {
|
||||
this.O = d8;
|
||||
} else if (d7 > 28.0d && d7 <= 152.0d) {
|
||||
this.O = 152.0d;
|
||||
} else if (this.O < 0.0d) {
|
||||
this.O = 360.0d;
|
||||
}
|
||||
Log.e("Test", "最小值角度+1 progressEndAngle-Down" + this.O + " 28.0 152.0");
|
||||
double a7 = a(this.O);
|
||||
if (a7 <= this.T) {
|
||||
this.t.setAlpha(60);
|
||||
} else {
|
||||
this.t.setAlpha(255);
|
||||
}
|
||||
this.s.setAlpha(225);
|
||||
float[] b = b((float) a7);
|
||||
this.W = ((int) a7) + "°";
|
||||
if (b != null) {
|
||||
RectF rectF5 = this.x;
|
||||
float f22 = b[0];
|
||||
float f23 = this.i;
|
||||
rectF5.set(f22 - (f23 / 2.0f), b[1] - (f23 / 2.0f), b[0] + (f23 / 2.0f), b[1] + (f23 / 2.0f));
|
||||
}
|
||||
invalidate();
|
||||
AngleUpdateListener angleUpdateListener5 = this.e0;
|
||||
if (angleUpdateListener5 != null) {
|
||||
angleUpdateListener5.d(a7);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
float centerX7 = this.z.centerX();
|
||||
float centerY7 = this.z.centerY();
|
||||
float f24 = this.a;
|
||||
float f25 = this.a0;
|
||||
if (x2 >= (centerX7 - (f24 / 2.0f)) - f25 && x2 <= centerX7 + (f24 / 2.0f) + f25) {
|
||||
float f26 = this.b;
|
||||
if (y2 >= (centerY7 - (f26 / 2.0f)) - f25 && y2 <= centerY7 + (f26 / 2.0f) + f25) {
|
||||
this.L = true;
|
||||
this.d0 = true;
|
||||
this.O += 1.0d;
|
||||
double d9 = this.O;
|
||||
if (d9 > 360.0d) {
|
||||
this.O = d9 - 360.0d;
|
||||
}
|
||||
double d10 = this.O;
|
||||
if (d10 < 28.0d || d10 >= 152.0d) {
|
||||
double d11 = this.O;
|
||||
double d12 = this.N;
|
||||
if (d11 == d12) {
|
||||
this.O = d12;
|
||||
}
|
||||
} else {
|
||||
this.O = 28.0d;
|
||||
}
|
||||
double a8 = a(this.O);
|
||||
if (a8 >= 118.0d) {
|
||||
this.s.setAlpha(60);
|
||||
} else {
|
||||
this.s.setAlpha(255);
|
||||
}
|
||||
this.t.setAlpha(225);
|
||||
float[] b2 = b((float) a8);
|
||||
this.W = ((int) a8) + "°";
|
||||
if (b2 != null) {
|
||||
RectF rectF6 = this.x;
|
||||
float f27 = b2[0];
|
||||
float f28 = this.i;
|
||||
rectF6.set(f27 - (f28 / 2.0f), b2[1] - (f28 / 2.0f), b2[0] + (f28 / 2.0f), b2[1] + (f28 / 2.0f));
|
||||
}
|
||||
invalidate();
|
||||
AngleUpdateListener angleUpdateListener6 = this.e0;
|
||||
if (angleUpdateListener6 != null) {
|
||||
angleUpdateListener6.d(a8);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return super.onTouchEvent(motionEvent);
|
||||
}
|
||||
|
||||
public void setAngleUpdateListener(AngleUpdateListener angleUpdateListener) {
|
||||
this.e0 = angleUpdateListener;
|
||||
}
|
||||
|
||||
public void setCurrentMax(float f) {
|
||||
this.J = f;
|
||||
}
|
||||
|
||||
public void setCurrentMin(float f) {
|
||||
this.I = f;
|
||||
}
|
||||
|
||||
public TensionAngleSetView(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
this.j = 0.0f;
|
||||
this.k = 0.0f;
|
||||
this.T = -118.0f;
|
||||
this.U = 118.0f;
|
||||
this.D = context;
|
||||
a();
|
||||
}
|
||||
|
||||
public void a() {
|
||||
float f;
|
||||
this.V = ((int) this.T) + "°";
|
||||
this.W = ((int) this.U) + "°";
|
||||
this.a0 = this.D.getResources().getDimension(R.dimen.arrow_down_offset);
|
||||
this.a = this.D.getResources().getDimension(R.dimen.arrow_width);
|
||||
this.b = this.D.getResources().getDimension(R.dimen.arrow_height);
|
||||
this.c = this.D.getResources().getDimension(R.dimen.arrow_sides_x);
|
||||
this.d = this.D.getResources().getDimension(R.dimen.arrow_sides_y);
|
||||
this.e = this.D.getResources().getDimension(R.dimen.arrow_sides_down_y);
|
||||
this.f = this.D.getResources().getDimension(R.dimen.angle_text_margin_top);
|
||||
this.K = this.D.getResources().getDimension(R.dimen.angle_set_progress_width);
|
||||
this.g = this.D.getResources().getDimension(R.dimen.angle_set_view_width);
|
||||
this.c0 = this.D.getResources().getDimension(R.dimen.angle_set_view_width) + getResources().getDimension(R.dimen.angle_set_match);
|
||||
this.j = getResources().getDimension(R.dimen.top_match);
|
||||
this.k = getResources().getDimension(R.dimen.top_match);
|
||||
this.h = this.K;
|
||||
this.i = this.D.getResources().getDimension(R.dimen.start_arrows_wh);
|
||||
this.R = this.D.getResources().getString(R.string.ejector_value);
|
||||
this.S = this.D.getResources().getString(R.string.default_value);
|
||||
this.o = new Paint();
|
||||
this.o.setAntiAlias(true);
|
||||
this.o.setColor(this.D.getResources().getColor(R.color.txt_596F80));
|
||||
this.o.setTextSize(this.D.getResources().getDimension(R.dimen.angle_text_size));
|
||||
this.o.setTextAlign(Paint.Align.CENTER);
|
||||
this.p = new Paint();
|
||||
this.p.setAntiAlias(true);
|
||||
this.p.setColor(this.D.getResources().getColor(R.color.txt_596F80));
|
||||
this.p.setTextSize(this.D.getResources().getDimension(R.dimen.angle_text_hint_size));
|
||||
this.p.setTextAlign(Paint.Align.CENTER);
|
||||
this.n = new Paint();
|
||||
this.n.setFlags(3);
|
||||
this.q = new Paint();
|
||||
this.q.setFlags(3);
|
||||
this.r = new Paint();
|
||||
this.r.setFlags(3);
|
||||
this.r.setAlpha(60);
|
||||
this.s = new Paint();
|
||||
this.s.setFlags(3);
|
||||
this.s.setAlpha(60);
|
||||
this.t = new Paint();
|
||||
this.t.setFlags(3);
|
||||
this.M = new Paint();
|
||||
this.M.setColor(-16776961);
|
||||
this.l = new Paint();
|
||||
this.l.setColor(this.D.getResources().getColor(R.color.bg_3396A6B4));
|
||||
this.l.setFlags(3);
|
||||
this.l.setStrokeWidth(this.K);
|
||||
this.l.setStyle(Paint.Style.STROKE);
|
||||
this.l.setStrokeCap(Paint.Cap.ROUND);
|
||||
this.m = new Paint();
|
||||
this.m.setShader(new LinearGradient(0.0f, 0.0f, this.g + 500.0f, 0.0f, new int[]{this.D.getResources().getColor(R.color.color_FF4979), this.D.getResources().getColor(R.color.bg_F0553E)}, (float[]) null, Shader.TileMode.CLAMP));
|
||||
this.m.setFlags(3);
|
||||
this.m.setStrokeWidth(this.K);
|
||||
this.m.setStyle(Paint.Style.STROKE);
|
||||
this.m.setStrokeCap(Paint.Cap.BUTT);
|
||||
float f2 = this.j;
|
||||
float f3 = this.k;
|
||||
float f4 = this.K;
|
||||
float f5 = this.g;
|
||||
this.u = new RectF(f2, f3 + f4, f2 + f5, f3 + f5 + f4);
|
||||
float f6 = this.j;
|
||||
float f7 = this.k;
|
||||
float f8 = this.K;
|
||||
float f9 = this.g;
|
||||
this.v = new RectF(f6, f7 + f8, f6 + f9, f7 + f9 + f8);
|
||||
this.b0 = new Matrix();
|
||||
this.Q = this.u.centerX();
|
||||
this.P = this.u.centerY();
|
||||
float[] a = a(this.T, DataType.START);
|
||||
float f10 = a[0];
|
||||
float f11 = a[1];
|
||||
float[] b = b(this.U);
|
||||
float f12 = 0.0f;
|
||||
if (b != null) {
|
||||
f12 = b[0];
|
||||
f = b[1];
|
||||
} else {
|
||||
f = 0.0f;
|
||||
}
|
||||
float f13 = this.h;
|
||||
this.y = new RectF(f10 - (f13 / 2.0f), f11 - (f13 / 2.0f), f10 + (f13 / 2.0f), f11 + (f13 / 2.0f));
|
||||
float f14 = this.Q;
|
||||
float f15 = this.c;
|
||||
float f16 = this.a;
|
||||
float f17 = this.P;
|
||||
float f18 = this.d;
|
||||
float f19 = this.b;
|
||||
this.z = new RectF((f14 + f15) - (f16 / 2.0f), (f17 - f18) - (f19 / 2.0f), f14 + f15 + (f16 / 2.0f), (f17 - f18) + (f19 / 2.0f));
|
||||
float f20 = this.Q;
|
||||
float f21 = this.c;
|
||||
float f22 = this.a;
|
||||
float f23 = this.P;
|
||||
float f24 = this.d;
|
||||
float f25 = this.b;
|
||||
this.A = new RectF((f20 - f21) - (f22 / 2.0f), (f23 - f24) - (f25 / 2.0f), (f20 - f21) + (f22 / 2.0f), (f23 - f24) + (f25 / 2.0f));
|
||||
float f26 = this.Q;
|
||||
float f27 = this.c;
|
||||
float f28 = this.a;
|
||||
float f29 = this.P;
|
||||
float f30 = this.e;
|
||||
float f31 = this.b;
|
||||
this.B = new RectF((f26 + f27) - (f28 / 2.0f), (f29 + f30) - (f31 / 2.0f), f26 + f27 + (f28 / 2.0f), f29 + f30 + (f31 / 2.0f));
|
||||
float f32 = this.Q;
|
||||
float f33 = this.c;
|
||||
float f34 = this.a;
|
||||
float f35 = this.P;
|
||||
float f36 = this.e;
|
||||
float f37 = this.b;
|
||||
this.C = new RectF((f32 - f33) - (f34 / 2.0f), (f35 + f36) - (f37 / 2.0f), (f32 - f33) + (f34 / 2.0f), f35 + f36 + (f37 / 2.0f));
|
||||
this.E = BitmapFactory.decodeResource(this.D.getResources(), R.drawable.tension_start);
|
||||
Context context = this.D;
|
||||
float f38 = this.i;
|
||||
this.F = BitmapUtils.a(context, R.drawable.tension_end, (int) f38, (int) f38);
|
||||
float f39 = this.i;
|
||||
this.x = new RectF(f12 - (f39 / 2.0f), f - (f39 / 2.0f), f12 + (f39 / 2.0f), f + (f39 / 2.0f));
|
||||
this.G = BitmapFactory.decodeResource(this.D.getResources(), R.mipmap.arrow_up);
|
||||
this.H = BitmapFactory.decodeResource(this.D.getResources(), R.mipmap.arrow_down);
|
||||
}
|
||||
|
||||
private float b(float f, float f2) {
|
||||
float centerX = this.u.centerX();
|
||||
double degrees = Math.toDegrees(Math.atan((this.u.centerY() - f2) / (f - centerX)));
|
||||
if (f <= centerX) {
|
||||
degrees += 180.0d;
|
||||
}
|
||||
double d = -28.0f;
|
||||
if (degrees >= d) {
|
||||
d = degrees >= 208.0d ? 208.0d : degrees;
|
||||
}
|
||||
return (float) d;
|
||||
}
|
||||
|
||||
private float[] a(float f, DataType dataType) {
|
||||
float f2;
|
||||
float f3;
|
||||
float abs = (Math.abs(118.0f) + Math.abs(-118.0f)) / 236.0f;
|
||||
if (dataType == DataType.START) {
|
||||
f2 = (abs * (f - (-118.0f))) + 152.0f;
|
||||
this.N = f2;
|
||||
double d = this.N;
|
||||
if (d > 360.0d) {
|
||||
this.N = d - 360.0d;
|
||||
}
|
||||
f3 = f2;
|
||||
} else {
|
||||
f2 = (abs * (118.0f - f)) + 236.0f;
|
||||
this.O = f2 + this.N;
|
||||
double d2 = this.O;
|
||||
f3 = d2 > 360.0d ? (float) (d2 - 360.0d) : 0.0f;
|
||||
LogUtils.c("launchLimitAngle:angleDeviation:" + f2 + " progressEndAngle:" + this.O);
|
||||
}
|
||||
if (f3 >= 90.0f && f3 <= 180.0f) {
|
||||
float f4 = 180.0f - f3;
|
||||
double radians = Math.toRadians(f4);
|
||||
double sin = Math.sin(radians) * (this.g / 2.0f);
|
||||
float f5 = (float) (this.P + sin);
|
||||
float cos = (float) (this.Q - (Math.cos(radians) * (this.g / 2.0f)));
|
||||
Log.e("Test", "minBallX:" + cos + " minBallY:" + f5 + " radiansA:" + f4);
|
||||
return new float[]{cos, f5};
|
||||
}
|
||||
if (f3 > 180.0f && f3 <= 270.0f) {
|
||||
float f6 = f2 - 180.0f;
|
||||
double radians2 = Math.toRadians(f6);
|
||||
double sin2 = Math.sin(radians2) * (this.g / 2.0f);
|
||||
float f7 = (float) (this.P - sin2);
|
||||
float cos2 = (float) (this.Q - (Math.cos(radians2) * (this.g / 2.0f)));
|
||||
Log.e("Test", "minBallX:" + cos2 + " minBallY:" + f7 + " radiansA:" + f6);
|
||||
return new float[]{cos2, f7};
|
||||
}
|
||||
if (f3 > 270.0f && f3 <= 360.0f) {
|
||||
float f8 = f2 - 270.0f;
|
||||
double radians3 = Math.toRadians(f8);
|
||||
double sin3 = Math.sin(radians3) * (this.g / 2.0f);
|
||||
float cos3 = (float) (this.P - (Math.cos(radians3) * (this.g / 2.0f)));
|
||||
float f9 = (float) (this.Q + sin3);
|
||||
Log.e("Test", "minBallX:" + f9 + " minBallY:" + cos3 + " radiansA:" + f8);
|
||||
return new float[]{f9, cos3};
|
||||
}
|
||||
if (f3 >= 360.0f) {
|
||||
float f10 = f2 - 360.0f;
|
||||
double radians4 = Math.toRadians(f10);
|
||||
double sin4 = Math.sin(radians4) * (this.g / 2.0f);
|
||||
float f11 = (float) (this.P + sin4);
|
||||
float cos4 = (float) (this.Q + (Math.cos(radians4) * (this.g / 2.0f)));
|
||||
Log.e("Test", "minBallX:" + cos4 + " minBallY:" + f11 + " radiansA:" + f10);
|
||||
return new float[]{cos4, f11};
|
||||
}
|
||||
double radians5 = Math.toRadians(28.0f);
|
||||
double sin5 = Math.sin(radians5) * (this.g / 2.0f);
|
||||
float cos5 = (float) (this.Q - (Math.cos(radians5) * (this.g / 2.0f)));
|
||||
float f12 = (float) (sin5 + this.P);
|
||||
this.N = 152.0d;
|
||||
this.O = 28.0d;
|
||||
return new float[]{cos5, f12};
|
||||
}
|
||||
|
||||
private float[] a(float f) {
|
||||
if (f >= 90.0f && f <= 180.0f) {
|
||||
float f2 = 180.0f - f;
|
||||
double radians = Math.toRadians(f2);
|
||||
double sin = Math.sin(radians) * (this.g / 2.0f);
|
||||
float f3 = (float) (this.P + sin);
|
||||
float cos = (float) (this.Q - (Math.cos(radians) * (this.g / 2.0f)));
|
||||
Log.e("Test", "minBallX:" + cos + " minBallY:" + f3 + " radiansA:" + f2);
|
||||
return new float[]{cos, f3};
|
||||
}
|
||||
if (f > 180.0f && f <= 270.0f) {
|
||||
float f4 = f - 180.0f;
|
||||
double radians2 = Math.toRadians(f4);
|
||||
double sin2 = Math.sin(radians2) * (this.g / 2.0f);
|
||||
float f5 = (float) (this.P - sin2);
|
||||
float cos2 = (float) (this.Q - (Math.cos(radians2) * (this.g / 2.0f)));
|
||||
Log.e("Test", "minBallX:" + cos2 + " minBallY:" + f5 + " radiansA:" + f4);
|
||||
return new float[]{cos2, f5};
|
||||
}
|
||||
if (f > 270.0f && f <= 360.0f) {
|
||||
double radians3 = Math.toRadians(f - 270.0f);
|
||||
return new float[]{(float) (this.Q + (Math.sin(radians3) * (this.g / 2.0f))), (float) (this.P - (Math.cos(radians3) * (this.g / 2.0f)))};
|
||||
}
|
||||
if (f >= 0.0f && f < 90.0f) {
|
||||
double radians4 = Math.toRadians(f);
|
||||
return new float[]{(float) (this.Q + (Math.cos(radians4) * (this.g / 2.0f))), (float) (this.P + (Math.sin(radians4) * (this.g / 2.0f)))};
|
||||
}
|
||||
double radians5 = Math.toRadians(28.0f);
|
||||
double sin3 = Math.sin(radians5) * (this.g / 2.0f);
|
||||
float cos3 = (float) (this.Q - (Math.cos(radians5) * (this.g / 2.0f)));
|
||||
float f6 = (float) (sin3 + this.P);
|
||||
this.N = 152.0d;
|
||||
this.O = 28.0d;
|
||||
return new float[]{cos3, f6};
|
||||
}
|
||||
|
||||
private double a(double d) {
|
||||
if (Math.round(d) < 152.0f) {
|
||||
d += 360.0d;
|
||||
}
|
||||
return Math.round((d - 152.0d) * 1.0d) - 118.0d;
|
||||
}
|
||||
|
||||
public float a(boolean z) {
|
||||
float degrees = (float) Math.toDegrees(Math.atan2(this.u.centerX() - this.x.centerX(), this.u.centerY() - this.x.centerY()));
|
||||
return !z ? degrees + 180.0f : degrees;
|
||||
}
|
||||
}
|
||||
335
sources/com/ubt/jimu/controller/component/VSliderView.java
Normal file
335
sources/com/ubt/jimu/controller/component/VSliderView.java
Normal file
@@ -0,0 +1,335 @@
|
||||
package com.ubt.jimu.controller.component;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.controller.data.config.SliderConfig;
|
||||
import com.ubt.jimu.controller.data.widget.SliderWidgetData;
|
||||
import com.ubt.jimu.controller.manager.CommandSendManager;
|
||||
import com.ubt.jimu.controller.view.control.ControlTouchEvent;
|
||||
import com.ubt.jimu.controller.view.control.SuperControlView;
|
||||
import com.ubt.jimu.utils.LogUtils;
|
||||
import com.ubt.jimu.utils.SystemUtils;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class VSliderView extends SuperControlView<SliderWidgetData> {
|
||||
private Paint B;
|
||||
private Context C;
|
||||
private Bitmap D;
|
||||
private Bitmap E;
|
||||
private RectF F;
|
||||
private float G;
|
||||
private float H;
|
||||
private float I;
|
||||
private RectF J;
|
||||
private float K;
|
||||
private float L;
|
||||
private float M;
|
||||
private long N;
|
||||
private CommandSendManager O;
|
||||
private float P;
|
||||
private float Q;
|
||||
private float R;
|
||||
private float S;
|
||||
|
||||
public VSliderView(Context context, float f, float f2) {
|
||||
super(context);
|
||||
this.N = System.currentTimeMillis();
|
||||
this.C = context;
|
||||
this.G = f;
|
||||
this.H = f2;
|
||||
f();
|
||||
h();
|
||||
g();
|
||||
this.O = new CommandSendManager();
|
||||
}
|
||||
|
||||
private void b(float f, float f2) {
|
||||
this.F.offsetTo(f, f2);
|
||||
this.j.offsetTo(f, f2);
|
||||
this.J.offsetTo(this.F.centerX() - (this.I / 2.0f), this.F.centerY() - (this.I / 2.0f));
|
||||
}
|
||||
|
||||
private void f() {
|
||||
this.B = new Paint();
|
||||
this.B.setFlags(3);
|
||||
}
|
||||
|
||||
private void g() {
|
||||
this.m = this.C.getResources().getDimension(R.dimen.grid_view_width) * 8.0f;
|
||||
this.D.getWidth();
|
||||
this.D.getHeight();
|
||||
float f = this.m;
|
||||
this.l = f / 2.0f;
|
||||
this.K = this.l / 2.0f;
|
||||
this.L = f / 2.0f;
|
||||
this.I = this.C.getResources().getDimension(R.dimen.controlBallWidthOrHeight);
|
||||
float f2 = this.H;
|
||||
float f3 = this.m;
|
||||
float f4 = f2 + (f3 / 2.0f);
|
||||
int i = this.s;
|
||||
if (f4 >= i) {
|
||||
this.H = i - (f3 / 2.0f);
|
||||
}
|
||||
float f5 = this.G;
|
||||
float f6 = this.l;
|
||||
if (f5 - (f6 / 2.0f) <= 0.0f) {
|
||||
this.G = f6 / 2.0f;
|
||||
} else {
|
||||
float f7 = f5 + (f6 / 2.0f);
|
||||
int i2 = this.r;
|
||||
if (f7 >= i2) {
|
||||
this.G = i2 - (f6 / 2.0f);
|
||||
}
|
||||
}
|
||||
float f8 = this.G;
|
||||
float f9 = this.l;
|
||||
float f10 = this.H;
|
||||
float f11 = this.m;
|
||||
this.F = new RectF(f8 - (f9 / 2.0f), f10 - (f11 / 2.0f), (f9 / 2.0f) + f8, (f11 / 2.0f) + f10);
|
||||
float centerX = this.F.centerX();
|
||||
float centerY = this.F.centerY();
|
||||
float f12 = this.I;
|
||||
this.J = new RectF(centerX - (f12 / 2.0f), centerY - (f12 / 2.0f), centerX + (f12 / 2.0f), centerY + (f12 / 2.0f));
|
||||
}
|
||||
|
||||
private void h() {
|
||||
this.D = BitmapFactory.decodeResource(this.C.getResources(), R.mipmap.bg_v_slider);
|
||||
this.E = BitmapFactory.decodeResource(this.C.getResources(), R.mipmap.slider_ball);
|
||||
}
|
||||
|
||||
public boolean a(RectF rectF) {
|
||||
RectF deleteViewRectF = getDeleteViewRectF();
|
||||
if (deleteViewRectF == null) {
|
||||
return false;
|
||||
}
|
||||
return RectF.intersects(deleteViewRectF, rectF);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.view.control.SuperControlView
|
||||
public float[] getViewCenterXY() {
|
||||
return new float[]{this.F.centerX(), this.F.centerY()};
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.view.control.SuperControlView, android.view.View
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
canvas.drawBitmap(this.D, (Rect) null, this.F, this.B);
|
||||
canvas.drawBitmap(this.E, (Rect) null, this.J, this.B);
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public boolean onTouchEvent(MotionEvent motionEvent) {
|
||||
int action = motionEvent.getAction();
|
||||
if (action == 0) {
|
||||
this.t = System.currentTimeMillis();
|
||||
this.R = motionEvent.getX();
|
||||
this.S = motionEvent.getY();
|
||||
super.d();
|
||||
this.f = false;
|
||||
if (!b()) {
|
||||
float centerX = this.J.centerX();
|
||||
float centerY = this.J.centerY();
|
||||
float f = this.I;
|
||||
float f2 = centerX - (f / 2.0f);
|
||||
float f3 = centerX + (f / 2.0f);
|
||||
float f4 = centerY - (f / 2.0f);
|
||||
float f5 = centerY + (f / 2.0f);
|
||||
float f6 = this.R;
|
||||
if (f6 >= f2 && f6 <= f3) {
|
||||
float f7 = this.S;
|
||||
if (f7 >= f4 && f7 <= f5) {
|
||||
this.O.a((CommandSendManager) getData());
|
||||
this.O.a();
|
||||
ControlTouchEvent controlTouchEvent = this.i;
|
||||
if (controlTouchEvent != null) {
|
||||
controlTouchEvent.a((SuperControlView) this);
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.onTouchEvent(motionEvent);
|
||||
}
|
||||
float centerX2 = this.F.centerX();
|
||||
float centerY2 = this.F.centerY();
|
||||
float f8 = this.K;
|
||||
float f9 = centerX2 - f8;
|
||||
float f10 = centerX2 + f8;
|
||||
float f11 = this.L;
|
||||
float f12 = centerY2 - f11;
|
||||
float f13 = centerY2 + f11;
|
||||
float f14 = this.R;
|
||||
if (f14 >= f9 && f14 <= f10) {
|
||||
float f15 = this.S;
|
||||
if (f15 >= f12 && f15 <= f13) {
|
||||
this.P = super.a(f14);
|
||||
this.Q = super.b(this.S);
|
||||
bringToFront();
|
||||
ControlTouchEvent controlTouchEvent2 = this.i;
|
||||
if (controlTouchEvent2 != null) {
|
||||
controlTouchEvent2.a((View) this);
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.onTouchEvent(motionEvent);
|
||||
return true;
|
||||
}
|
||||
if (action == 1) {
|
||||
if (!this.f) {
|
||||
this.f = true;
|
||||
b(motionEvent);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (action != 2) {
|
||||
if (action == 3 && !this.f) {
|
||||
this.f = true;
|
||||
b(motionEvent);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (b()) {
|
||||
b(super.a(motionEvent, this.P), super.b(motionEvent, this.Q));
|
||||
if (this.i != null) {
|
||||
float abs = Math.abs(motionEvent.getX() - this.R);
|
||||
float abs2 = Math.abs(motionEvent.getY() - this.S);
|
||||
if (abs <= 10.0f && abs2 <= 10.0f) {
|
||||
return true;
|
||||
}
|
||||
this.i.b((View) this);
|
||||
if (a(this.j)) {
|
||||
b(false);
|
||||
if (this.e != null && getData() != null) {
|
||||
this.e.setOverlapState(true);
|
||||
this.e.a(String.format(this.C.getResources().getString(R.string.control_remove_widget), getData().getWidgetInfo(this.C)));
|
||||
}
|
||||
this.b.setColor(this.C.getResources().getColor(R.color.color_FF4979));
|
||||
if (!this.n) {
|
||||
SystemUtils.b(this.C);
|
||||
this.n = true;
|
||||
}
|
||||
} else {
|
||||
if (this.e != null && getData() != null) {
|
||||
this.e.setOverlapState(false);
|
||||
this.e.a(String.format(this.C.getResources().getString(R.string.control_remove_widget_here), getData().getWidgetInfo(this.C)));
|
||||
}
|
||||
RectF rectF = this.F;
|
||||
PointF a = a(rectF.left, rectF.top);
|
||||
this.k.offsetTo(a.x, a.y);
|
||||
if (this.i.c((SuperControlView) this)) {
|
||||
b(false);
|
||||
this.b.setColor(this.C.getResources().getColor(R.color.bg_99B8BEC1));
|
||||
} else {
|
||||
b(true);
|
||||
this.b.setColor(this.C.getResources().getColor(this.a));
|
||||
}
|
||||
this.n = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
float y = motionEvent.getY();
|
||||
float centerX3 = this.F.centerX();
|
||||
float centerY3 = this.F.centerY();
|
||||
float f16 = this.L;
|
||||
float f17 = this.I;
|
||||
float f18 = (centerY3 - f16) + (f17 / 2.0f);
|
||||
float f19 = (centerY3 + f16) - (f17 / 2.0f);
|
||||
if (y < f18) {
|
||||
y = f18;
|
||||
}
|
||||
if (y > f19) {
|
||||
y = f19;
|
||||
}
|
||||
RectF rectF2 = this.J;
|
||||
float f20 = this.I;
|
||||
rectF2.offsetTo(centerX3 - (f20 / 2.0f), y - (f20 / 2.0f));
|
||||
this.M = this.J.centerX() - this.F.centerX();
|
||||
if (System.currentTimeMillis() - this.N > 200) {
|
||||
this.N = System.currentTimeMillis();
|
||||
}
|
||||
a(motionEvent);
|
||||
}
|
||||
invalidate();
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setUpdateCommandParameterListener(CommandSendManager.VSliderViewCommandSendListener vSliderViewCommandSendListener) {
|
||||
this.O.a(vSliderViewCommandSendListener);
|
||||
}
|
||||
|
||||
public void a(MotionEvent motionEvent) {
|
||||
float[] viewCenterXY = getViewCenterXY();
|
||||
if (viewCenterXY == null || viewCenterXY.length < 2) {
|
||||
return;
|
||||
}
|
||||
float y = motionEvent.getY() - viewCenterXY[1];
|
||||
float f = viewCenterXY[1];
|
||||
float f2 = this.L;
|
||||
float f3 = this.I;
|
||||
float f4 = (((viewCenterXY[1] + f2) - (f3 / 2.0f)) - ((f - f2) + (f3 / 2.0f))) / 2.0f;
|
||||
float f5 = -f4;
|
||||
if (y <= f5) {
|
||||
y = f5;
|
||||
} else if (y >= f4) {
|
||||
y = f4;
|
||||
}
|
||||
this.O.a(-((y / f4) * 100.0f));
|
||||
if (motionEvent.getAction() == 1 || motionEvent.getAction() == 3) {
|
||||
this.O.b();
|
||||
}
|
||||
}
|
||||
|
||||
private void b(MotionEvent motionEvent) {
|
||||
SliderWidgetData data;
|
||||
SliderConfig config;
|
||||
if (b()) {
|
||||
boolean a = a(this.j);
|
||||
LogUtils.c("isDelete:");
|
||||
if (a) {
|
||||
if (this.i != null && (data = getData()) != null && (config = data.getConfig()) != null) {
|
||||
this.i.a(this, config.getConfigID());
|
||||
this.i.c((View) this);
|
||||
}
|
||||
invalidate();
|
||||
return;
|
||||
}
|
||||
if (this.i != null) {
|
||||
RectF rectF = this.F;
|
||||
PointF a2 = a(rectF.left, rectF.top);
|
||||
this.k.offsetTo(a2.x, a2.y);
|
||||
if (this.i.c((SuperControlView) this)) {
|
||||
b(this.o, this.p);
|
||||
this.b.setColor(this.C.getResources().getColor(this.a));
|
||||
} else {
|
||||
b(a2.x, a2.y);
|
||||
this.i.a(this, this.F.centerX(), this.F.centerY());
|
||||
}
|
||||
this.i.c((View) this);
|
||||
if (System.currentTimeMillis() - this.t < 350) {
|
||||
this.i.a(this, getData());
|
||||
}
|
||||
}
|
||||
b(false);
|
||||
} else {
|
||||
ControlTouchEvent controlTouchEvent = this.i;
|
||||
if (controlTouchEvent != null) {
|
||||
controlTouchEvent.b((SuperControlView) this);
|
||||
}
|
||||
float centerX = this.F.centerX();
|
||||
float centerY = this.F.centerY();
|
||||
RectF rectF2 = this.J;
|
||||
float f = centerX + this.M;
|
||||
float f2 = this.I;
|
||||
rectF2.offsetTo(f - (f2 / 2.0f), centerY - (f2 / 2.0f));
|
||||
a(motionEvent);
|
||||
}
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
550
sources/com/ubt/jimu/controller/component/WallPulleyView.java
Normal file
550
sources/com/ubt/jimu/controller/component/WallPulleyView.java
Normal file
@@ -0,0 +1,550 @@
|
||||
package com.ubt.jimu.controller.component;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.animation.BounceInterpolator;
|
||||
import android.view.animation.LinearInterpolator;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.controller.data.config.AccumulatorConfig;
|
||||
import com.ubt.jimu.controller.data.widget.AccumulatorData;
|
||||
import com.ubt.jimu.controller.view.control.ControlTouchEvent;
|
||||
import com.ubt.jimu.controller.view.control.SuperControlView;
|
||||
import com.ubt.jimu.utils.BitmapUtils;
|
||||
import com.ubt.jimu.utils.LogUtils;
|
||||
import com.ubt.jimu.utils.SystemUtils;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class WallPulleyView extends SuperControlView<AccumulatorData> {
|
||||
private Bitmap B;
|
||||
private Bitmap C;
|
||||
private Context D;
|
||||
private Paint E;
|
||||
private Paint F;
|
||||
private Paint G;
|
||||
private RectF H;
|
||||
private RectF I;
|
||||
private RectF J;
|
||||
private RectF K;
|
||||
private RectF L;
|
||||
private RectF M;
|
||||
private float N;
|
||||
private float O;
|
||||
private float P;
|
||||
private float Q;
|
||||
private float R;
|
||||
private float S;
|
||||
private float T;
|
||||
private float U;
|
||||
private float V;
|
||||
private float W;
|
||||
private float a0;
|
||||
private float b0;
|
||||
private float c0;
|
||||
private float d0;
|
||||
private float e0;
|
||||
private float f0;
|
||||
private float g0;
|
||||
private float h0;
|
||||
private WallPulleyViewCommandParameterListener i0;
|
||||
|
||||
public interface WallPulleyViewCommandParameterListener {
|
||||
void a(float f, AccumulatorData accumulatorData);
|
||||
|
||||
void b(float f, AccumulatorData accumulatorData);
|
||||
}
|
||||
|
||||
public WallPulleyView(Context context, float f, float f2) {
|
||||
super(context);
|
||||
this.R = 900.0f;
|
||||
this.S = 400.0f;
|
||||
this.e0 = 90.0f;
|
||||
this.f0 = 0.0f;
|
||||
this.g0 = 90.0f;
|
||||
this.h0 = 0.0f;
|
||||
this.D = context;
|
||||
this.R = f;
|
||||
this.S = f2;
|
||||
h();
|
||||
}
|
||||
|
||||
private void c(float f, float f2) {
|
||||
float centerY = this.M.centerY() - (f2 - (this.Q / 2.0f));
|
||||
if (centerY < 5.0f) {
|
||||
centerY = 0.0f;
|
||||
}
|
||||
float f3 = this.T * centerY;
|
||||
double d = (f3 * 180.0f) / ((this.P * 3.141592653589793d) / 2.0d);
|
||||
if (d >= 90.0d) {
|
||||
d = 90.0d;
|
||||
}
|
||||
this.e0 = (float) (90.0d - d);
|
||||
this.f0 = ((float) d) * 2.0f;
|
||||
float arcLength = getArcLength();
|
||||
float f4 = this.T;
|
||||
float f5 = arcLength / f4;
|
||||
float f6 = (this.Q - f5) * f4;
|
||||
float centerY2 = this.J.centerY();
|
||||
float centerY3 = this.K.centerY();
|
||||
if (f3 >= arcLength && f6 >= f3) {
|
||||
float f7 = centerY2 - ((centerY - f5) * this.T);
|
||||
RectF rectF = this.L;
|
||||
float f8 = this.N;
|
||||
rectF.set(f - (f8 / 2.0f), f7, f + (f8 / 2.0f), centerY2);
|
||||
this.g0 = 90.0f;
|
||||
this.h0 = 0.0f;
|
||||
} else if (f6 < f3) {
|
||||
double d2 = ((f3 - f6) * 180.0f) / ((this.P * 3.141592653589793d) / 2.0d);
|
||||
this.g0 = (float) (360.0d - d2);
|
||||
this.h0 = (float) ((d2 * 2.0d) + 180.0d);
|
||||
RectF rectF2 = this.L;
|
||||
float f9 = this.N;
|
||||
rectF2.set(f - (f9 / 2.0f), centerY3, f + (f9 / 2.0f), centerY2);
|
||||
} else {
|
||||
RectF rectF3 = this.L;
|
||||
float f10 = this.N;
|
||||
rectF3.set(f - (f10 / 2.0f), 0.0f, f + (f10 / 2.0f), 0.0f);
|
||||
}
|
||||
this.W = centerY / this.Q;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void d(float f, float f2) {
|
||||
float f3 = this.T * f;
|
||||
double d = (f3 * 180.0f) / ((this.P * 3.141592653589793d) / 2.0d);
|
||||
if (d >= 90.0d) {
|
||||
d = 90.0d;
|
||||
}
|
||||
this.e0 = (float) (90.0d - d);
|
||||
this.f0 = ((float) d) * 2.0f;
|
||||
float arcLength = getArcLength();
|
||||
float f4 = this.T;
|
||||
float f5 = arcLength / f4;
|
||||
float f6 = (this.Q - f5) * f4;
|
||||
float centerY = this.J.centerY();
|
||||
float centerY2 = this.K.centerY();
|
||||
if (f3 >= arcLength && f6 >= f3) {
|
||||
float f7 = centerY - ((f - f5) * this.T);
|
||||
RectF rectF = this.L;
|
||||
float f8 = this.N;
|
||||
rectF.set(f2 - (f8 / 2.0f), f7, f2 + (f8 / 2.0f), centerY);
|
||||
this.g0 = 90.0f;
|
||||
this.h0 = 0.0f;
|
||||
} else if (f6 < f3) {
|
||||
double d2 = ((f3 - f6) * 180.0f) / ((this.P * 3.141592653589793d) / 2.0d);
|
||||
this.g0 = (float) (360.0d - d2);
|
||||
this.h0 = (float) ((d2 * 2.0d) + 180.0d);
|
||||
RectF rectF2 = this.L;
|
||||
float f9 = this.N;
|
||||
rectF2.set(f2 - (f9 / 2.0f), centerY2, f2 + (f9 / 2.0f), centerY);
|
||||
} else {
|
||||
RectF rectF3 = this.L;
|
||||
float f10 = this.N;
|
||||
rectF3.set(f2 - (f10 / 2.0f), 0.0f, f2 + (f10 / 2.0f), 0.0f);
|
||||
}
|
||||
this.W = f / this.Q;
|
||||
}
|
||||
|
||||
private void g() {
|
||||
this.B = BitmapUtils.a(ContextCompat.c(this.D, R.mipmap.wall_pulley));
|
||||
this.C = BitmapFactory.decodeResource(this.D.getResources(), R.mipmap.wall_pulley_ball);
|
||||
}
|
||||
|
||||
private float getArcLength() {
|
||||
return ((float) (this.N * 3.141592653589793d)) / 4.0f;
|
||||
}
|
||||
|
||||
private float getProgressLength() {
|
||||
float arcLength = getArcLength() * 2.0f;
|
||||
float f = this.Q + arcLength;
|
||||
LogUtils.c("progressLength:" + f + " arcLength:" + arcLength);
|
||||
return f;
|
||||
}
|
||||
|
||||
private float getProgressRatio() {
|
||||
return getProgressLength() / this.Q;
|
||||
}
|
||||
|
||||
private void h() {
|
||||
i();
|
||||
g();
|
||||
j();
|
||||
k();
|
||||
}
|
||||
|
||||
private void i() {
|
||||
this.E = new Paint();
|
||||
this.F = new Paint();
|
||||
this.G = new Paint();
|
||||
this.E.setFlags(3);
|
||||
this.F.setFlags(3);
|
||||
this.G.setFlags(3);
|
||||
this.F.setColor(this.D.getResources().getColor(R.color.bg_D3EEFF));
|
||||
this.G.setColor(this.D.getResources().getColor(R.color.color_00C4C9));
|
||||
}
|
||||
|
||||
private void j() {
|
||||
this.m = this.D.getResources().getDimension(R.dimen.grid_view_width) * 8.0f;
|
||||
float f = this.m;
|
||||
this.l = f / 2.0f;
|
||||
float f2 = this.S + (f / 2.0f);
|
||||
int i = this.s;
|
||||
if (f2 >= i) {
|
||||
this.S = i - (f / 2.0f);
|
||||
}
|
||||
float f3 = this.R;
|
||||
float f4 = this.l;
|
||||
if (f3 - (f4 / 2.0f) <= 0.0f) {
|
||||
this.R = f4 / 2.0f;
|
||||
} else {
|
||||
float f5 = f3 + (f4 / 2.0f);
|
||||
int i2 = this.r;
|
||||
if (f5 >= i2) {
|
||||
this.R = i2 - (f4 / 2.0f);
|
||||
}
|
||||
}
|
||||
float f6 = this.l;
|
||||
this.U = f6 / 2.0f;
|
||||
float f7 = this.m;
|
||||
this.V = f7 / 2.0f;
|
||||
this.N = f6 * 0.79f;
|
||||
this.O = f7 * 0.87f;
|
||||
this.P = this.D.getResources().getDimension(R.dimen.ball_width_height);
|
||||
this.Q = this.m * 0.47f;
|
||||
this.T = getProgressRatio();
|
||||
}
|
||||
|
||||
private void k() {
|
||||
float f = this.R;
|
||||
float f2 = this.l;
|
||||
float f3 = this.S;
|
||||
float f4 = this.m;
|
||||
this.H = new RectF(f - (f2 / 2.0f), f3 - (f4 / 2.0f), f + (f2 / 2.0f), f3 + (f4 / 2.0f));
|
||||
float centerX = this.H.centerX();
|
||||
float centerY = this.H.centerY();
|
||||
float f5 = this.N;
|
||||
float f6 = this.O;
|
||||
this.I = new RectF(centerX - (f5 / 2.0f), centerY - (f6 / 2.0f), (f5 / 2.0f) + centerX, (f6 / 2.0f) + centerY);
|
||||
float f7 = this.O;
|
||||
float f8 = (f7 / 2.0f) + centerY;
|
||||
float f9 = centerY - (f7 / 2.0f);
|
||||
float f10 = this.N;
|
||||
this.J = new RectF(centerX - (f10 / 2.0f), f8 - f10, (f10 / 2.0f) + centerX, f8);
|
||||
float f11 = this.N;
|
||||
this.L = new RectF(centerX - (f11 / 2.0f), 0.0f, (f11 / 2.0f) + centerX, 0.0f);
|
||||
float f12 = this.N;
|
||||
this.K = new RectF(centerX - (f12 / 2.0f), f9, (f12 / 2.0f) + centerX, f12 + f9);
|
||||
float f13 = centerY - (this.Q / 2.0f);
|
||||
float f14 = this.P;
|
||||
this.M = new RectF(centerX - (f14 / 2.0f), f13 - (f14 / 2.0f), centerX + (f14 / 2.0f), f13 + (f14 / 2.0f));
|
||||
}
|
||||
|
||||
public void f() {
|
||||
float centerY = this.M.centerY();
|
||||
float centerY2 = this.H.centerY();
|
||||
final float centerX = this.H.centerX();
|
||||
ValueAnimator ofFloat = ValueAnimator.ofFloat(centerY, centerY2 - (this.Q / 2.0f));
|
||||
ofFloat.setInterpolator(new BounceInterpolator());
|
||||
ofFloat.setDuration(300L);
|
||||
ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { // from class: com.ubt.jimu.controller.component.WallPulleyView.1
|
||||
@Override // android.animation.ValueAnimator.AnimatorUpdateListener
|
||||
public void onAnimationUpdate(ValueAnimator valueAnimator) {
|
||||
WallPulleyView.this.M.offsetTo(centerX - (WallPulleyView.this.P / 2.0f), ((Float) valueAnimator.getAnimatedValue()).floatValue() - (WallPulleyView.this.P / 2.0f));
|
||||
WallPulleyView.this.invalidate();
|
||||
}
|
||||
});
|
||||
ofFloat.start();
|
||||
ValueAnimator ofFloat2 = ValueAnimator.ofFloat(this.Q, 0.0f);
|
||||
ofFloat2.setInterpolator(new LinearInterpolator());
|
||||
ofFloat2.setDuration(400L);
|
||||
ofFloat2.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { // from class: com.ubt.jimu.controller.component.WallPulleyView.2
|
||||
@Override // android.animation.ValueAnimator.AnimatorUpdateListener
|
||||
public void onAnimationUpdate(ValueAnimator valueAnimator) {
|
||||
WallPulleyView.this.d(((Float) valueAnimator.getAnimatedValue()).floatValue(), centerX);
|
||||
WallPulleyView.this.invalidate();
|
||||
}
|
||||
});
|
||||
ofFloat2.addListener(new Animator.AnimatorListener() { // from class: com.ubt.jimu.controller.component.WallPulleyView.3
|
||||
@Override // android.animation.Animator.AnimatorListener
|
||||
public void onAnimationCancel(Animator animator) {
|
||||
LogUtils.c("onAnimationCancel");
|
||||
WallPulleyView.this.g0 = 0.0f;
|
||||
WallPulleyView.this.h0 = 0.0f;
|
||||
WallPulleyView.this.invalidate();
|
||||
}
|
||||
|
||||
@Override // android.animation.Animator.AnimatorListener
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
LogUtils.c("onAnimationEnd");
|
||||
WallPulleyView.this.g0 = 0.0f;
|
||||
WallPulleyView.this.h0 = 0.0f;
|
||||
WallPulleyView.this.invalidate();
|
||||
}
|
||||
|
||||
@Override // android.animation.Animator.AnimatorListener
|
||||
public void onAnimationRepeat(Animator animator) {
|
||||
LogUtils.c("onAnimationRepeat");
|
||||
}
|
||||
|
||||
@Override // android.animation.Animator.AnimatorListener
|
||||
public void onAnimationStart(Animator animator) {
|
||||
LogUtils.c("动画开始");
|
||||
}
|
||||
});
|
||||
ofFloat2.start();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.view.control.SuperControlView
|
||||
public float[] getViewCenterXY() {
|
||||
return new float[]{this.H.centerX(), this.H.centerY()};
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.view.control.SuperControlView, android.view.View
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
RectF rectF = this.I;
|
||||
float f = this.N;
|
||||
canvas.drawRoundRect(rectF, f / 2.0f, f / 2.0f, this.F);
|
||||
canvas.drawArc(this.J, this.e0, this.f0, true, this.G);
|
||||
canvas.drawArc(this.K, this.g0, this.h0, true, this.G);
|
||||
canvas.drawRect(this.L, this.G);
|
||||
canvas.drawBitmap(this.B, (Rect) null, this.H, this.E);
|
||||
canvas.drawBitmap(this.C, (Rect) null, this.M, this.E);
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public boolean onTouchEvent(MotionEvent motionEvent) {
|
||||
int action = motionEvent.getAction();
|
||||
if (action == 0) {
|
||||
this.t = System.currentTimeMillis();
|
||||
this.c0 = motionEvent.getX();
|
||||
this.d0 = motionEvent.getY();
|
||||
float centerX = this.M.centerX();
|
||||
float centerY = this.M.centerY();
|
||||
super.d();
|
||||
this.f = false;
|
||||
if (!b()) {
|
||||
float f = this.c0;
|
||||
float f2 = this.P;
|
||||
if (f >= centerX - (f2 / 2.0f) && f <= centerX + (f2 / 2.0f)) {
|
||||
float f3 = this.d0;
|
||||
if (f3 >= centerY - (f2 / 2.0f) && f3 <= centerY + (f2 / 2.0f)) {
|
||||
ControlTouchEvent controlTouchEvent = this.i;
|
||||
if (controlTouchEvent != null) {
|
||||
controlTouchEvent.a((SuperControlView) this);
|
||||
}
|
||||
}
|
||||
}
|
||||
LogUtils.c("不可移动");
|
||||
return super.onTouchEvent(motionEvent);
|
||||
}
|
||||
float centerX2 = this.H.centerX();
|
||||
float centerY2 = this.H.centerY();
|
||||
float f4 = this.U;
|
||||
float f5 = centerX2 - f4;
|
||||
float f6 = centerX2 + f4;
|
||||
float f7 = this.V;
|
||||
float f8 = centerY2 - f7;
|
||||
float f9 = centerY2 + f7;
|
||||
float f10 = this.c0;
|
||||
if (f10 >= f5 && f10 <= f6) {
|
||||
float f11 = this.d0;
|
||||
if (f11 >= f8 && f11 <= f9) {
|
||||
this.a0 = super.a(f10);
|
||||
this.b0 = super.b(this.d0);
|
||||
bringToFront();
|
||||
ControlTouchEvent controlTouchEvent2 = this.i;
|
||||
if (controlTouchEvent2 != null) {
|
||||
controlTouchEvent2.a((View) this);
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.onTouchEvent(motionEvent);
|
||||
return true;
|
||||
}
|
||||
if (action == 1) {
|
||||
if (!this.f) {
|
||||
LogUtils.c("蓄力器:ACTION_UP");
|
||||
this.f = true;
|
||||
b(motionEvent);
|
||||
}
|
||||
invalidate();
|
||||
return true;
|
||||
}
|
||||
if (action != 2) {
|
||||
if (action != 3) {
|
||||
return true;
|
||||
}
|
||||
if (!this.f) {
|
||||
LogUtils.c("蓄力器:ACTION_CANCEL");
|
||||
this.f = true;
|
||||
b(motionEvent);
|
||||
}
|
||||
invalidate();
|
||||
return true;
|
||||
}
|
||||
if (b()) {
|
||||
b(super.a(motionEvent, this.a0), super.b(motionEvent, this.b0));
|
||||
if (this.i != null) {
|
||||
float abs = Math.abs(motionEvent.getX() - this.c0);
|
||||
float abs2 = Math.abs(motionEvent.getY() - this.d0);
|
||||
if (abs <= 10.0f && abs2 <= 10.0f) {
|
||||
return true;
|
||||
}
|
||||
this.i.b((View) this);
|
||||
if (a(this.j)) {
|
||||
if (this.e != null && getData() != null) {
|
||||
String format = String.format(this.D.getResources().getString(R.string.control_remove_widget), getData().getWidgetInfo(this.D));
|
||||
this.e.setOverlapState(true);
|
||||
this.e.a(format);
|
||||
}
|
||||
b(false);
|
||||
this.b.setColor(this.D.getResources().getColor(R.color.color_FF4979));
|
||||
if (!this.n) {
|
||||
SystemUtils.b(this.D);
|
||||
this.n = true;
|
||||
}
|
||||
} else {
|
||||
if (this.e != null && getData() != null) {
|
||||
String format2 = String.format(this.D.getResources().getString(R.string.control_remove_widget_here), getData().getWidgetInfo(this.D));
|
||||
this.e.setOverlapState(false);
|
||||
this.e.a(format2);
|
||||
}
|
||||
RectF rectF = this.H;
|
||||
PointF a = a(rectF.left, rectF.top);
|
||||
this.k.offsetTo(a.x, a.y);
|
||||
if (this.i.c((SuperControlView) this)) {
|
||||
b(false);
|
||||
this.b.setColor(this.D.getResources().getColor(R.color.bg_99B8BEC1));
|
||||
} else {
|
||||
b(true);
|
||||
this.b.setColor(this.D.getResources().getColor(this.a));
|
||||
}
|
||||
this.n = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
float y = motionEvent.getY();
|
||||
motionEvent.getX();
|
||||
float centerX3 = this.H.centerX();
|
||||
float centerY3 = this.H.centerY();
|
||||
float f12 = this.Q;
|
||||
if (y < centerY3 - (f12 / 2.0f)) {
|
||||
y = centerY3 - (f12 / 2.0f);
|
||||
} else if (y > (f12 / 2.0f) + centerY3) {
|
||||
y = centerY3 + (f12 / 2.0f);
|
||||
}
|
||||
RectF rectF2 = this.M;
|
||||
float f13 = this.P;
|
||||
rectF2.offsetTo(centerX3 - (f13 / 2.0f), y - (f13 / 2.0f));
|
||||
c(centerX3, centerY3);
|
||||
a(motionEvent);
|
||||
}
|
||||
invalidate();
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setWallPulleyViewCommandParameterListener(WallPulleyViewCommandParameterListener wallPulleyViewCommandParameterListener) {
|
||||
this.i0 = wallPulleyViewCommandParameterListener;
|
||||
}
|
||||
|
||||
private void b(float f, float f2) {
|
||||
this.H.offsetTo(f, f2);
|
||||
this.j.offsetTo(f, f2);
|
||||
b(this.H);
|
||||
}
|
||||
|
||||
public boolean a(RectF rectF) {
|
||||
RectF deleteViewRectF = getDeleteViewRectF();
|
||||
if (deleteViewRectF == null) {
|
||||
return false;
|
||||
}
|
||||
return RectF.intersects(deleteViewRectF, rectF);
|
||||
}
|
||||
|
||||
private void b(MotionEvent motionEvent) {
|
||||
AccumulatorConfig config;
|
||||
if (b()) {
|
||||
if (a(this.j) && this.i != null && (config = getData().getConfig()) != null) {
|
||||
this.i.a(this, config.getConfigID());
|
||||
}
|
||||
if (this.i != null) {
|
||||
RectF rectF = this.H;
|
||||
PointF a = a(rectF.left, rectF.top);
|
||||
this.k.offsetTo(a.x, a.y);
|
||||
boolean c = this.i.c((SuperControlView) this);
|
||||
LogUtils.c("isOverlap:" + c);
|
||||
if (c) {
|
||||
b(this.o, this.p);
|
||||
this.b.setColor(this.D.getResources().getColor(this.a));
|
||||
} else {
|
||||
b(a.x, a.y);
|
||||
this.i.a(this, this.H.centerX(), this.H.centerY());
|
||||
}
|
||||
this.i.c((View) this);
|
||||
if (System.currentTimeMillis() - this.t < 350) {
|
||||
this.i.a(this, getData());
|
||||
}
|
||||
}
|
||||
b(false);
|
||||
return;
|
||||
}
|
||||
a(motionEvent);
|
||||
if (this.W > 0.0f) {
|
||||
f();
|
||||
}
|
||||
ControlTouchEvent controlTouchEvent = this.i;
|
||||
if (controlTouchEvent != null) {
|
||||
controlTouchEvent.b((SuperControlView) this);
|
||||
}
|
||||
}
|
||||
|
||||
public void a(MotionEvent motionEvent) {
|
||||
if (this.i0 == null) {
|
||||
return;
|
||||
}
|
||||
if (motionEvent.getAction() != 1 && motionEvent.getAction() != 3) {
|
||||
if (motionEvent.getAction() == 2) {
|
||||
this.i0.b(this.W * 100.0f, getData());
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
this.i0.a(this.W * 100.0f, getData());
|
||||
}
|
||||
|
||||
private void b(RectF rectF) {
|
||||
float centerX = rectF.centerX();
|
||||
float centerY = rectF.centerY();
|
||||
RectF rectF2 = this.I;
|
||||
float f = this.N;
|
||||
float f2 = this.O;
|
||||
rectF2.set(centerX - (f / 2.0f), centerY - (f2 / 2.0f), (f / 2.0f) + centerX, (f2 / 2.0f) + centerY);
|
||||
float f3 = this.O;
|
||||
float f4 = (f3 / 2.0f) + centerY;
|
||||
float f5 = centerY - (f3 / 2.0f);
|
||||
RectF rectF3 = this.J;
|
||||
float f6 = this.N;
|
||||
rectF3.set(centerX - (f6 / 2.0f), f4 - f6, (f6 / 2.0f) + centerX, f4);
|
||||
RectF rectF4 = this.L;
|
||||
float f7 = this.N;
|
||||
rectF4.set(centerX - (f7 / 2.0f), 0.0f, (f7 / 2.0f) + centerY, 0.0f);
|
||||
RectF rectF5 = this.K;
|
||||
float f8 = this.N;
|
||||
rectF5.set(centerX - (f8 / 2.0f), f5, (f8 / 2.0f) + centerX, f8 + f5);
|
||||
float f9 = centerY - (this.Q / 2.0f);
|
||||
RectF rectF6 = this.M;
|
||||
float f10 = this.P;
|
||||
rectF6.set(centerX - (f10 / 2.0f), f9 - (f10 / 2.0f), centerX + (f10 / 2.0f), f9 + (f10 / 2.0f));
|
||||
}
|
||||
}
|
||||
69
sources/com/ubt/jimu/controller/data/action/Action.java
Normal file
69
sources/com/ubt/jimu/controller/data/action/Action.java
Normal file
@@ -0,0 +1,69 @@
|
||||
package com.ubt.jimu.controller.data.action;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Action {
|
||||
private int a;
|
||||
private int b;
|
||||
private int c;
|
||||
private Map<Integer, Integer> d;
|
||||
private Map<Integer, TurnData> e;
|
||||
private Map<Integer, MotorData> f;
|
||||
|
||||
public void a(int i) {
|
||||
this.a = i;
|
||||
}
|
||||
|
||||
public void a(List<Integer> list) {
|
||||
}
|
||||
|
||||
public void b(int i) {
|
||||
this.b = i;
|
||||
}
|
||||
|
||||
public void c(int i) {
|
||||
this.c = i;
|
||||
}
|
||||
|
||||
public int d() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
public Map<Integer, TurnData> e() {
|
||||
return this.e;
|
||||
}
|
||||
|
||||
public int f() {
|
||||
return this.c;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "Action{index=" + this.a + ", sportTime=" + this.b + ", waitTime=" + this.c + ", rotas=" + this.d + ", turns=" + this.e + ", motors=" + this.f + '}';
|
||||
}
|
||||
|
||||
public void a(Map<Integer, MotorData> map) {
|
||||
this.f = map;
|
||||
}
|
||||
|
||||
public void b(Map<Integer, Integer> map) {
|
||||
this.d = map;
|
||||
}
|
||||
|
||||
public Map<Integer, Integer> c() {
|
||||
return this.d;
|
||||
}
|
||||
|
||||
public int a() {
|
||||
return this.c + this.b;
|
||||
}
|
||||
|
||||
public Map<Integer, MotorData> b() {
|
||||
return this.f;
|
||||
}
|
||||
|
||||
public void c(Map<Integer, TurnData> map) {
|
||||
this.e = map;
|
||||
}
|
||||
}
|
||||
14
sources/com/ubt/jimu/controller/data/action/ActionIcon.java
Normal file
14
sources/com/ubt/jimu/controller/data/action/ActionIcon.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package com.ubt.jimu.controller.data.action;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ActionIcon {
|
||||
private int a;
|
||||
|
||||
public ActionIcon(String str, int i) {
|
||||
this.a = i;
|
||||
}
|
||||
|
||||
public int a() {
|
||||
return this.a;
|
||||
}
|
||||
}
|
||||
210
sources/com/ubt/jimu/controller/data/action/ActionSequence.java
Normal file
210
sources/com/ubt/jimu/controller/data/action/ActionSequence.java
Normal file
@@ -0,0 +1,210 @@
|
||||
package com.ubt.jimu.controller.data.action;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.SparseArray;
|
||||
import com.ubt.jimu.base.data.Engine;
|
||||
import com.ubt.jimu.base.data.Motor;
|
||||
import com.ubt.jimu.base.data.Servo;
|
||||
import com.ubt.jimu.base.data.ServoMode;
|
||||
import com.ubt.jimu.controller.data.widget.JockstickDataConverter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ActionSequence {
|
||||
private static final HashMap<String, Integer> k = new HashMap<>();
|
||||
private String a;
|
||||
private String b;
|
||||
private String c;
|
||||
private List<Action> d;
|
||||
private String e;
|
||||
private SparseArray<String> f;
|
||||
private long g;
|
||||
private boolean h = false;
|
||||
private int i;
|
||||
private String j;
|
||||
|
||||
static {
|
||||
k.put(Locale.CHINESE.getLanguage(), 0);
|
||||
k.put("zh-hans", 0);
|
||||
k.put(Locale.ENGLISH.getLanguage(), 1);
|
||||
k.put(Locale.JAPANESE.getLanguage(), 2);
|
||||
k.put(Locale.KOREAN.getLanguage(), 3);
|
||||
k.put(Locale.GERMAN.getLanguage(), 4);
|
||||
k.put(Locale.ITALIAN.getLanguage(), 5);
|
||||
k.put(Locale.FRENCH.getLanguage(), 6);
|
||||
k.put("es", 7);
|
||||
k.put("pt", 8);
|
||||
k.put("zh-hant", 9);
|
||||
k.put("ar", 10);
|
||||
k.put("ru", 11);
|
||||
k.put("pl", 12);
|
||||
k.put("tr", 13);
|
||||
k.put("da", 14);
|
||||
k.put("th", 15);
|
||||
k.put(JockstickDataConverter.ID, 16);
|
||||
}
|
||||
|
||||
public void a(int i) {
|
||||
this.i = i;
|
||||
}
|
||||
|
||||
public void b(String str) {
|
||||
this.e = str;
|
||||
}
|
||||
|
||||
public void c(String str) {
|
||||
this.c = str;
|
||||
}
|
||||
|
||||
public int d() {
|
||||
return this.i;
|
||||
}
|
||||
|
||||
public void e(String str) {
|
||||
this.a = str;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof ActionSequence)) {
|
||||
return false;
|
||||
}
|
||||
ActionSequence actionSequence = (ActionSequence) obj;
|
||||
String str = this.a;
|
||||
if (str == null ? actionSequence.a != null : !str.equals(actionSequence.a)) {
|
||||
return false;
|
||||
}
|
||||
String str2 = this.c;
|
||||
String str3 = actionSequence.c;
|
||||
return str2 != null ? str2.equals(str3) : str3 == null;
|
||||
}
|
||||
|
||||
public void f(String str) {
|
||||
this.b = str;
|
||||
}
|
||||
|
||||
public String g() {
|
||||
return this.j;
|
||||
}
|
||||
|
||||
public String h() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
String str = this.a;
|
||||
int hashCode = (str != null ? str.hashCode() : 0) * 31;
|
||||
String str2 = this.c;
|
||||
return hashCode + (str2 != null ? str2.hashCode() : 0);
|
||||
}
|
||||
|
||||
public List<Servo> i() {
|
||||
List<Action> list = this.d;
|
||||
if (list == null || list.size() <= 0) {
|
||||
return null;
|
||||
}
|
||||
HashMap hashMap = new HashMap();
|
||||
Iterator<Action> it = this.d.iterator();
|
||||
while (it.hasNext()) {
|
||||
Map<Integer, TurnData> e = it.next().e();
|
||||
if (e != null && e.size() > 0) {
|
||||
Iterator<Integer> it2 = e.keySet().iterator();
|
||||
while (it2.hasNext()) {
|
||||
int intValue = it2.next().intValue();
|
||||
hashMap.put(Integer.valueOf(intValue), new Servo(intValue, ServoMode.SERVO_MODE_TURN));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hashMap.size() > 0) {
|
||||
return new ArrayList(hashMap.values());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean j() {
|
||||
return this.h;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "ActionSequence{name='" + this.a + "', robotID='" + this.b + "', id='" + this.c + "', actions=" + this.d + ", icon='" + this.e + "', showName=" + this.f + ", createTime=" + this.g + ", isOfficial=" + this.h + ", iconResID=" + this.i + ", musicPath='" + this.j + "'}";
|
||||
}
|
||||
|
||||
public List<Action> a() {
|
||||
return this.d;
|
||||
}
|
||||
|
||||
public long b() {
|
||||
return this.g;
|
||||
}
|
||||
|
||||
public String c() {
|
||||
return this.e;
|
||||
}
|
||||
|
||||
public void d(String str) {
|
||||
this.j = str;
|
||||
}
|
||||
|
||||
public String e() {
|
||||
return this.c;
|
||||
}
|
||||
|
||||
public List<Engine> f() {
|
||||
List<Action> list = this.d;
|
||||
if (list == null || list.size() <= 0) {
|
||||
return null;
|
||||
}
|
||||
HashMap hashMap = new HashMap();
|
||||
Iterator<Action> it = this.d.iterator();
|
||||
while (it.hasNext()) {
|
||||
Map<Integer, MotorData> b = it.next().b();
|
||||
if (b != null && b.size() > 0) {
|
||||
Iterator<Integer> it2 = b.keySet().iterator();
|
||||
while (it2.hasNext()) {
|
||||
int intValue = it2.next().intValue();
|
||||
hashMap.put(Integer.valueOf(intValue), new Motor(intValue));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hashMap.size() > 0) {
|
||||
return new ArrayList(hashMap.values());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void a(Action action) {
|
||||
if (this.d == null) {
|
||||
this.d = new ArrayList();
|
||||
}
|
||||
this.d.add(action);
|
||||
}
|
||||
|
||||
public void a(long j) {
|
||||
this.g = j;
|
||||
}
|
||||
|
||||
public void a(boolean z) {
|
||||
this.h = z;
|
||||
}
|
||||
|
||||
public void a(SparseArray<String> sparseArray) {
|
||||
this.f = sparseArray;
|
||||
}
|
||||
|
||||
public String a(String str) {
|
||||
SparseArray<String> sparseArray;
|
||||
Integer num = k.get(str);
|
||||
if (num == null || (sparseArray = this.f) == null) {
|
||||
return null;
|
||||
}
|
||||
String str2 = sparseArray.get(num.intValue());
|
||||
return TextUtils.isEmpty(str2) ? this.f.get(k.get(Locale.ENGLISH.getLanguage()).intValue()) : str2;
|
||||
}
|
||||
}
|
||||
31
sources/com/ubt/jimu/controller/data/action/MotorData.java
Normal file
31
sources/com/ubt/jimu/controller/data/action/MotorData.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package com.ubt.jimu.controller.data.action;
|
||||
|
||||
import com.twitter.sdk.android.core.TwitterAuthConfig;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class MotorData extends TurnData {
|
||||
private int c;
|
||||
|
||||
public MotorData(int i, int i2, int i3) {
|
||||
super(i, i2);
|
||||
this.c = i3;
|
||||
}
|
||||
|
||||
public static int e() {
|
||||
return TwitterAuthConfig.DEFAULT_AUTH_REQUEST_CODE;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.action.TurnData
|
||||
public boolean d() {
|
||||
return super.d() || this.c == 0;
|
||||
}
|
||||
|
||||
public int f() {
|
||||
return this.c;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.action.TurnData
|
||||
public String toString() {
|
||||
return super.toString() + " duration=" + this.c;
|
||||
}
|
||||
}
|
||||
77
sources/com/ubt/jimu/controller/data/action/RunningData.java
Normal file
77
sources/com/ubt/jimu/controller/data/action/RunningData.java
Normal file
@@ -0,0 +1,77 @@
|
||||
package com.ubt.jimu.controller.data.action;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class RunningData {
|
||||
private CopyOnWriteArrayList<RunningItem> a = new CopyOnWriteArrayList<>();
|
||||
|
||||
public synchronized void a(RunningItem runningItem) {
|
||||
if (runningItem == null) {
|
||||
return;
|
||||
}
|
||||
if (this.a.size() > 0) {
|
||||
Iterator<RunningItem> it = this.a.iterator();
|
||||
while (it.hasNext()) {
|
||||
RunningItem next = it.next();
|
||||
if (runningItem.b().equals(next.b()) && runningItem.a() == next.a()) {
|
||||
next.b(runningItem.c());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.a.add(runningItem);
|
||||
}
|
||||
|
||||
public synchronized boolean b(RunningItem runningItem) {
|
||||
if (runningItem == null) {
|
||||
return false;
|
||||
}
|
||||
int i = -1;
|
||||
int i2 = 0;
|
||||
while (true) {
|
||||
if (i2 >= this.a.size()) {
|
||||
break;
|
||||
}
|
||||
RunningItem runningItem2 = this.a.get(i2);
|
||||
if (runningItem.b().equals(runningItem2.b()) && runningItem.a() == runningItem2.a()) {
|
||||
i = i2;
|
||||
break;
|
||||
}
|
||||
i2++;
|
||||
}
|
||||
if (i < 0) {
|
||||
return false;
|
||||
}
|
||||
this.a.remove(i);
|
||||
return true;
|
||||
}
|
||||
|
||||
public synchronized boolean a(long j) {
|
||||
boolean z;
|
||||
z = true;
|
||||
if (this.a != null && this.a.size() > 0) {
|
||||
CopyOnWriteArrayList copyOnWriteArrayList = new CopyOnWriteArrayList();
|
||||
Iterator<RunningItem> it = this.a.iterator();
|
||||
while (it.hasNext()) {
|
||||
RunningItem next = it.next();
|
||||
if (next.a(j)) {
|
||||
copyOnWriteArrayList.add(next);
|
||||
} else {
|
||||
z = false;
|
||||
}
|
||||
}
|
||||
if (copyOnWriteArrayList.size() > 0) {
|
||||
this.a.removeAll(copyOnWriteArrayList);
|
||||
}
|
||||
}
|
||||
return z;
|
||||
}
|
||||
|
||||
public synchronized void a() {
|
||||
if (this.a != null) {
|
||||
this.a.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
38
sources/com/ubt/jimu/controller/data/action/RunningItem.java
Normal file
38
sources/com/ubt/jimu/controller/data/action/RunningItem.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package com.ubt.jimu.controller.data.action;
|
||||
|
||||
import com.ubt.jimu.base.data.CtrlMotionType;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class RunningItem {
|
||||
private int a;
|
||||
private CtrlMotionType b;
|
||||
private long c;
|
||||
private long d;
|
||||
|
||||
public RunningItem(int i, CtrlMotionType ctrlMotionType, long j, long j2) {
|
||||
this.a = i;
|
||||
this.b = ctrlMotionType;
|
||||
this.c = j;
|
||||
this.d = j2;
|
||||
}
|
||||
|
||||
public boolean a(long j) {
|
||||
return j - this.d > this.c;
|
||||
}
|
||||
|
||||
public CtrlMotionType b() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
public long c() {
|
||||
return this.d;
|
||||
}
|
||||
|
||||
public int a() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
public void b(long j) {
|
||||
this.d = j;
|
||||
}
|
||||
}
|
||||
45
sources/com/ubt/jimu/controller/data/action/TurnData.java
Normal file
45
sources/com/ubt/jimu/controller/data/action/TurnData.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package com.ubt.jimu.controller.data.action;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class TurnData {
|
||||
private int a;
|
||||
private int b;
|
||||
|
||||
public TurnData(int i, int i2) {
|
||||
this.a = i;
|
||||
this.b = i2;
|
||||
}
|
||||
|
||||
public static int e() {
|
||||
return 658;
|
||||
}
|
||||
|
||||
public int a() {
|
||||
if (b() == 0) {
|
||||
return 0;
|
||||
}
|
||||
if (b() == 1) {
|
||||
return c();
|
||||
}
|
||||
if (b() == -1) {
|
||||
return -c();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int b() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
public int c() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
public boolean d() {
|
||||
return this.b * this.a == 0;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "TurnData{direction=" + this.a + ", speed=" + this.b + '}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.ubt.jimu.controller.data.bean;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AddDirectionItemBean {
|
||||
private int a;
|
||||
private String b;
|
||||
private ItemType c;
|
||||
|
||||
public enum ItemType {
|
||||
TOW_WHEEL,
|
||||
FOUR_WHEEL,
|
||||
H_SLIDER,
|
||||
V_SLIDER,
|
||||
ACCUMULATOR,
|
||||
SIX_WHEEL
|
||||
}
|
||||
|
||||
public int a() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
public String b() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
public ItemType c() {
|
||||
return this.c;
|
||||
}
|
||||
|
||||
public void a(int i) {
|
||||
this.a = i;
|
||||
}
|
||||
|
||||
public void a(String str) {
|
||||
this.b = str;
|
||||
}
|
||||
|
||||
public void a(ItemType itemType) {
|
||||
this.c = itemType;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.ubt.jimu.controller.data.command;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AccumulatorGear {
|
||||
public static int a(float f, int i) {
|
||||
float f2;
|
||||
float f3;
|
||||
float f4;
|
||||
float f5;
|
||||
float f6;
|
||||
float f7;
|
||||
if (f < 0.2f) {
|
||||
return 0;
|
||||
}
|
||||
float f8 = 0.4f;
|
||||
if (f >= 0.4f) {
|
||||
if (0.4f > f || f >= 0.6f) {
|
||||
f8 = 0.8f;
|
||||
if (0.6f > f || f >= 0.8f) {
|
||||
f2 = i;
|
||||
f3 = 384.0f;
|
||||
f4 = 96.0f;
|
||||
} else {
|
||||
f2 = i;
|
||||
f5 = 320.0f;
|
||||
f6 = (f - 0.6f) * 64.0f;
|
||||
}
|
||||
} else {
|
||||
f2 = i;
|
||||
f3 = 274.0f;
|
||||
f4 = 46.0f;
|
||||
}
|
||||
f7 = (((f - f8) * f4) / 0.2f) + f3;
|
||||
return (int) ((f2 / f7) * 1000.0f);
|
||||
}
|
||||
f2 = i;
|
||||
f5 = 192.0f;
|
||||
f6 = (f - 0.2f) * 82.0f;
|
||||
f7 = (f6 / 0.2f) + f5;
|
||||
return (int) ((f2 / f7) * 1000.0f);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
package com.ubt.jimu.controller.data.command;
|
||||
|
||||
import android.media.MediaPlayer;
|
||||
import android.os.SystemClock;
|
||||
import android.text.TextUtils;
|
||||
import com.ubt.jimu.base.data.CtrlMotionType;
|
||||
import com.ubt.jimu.controller.data.action.Action;
|
||||
import com.ubt.jimu.controller.data.action.ActionSequence;
|
||||
import com.ubt.jimu.controller.data.action.MotorData;
|
||||
import com.ubt.jimu.controller.data.action.RunningData;
|
||||
import com.ubt.jimu.controller.data.action.RunningItem;
|
||||
import com.ubt.jimu.controller.data.action.TurnData;
|
||||
import com.ubt.jimu.controller.manager.ICommandExecutor;
|
||||
import com.ubtech.utils.XLog;
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ActionSequenceTask implements Runnable {
|
||||
private ActionSequence a;
|
||||
private ICommandExecutor b;
|
||||
private MediaPlayer c;
|
||||
private volatile boolean e = false;
|
||||
private volatile boolean f = false;
|
||||
private volatile boolean g = true;
|
||||
private RunningData d = new RunningData();
|
||||
|
||||
public ActionSequenceTask(ActionSequence actionSequence, ICommandExecutor iCommandExecutor) {
|
||||
this.a = actionSequence;
|
||||
this.b = iCommandExecutor;
|
||||
}
|
||||
|
||||
private void a(Map<Integer, ? extends TurnData> map) {
|
||||
if (map == null || map.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||
Iterator<Integer> it = map.keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
int intValue = it.next().intValue();
|
||||
TurnData turnData = map.get(Integer.valueOf(intValue));
|
||||
CtrlMotionType ctrlMotionType = CtrlMotionType.servo;
|
||||
long j = Long.MAX_VALUE;
|
||||
if (turnData instanceof MotorData) {
|
||||
ctrlMotionType = CtrlMotionType.motor;
|
||||
j = ((MotorData) turnData).f();
|
||||
}
|
||||
if (turnData.d()) {
|
||||
this.d.b(new RunningItem(intValue, ctrlMotionType, j, elapsedRealtime));
|
||||
} else {
|
||||
this.d.a(new RunningItem(intValue, ctrlMotionType, j, elapsedRealtime));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void b() {
|
||||
if (this.c != null) {
|
||||
this.c.stop();
|
||||
this.c.release();
|
||||
this.c = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
this.g = false;
|
||||
this.f = true;
|
||||
b();
|
||||
this.d.a();
|
||||
}
|
||||
|
||||
public boolean g() {
|
||||
boolean a = this.d.a(SystemClock.elapsedRealtime());
|
||||
XLog.a("Controller", "mIsComplete:%b, mIsCancel:%b, runningData.isAllComplete:%b ", Boolean.valueOf(this.e), Boolean.valueOf(this.f), Boolean.valueOf(a));
|
||||
return this.f || (this.e && a);
|
||||
}
|
||||
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
while (!this.f) {
|
||||
if (!TextUtils.isEmpty(this.a.g())) {
|
||||
a(this.a.g());
|
||||
}
|
||||
List<Action> a = this.a.a();
|
||||
if (a != null && a.size() > 0) {
|
||||
Iterator<Action> it = a.iterator();
|
||||
while (true) {
|
||||
if (!it.hasNext()) {
|
||||
break;
|
||||
}
|
||||
Action next = it.next();
|
||||
if (!this.f) {
|
||||
Map<Integer, MotorData> b = next.b();
|
||||
if (b != null && b.size() > 0) {
|
||||
a(b);
|
||||
this.b.a(new TreeMap(b));
|
||||
}
|
||||
Map<Integer, TurnData> e = next.e();
|
||||
if (e != null && e.size() > 0) {
|
||||
a(e);
|
||||
this.b.b(new TreeMap(e));
|
||||
}
|
||||
Map<Integer, Integer> c = next.c();
|
||||
if (c != null && c.size() > 0 && this.b.a(new TreeMap(c), next.d(), next.f()) == -1) {
|
||||
this.f = true;
|
||||
this.g = false;
|
||||
break;
|
||||
} else {
|
||||
try {
|
||||
Thread.sleep(next.a());
|
||||
} catch (InterruptedException e2) {
|
||||
e2.printStackTrace();
|
||||
this.f = true;
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!this.g) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.e = true;
|
||||
}
|
||||
|
||||
private synchronized void a(String str) {
|
||||
this.c = new MediaPlayer();
|
||||
try {
|
||||
this.c.setDataSource(str);
|
||||
this.c.prepare();
|
||||
this.c.start();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void a(boolean z) {
|
||||
this.g = z;
|
||||
}
|
||||
|
||||
public ActionSequence a() {
|
||||
return this.a;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.ubt.jimu.controller.data.command;
|
||||
|
||||
import com.ubt.jimu.controller.manager.ICommandExecutor;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AngleCommand extends MoveCommand {
|
||||
private Map<Integer, Integer> a;
|
||||
private int b;
|
||||
private int c;
|
||||
|
||||
public AngleCommand(Map<Integer, Integer> map, int i, int i2) {
|
||||
this.c = i;
|
||||
this.a = map;
|
||||
this.b = i2;
|
||||
}
|
||||
|
||||
public int a() {
|
||||
return this.c;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.command.MoveCommand
|
||||
public void a(ICommandExecutor iCommandExecutor) {
|
||||
iCommandExecutor.a(this.a, a(), this.b);
|
||||
}
|
||||
}
|
||||
36
sources/com/ubt/jimu/controller/data/command/Gear.java
Normal file
36
sources/com/ubt/jimu/controller/data/command/Gear.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package com.ubt.jimu.controller.data.command;
|
||||
|
||||
import com.twitter.sdk.android.core.TwitterAuthConfig;
|
||||
import com.ubtrobot.jimu.robotapi.PeripheralType;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public enum Gear {
|
||||
EMPTY(0, PeripheralType.SERVO, 0),
|
||||
FIRST(1, 234, 60),
|
||||
SECOND(2, 340, 80),
|
||||
THIRD(3, 446, 100),
|
||||
FOURTH(4, 552, 120),
|
||||
FIFTH(5, 658, TwitterAuthConfig.DEFAULT_AUTH_REQUEST_CODE);
|
||||
|
||||
private int level;
|
||||
private int motorSpeed;
|
||||
private int turnSpeed;
|
||||
|
||||
Gear(int i, int i2, int i3) {
|
||||
this.level = i;
|
||||
this.turnSpeed = i2;
|
||||
this.motorSpeed = i3;
|
||||
}
|
||||
|
||||
public static int getCount() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
public int getMotorSpeed() {
|
||||
return this.motorSpeed;
|
||||
}
|
||||
|
||||
public int getTurnSpeed() {
|
||||
return this.turnSpeed;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.ubt.jimu.controller.data.command;
|
||||
|
||||
import com.ubt.jimu.controller.data.action.MotorData;
|
||||
import com.ubt.jimu.controller.manager.ICommandExecutor;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class MotorCommand extends MoveCommand {
|
||||
private Map<Integer, MotorData> a;
|
||||
|
||||
public MotorCommand(Map<Integer, MotorData> map) {
|
||||
this.a = map;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.command.MoveCommand
|
||||
public void a(ICommandExecutor iCommandExecutor) {
|
||||
iCommandExecutor.a(this.a);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.ubt.jimu.controller.data.command;
|
||||
|
||||
import com.ubt.jimu.controller.manager.ICommandExecutor;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class MoveCommand {
|
||||
public abstract void a(ICommandExecutor iCommandExecutor);
|
||||
}
|
||||
19
sources/com/ubt/jimu/controller/data/command/MoveTask.java
Normal file
19
sources/com/ubt/jimu/controller/data/command/MoveTask.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package com.ubt.jimu.controller.data.command;
|
||||
|
||||
import com.ubt.jimu.controller.manager.ICommandExecutor;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class MoveTask implements Runnable {
|
||||
private MoveCommand a;
|
||||
private ICommandExecutor b;
|
||||
|
||||
public MoveTask(MoveCommand moveCommand, ICommandExecutor iCommandExecutor) {
|
||||
this.a = moveCommand;
|
||||
this.b = iCommandExecutor;
|
||||
}
|
||||
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
this.a.a(this.b);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.ubt.jimu.controller.data.command;
|
||||
|
||||
import com.ubt.jimu.controller.data.config.AccumulatorConfig;
|
||||
import com.ubt.jimu.controller.manager.ICommandExecutor;
|
||||
import java.util.HashMap;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ShootCommand extends MoveCommand {
|
||||
private AccumulatorConfig a;
|
||||
private int b;
|
||||
|
||||
public ShootCommand(AccumulatorConfig accumulatorConfig, int i) {
|
||||
this.a = accumulatorConfig;
|
||||
this.b = i;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.command.MoveCommand
|
||||
public void a(ICommandExecutor iCommandExecutor) {
|
||||
if (this.a != null) {
|
||||
HashMap hashMap = new HashMap(1);
|
||||
hashMap.put(Integer.valueOf(this.a.getServoID()), Integer.valueOf(this.a.getLaunchAngle() + 120));
|
||||
if (iCommandExecutor.a(hashMap, this.b, 0) == 0) {
|
||||
try {
|
||||
Thread.sleep(this.b);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
hashMap.put(Integer.valueOf(this.a.getServoID()), Integer.valueOf(this.a.getStartAngle() + 120));
|
||||
iCommandExecutor.a(hashMap, 100, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.ubt.jimu.controller.data.command;
|
||||
|
||||
import com.ubt.jimu.controller.data.action.TurnData;
|
||||
import com.ubt.jimu.controller.manager.ICommandExecutor;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class TurnCommand extends MoveCommand {
|
||||
private Map<Integer, TurnData> a;
|
||||
|
||||
public TurnCommand(Map<Integer, TurnData> map) {
|
||||
this.a = map;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.command.MoveCommand
|
||||
public void a(ICommandExecutor iCommandExecutor) {
|
||||
iCommandExecutor.b(this.a);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.ubt.jimu.controller.data.config;
|
||||
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import com.ubt.jimu.controller.data.widget.AccumulatorData;
|
||||
|
||||
@XStreamAlias("XLSliderConfig")
|
||||
/* loaded from: classes.dex */
|
||||
public class AccumulatorConfig extends WidgetConfig<AccumulatorData> {
|
||||
private int launchAngle;
|
||||
private int servoID;
|
||||
private int startAngle;
|
||||
|
||||
public AccumulatorConfig() {
|
||||
this.startAngle = WidgetConfig.MIN_ANGLE;
|
||||
this.launchAngle = 118;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof AccumulatorConfig)) {
|
||||
return false;
|
||||
}
|
||||
AccumulatorConfig accumulatorConfig = (AccumulatorConfig) obj;
|
||||
return this.servoID == accumulatorConfig.servoID && this.startAngle == accumulatorConfig.startAngle && this.launchAngle == accumulatorConfig.launchAngle;
|
||||
}
|
||||
|
||||
public int getLaunchAngle() {
|
||||
return this.launchAngle;
|
||||
}
|
||||
|
||||
public int getServoID() {
|
||||
return this.servoID;
|
||||
}
|
||||
|
||||
public int getStartAngle() {
|
||||
return this.startAngle;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return (((this.servoID * 31) + this.startAngle) * 31) + this.launchAngle;
|
||||
}
|
||||
|
||||
public void setLaunchAngle(int i) {
|
||||
this.launchAngle = i;
|
||||
}
|
||||
|
||||
public void setServoID(int i) {
|
||||
this.servoID = i;
|
||||
}
|
||||
|
||||
public void setStartAngle(int i) {
|
||||
this.startAngle = i;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.config.WidgetConfig
|
||||
public String toString() {
|
||||
return "AccumulatorConfig{servoID=" + this.servoID + ", startAngle=" + this.startAngle + ", launchAngle=" + this.launchAngle + "} " + super.toString();
|
||||
}
|
||||
|
||||
/* JADX WARN: Can't rename method to resolve collision */
|
||||
@Override // com.ubt.jimu.controller.data.config.WidgetConfig
|
||||
public AccumulatorData encapData() {
|
||||
AccumulatorData accumulatorData = new AccumulatorData();
|
||||
accumulatorData.setConfig(this);
|
||||
return accumulatorData;
|
||||
}
|
||||
|
||||
public AccumulatorConfig(String str, int i, int i2, int i3) {
|
||||
super(str);
|
||||
this.startAngle = WidgetConfig.MIN_ANGLE;
|
||||
this.launchAngle = 118;
|
||||
this.servoID = i;
|
||||
this.startAngle = i2;
|
||||
this.launchAngle = i3;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.ubt.jimu.controller.data.config;
|
||||
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import com.ubt.jimu.controller.data.widget.HSliderWidgetData;
|
||||
|
||||
@XStreamAlias("HSliderConfig")
|
||||
/* loaded from: classes.dex */
|
||||
public class HSliderConfig extends WidgetConfig<HSliderWidgetData> {
|
||||
private int maxAngle;
|
||||
private int minAngle;
|
||||
private int servoID;
|
||||
|
||||
public HSliderConfig() {
|
||||
this.minAngle = WidgetConfig.MIN_ANGLE;
|
||||
this.maxAngle = 118;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof HSliderConfig)) {
|
||||
return false;
|
||||
}
|
||||
HSliderConfig hSliderConfig = (HSliderConfig) obj;
|
||||
return this.servoID == hSliderConfig.servoID && this.minAngle == hSliderConfig.minAngle && this.maxAngle == hSliderConfig.maxAngle;
|
||||
}
|
||||
|
||||
public int getMaxAngle() {
|
||||
return this.maxAngle;
|
||||
}
|
||||
|
||||
public int getMinAngle() {
|
||||
return this.minAngle;
|
||||
}
|
||||
|
||||
public int getServoID() {
|
||||
return this.servoID;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return (((this.servoID * 31) + this.minAngle) * 31) + this.maxAngle;
|
||||
}
|
||||
|
||||
public void setMaxAngle(int i) {
|
||||
this.maxAngle = i;
|
||||
}
|
||||
|
||||
public void setMinAngle(int i) {
|
||||
this.minAngle = i;
|
||||
}
|
||||
|
||||
public void setServoID(int i) {
|
||||
this.servoID = i;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.config.WidgetConfig
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(" servoID=" + this.servoID);
|
||||
sb.append(" minAngle=" + this.minAngle);
|
||||
sb.append(" maxAngle=" + this.maxAngle);
|
||||
return super.toString() + sb.toString();
|
||||
}
|
||||
|
||||
/* JADX WARN: Can't rename method to resolve collision */
|
||||
@Override // com.ubt.jimu.controller.data.config.WidgetConfig
|
||||
public HSliderWidgetData encapData() {
|
||||
HSliderWidgetData hSliderWidgetData = new HSliderWidgetData();
|
||||
hSliderWidgetData.setConfig(this);
|
||||
return hSliderWidgetData;
|
||||
}
|
||||
|
||||
public HSliderConfig(String str, int i, int i2, int i3) {
|
||||
super(str);
|
||||
this.minAngle = WidgetConfig.MIN_ANGLE;
|
||||
this.maxAngle = 118;
|
||||
this.servoID = i;
|
||||
this.minAngle = i2;
|
||||
this.maxAngle = i3;
|
||||
}
|
||||
}
|
||||
293
sources/com/ubt/jimu/controller/data/config/JockstickConfig.java
Normal file
293
sources/com/ubt/jimu/controller/data/config/JockstickConfig.java
Normal file
@@ -0,0 +1,293 @@
|
||||
package com.ubt.jimu.controller.data.config;
|
||||
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import com.thoughtworks.xstream.annotations.XStreamImplicit;
|
||||
import com.thoughtworks.xstream.annotations.XStreamOmitField;
|
||||
import com.ubt.jimu.base.data.CtrlMotionType;
|
||||
import com.ubt.jimu.controller.data.widget.JockstickData;
|
||||
import com.ubt.jimu.controller.data.widget.JockstickDataConverter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@XStreamAlias("JockstickConfig")
|
||||
/* loaded from: classes.dex */
|
||||
public class JockstickConfig extends WidgetConfig<JockstickData> {
|
||||
private int index;
|
||||
|
||||
@XStreamOmitField
|
||||
private Map<Integer, Wheel> mTempWheelMap;
|
||||
private CtrlMotionType motionType;
|
||||
private JockType type;
|
||||
|
||||
@XStreamImplicit(itemFieldName = JockstickDataConverter.WHEEL)
|
||||
private List<Wheel> wheelList;
|
||||
|
||||
public enum JockType {
|
||||
twoServo,
|
||||
treeServo,
|
||||
fourServo,
|
||||
sixServo,
|
||||
none
|
||||
}
|
||||
|
||||
public JockstickConfig() {
|
||||
this.type = JockType.twoServo;
|
||||
this.motionType = CtrlMotionType.servo;
|
||||
}
|
||||
|
||||
static /* synthetic */ int a(Wheel wheel, Wheel wheel2) {
|
||||
if (wheel == null && wheel2 == null) {
|
||||
return 0;
|
||||
}
|
||||
if (wheel == null) {
|
||||
return -1;
|
||||
}
|
||||
if (wheel2 == null) {
|
||||
return 1;
|
||||
}
|
||||
return wheel.getPosition() - wheel2.getPosition();
|
||||
}
|
||||
|
||||
private boolean checkValid(int i) {
|
||||
List<Wheel> list = this.wheelList;
|
||||
if (list == null || list.size() < i) {
|
||||
return false;
|
||||
}
|
||||
for (Wheel wheel : this.wheelList) {
|
||||
if (wheel == null || wheel.getId() <= 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void copyList2Map(List<Wheel> list, Map<Integer, Wheel> map) {
|
||||
for (Wheel wheel : list) {
|
||||
if (wheel != null) {
|
||||
map.put(Integer.valueOf(wheel.getPosition()), wheel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void sortWheelList(List<Wheel> list) {
|
||||
Collections.sort(list, new Comparator() { // from class: com.ubt.jimu.controller.data.config.a
|
||||
@Override // java.util.Comparator
|
||||
public final int compare(Object obj, Object obj2) {
|
||||
return JockstickConfig.a((Wheel) obj, (Wheel) obj2);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void checkEngineExist(int i) {
|
||||
List<Wheel> list;
|
||||
if (i == 0 || (list = this.wheelList) == null || list.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
for (Wheel wheel : new ArrayList(this.wheelList)) {
|
||||
if (wheel != null && wheel.getId() == i) {
|
||||
this.wheelList.remove(wheel);
|
||||
this.mTempWheelMap.remove(Integer.valueOf(wheel.getPosition()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public JockstickConfig cloneJockstickConfig() {
|
||||
JockstickConfig jockstickConfig = new JockstickConfig();
|
||||
List<Wheel> list = this.wheelList;
|
||||
if (list != null && list.size() > 0) {
|
||||
ArrayList arrayList = new ArrayList(this.wheelList.size());
|
||||
Iterator<Wheel> it = this.wheelList.iterator();
|
||||
while (it.hasNext()) {
|
||||
arrayList.add(it.next());
|
||||
}
|
||||
jockstickConfig.setWheelList(arrayList);
|
||||
}
|
||||
jockstickConfig.setType(this.type);
|
||||
jockstickConfig.setMotionType(this.motionType);
|
||||
jockstickConfig.setIndex(this.index);
|
||||
return jockstickConfig;
|
||||
}
|
||||
|
||||
public void emptyWheelList() {
|
||||
List<Wheel> list = this.wheelList;
|
||||
if (list != null) {
|
||||
list.clear();
|
||||
}
|
||||
Map<Integer, Wheel> map = this.mTempWheelMap;
|
||||
if (map != null) {
|
||||
map.clear();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof JockstickConfig)) {
|
||||
return false;
|
||||
}
|
||||
JockstickConfig jockstickConfig = (JockstickConfig) obj;
|
||||
if (this.type != jockstickConfig.type || this.motionType != jockstickConfig.motionType) {
|
||||
return false;
|
||||
}
|
||||
List<Wheel> list = this.wheelList;
|
||||
if (list == null) {
|
||||
return jockstickConfig.wheelList == null;
|
||||
}
|
||||
sortWheelList(list);
|
||||
List<Wheel> list2 = jockstickConfig.wheelList;
|
||||
if (list2 == null) {
|
||||
return false;
|
||||
}
|
||||
sortWheelList(list2);
|
||||
return this.wheelList.equals(jockstickConfig.wheelList);
|
||||
}
|
||||
|
||||
public int getIndex() {
|
||||
return this.index;
|
||||
}
|
||||
|
||||
public CtrlMotionType getMotionType() {
|
||||
return this.motionType;
|
||||
}
|
||||
|
||||
public List<Integer> getServoList() {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
List<Wheel> list = this.wheelList;
|
||||
if (list != null && list.size() > 0) {
|
||||
for (Wheel wheel : this.wheelList) {
|
||||
if (wheel != null && wheel.getId() > 0) {
|
||||
arrayList.add(Integer.valueOf(wheel.getId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
public JockType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public Wheel getWheel(int i) {
|
||||
Map<Integer, Wheel> map;
|
||||
List<Wheel> list;
|
||||
if (this.mTempWheelMap == null && (list = this.wheelList) != null && list.size() > 0) {
|
||||
this.mTempWheelMap = new HashMap(this.wheelList.size());
|
||||
copyList2Map(this.wheelList, this.mTempWheelMap);
|
||||
}
|
||||
if (i <= 0 || (map = this.mTempWheelMap) == null) {
|
||||
return null;
|
||||
}
|
||||
return map.get(Integer.valueOf(i));
|
||||
}
|
||||
|
||||
public List<Wheel> getWheelList() {
|
||||
return this.wheelList;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
JockType jockType = this.type;
|
||||
int hashCode = (jockType != null ? jockType.hashCode() : 0) * 31;
|
||||
CtrlMotionType ctrlMotionType = this.motionType;
|
||||
int hashCode2 = (hashCode + (ctrlMotionType != null ? ctrlMotionType.hashCode() : 0)) * 31;
|
||||
List<Wheel> list = this.wheelList;
|
||||
return hashCode2 + (list != null ? list.hashCode() : 0);
|
||||
}
|
||||
|
||||
public boolean isOK() {
|
||||
JockType jockType = this.type;
|
||||
if (jockType == JockType.none) {
|
||||
return false;
|
||||
}
|
||||
if (jockType == JockType.twoServo) {
|
||||
return checkValid(2);
|
||||
}
|
||||
if (jockType == JockType.fourServo) {
|
||||
return checkValid(4);
|
||||
}
|
||||
if (jockType == JockType.sixServo) {
|
||||
return checkValid(6);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void putWheel(int i, Wheel wheel) {
|
||||
if (this.mTempWheelMap == null) {
|
||||
this.mTempWheelMap = new HashMap();
|
||||
}
|
||||
if (this.wheelList == null) {
|
||||
this.wheelList = new ArrayList();
|
||||
}
|
||||
if (i > 0) {
|
||||
this.mTempWheelMap.put(Integer.valueOf(i), wheel);
|
||||
List<Wheel> list = this.wheelList;
|
||||
if (list != null && list.size() > 0) {
|
||||
for (Wheel wheel2 : new ArrayList(this.wheelList)) {
|
||||
if (wheel2.getId() == wheel.getId() || wheel2.getPosition() == i) {
|
||||
this.wheelList.remove(wheel2);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.wheelList.add(wheel);
|
||||
}
|
||||
}
|
||||
|
||||
public void setIndex(int i) {
|
||||
this.index = i;
|
||||
}
|
||||
|
||||
public void setMotionType(CtrlMotionType ctrlMotionType) {
|
||||
this.motionType = ctrlMotionType;
|
||||
}
|
||||
|
||||
public void setType(JockType jockType) {
|
||||
this.type = jockType;
|
||||
}
|
||||
|
||||
public void setWheelList(List<Wheel> list) {
|
||||
this.wheelList = list;
|
||||
if (list == null || list.size() <= 0) {
|
||||
Map<Integer, Wheel> map = this.mTempWheelMap;
|
||||
if (map != null) {
|
||||
map.clear();
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (this.mTempWheelMap == null) {
|
||||
this.mTempWheelMap = new HashMap(list.size());
|
||||
for (Wheel wheel : list) {
|
||||
if (wheel != null) {
|
||||
this.mTempWheelMap.put(Integer.valueOf(wheel.getPosition()), wheel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.config.WidgetConfig
|
||||
public String toString() {
|
||||
return "JockstickConfig{type=" + this.type + ", motionType=" + this.motionType + ", index=" + this.index + ", wheelList=" + this.wheelList + "} " + super.toString();
|
||||
}
|
||||
|
||||
/* JADX WARN: Can't rename method to resolve collision */
|
||||
@Override // com.ubt.jimu.controller.data.config.WidgetConfig
|
||||
public JockstickData encapData() {
|
||||
JockstickData jockstickData = new JockstickData();
|
||||
jockstickData.setConfig(this);
|
||||
return jockstickData;
|
||||
}
|
||||
|
||||
public JockstickConfig(String str, JockType jockType, CtrlMotionType ctrlMotionType) {
|
||||
super(str);
|
||||
this.type = JockType.twoServo;
|
||||
this.motionType = CtrlMotionType.servo;
|
||||
this.motionType = ctrlMotionType;
|
||||
this.type = jockType;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.ubt.jimu.controller.data.config;
|
||||
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import com.ubt.jimu.base.data.CtrlMotionType;
|
||||
import com.ubt.jimu.controller.data.widget.SliderWidgetData;
|
||||
|
||||
@XStreamAlias("SliderConfig")
|
||||
/* loaded from: classes.dex */
|
||||
public class SliderConfig extends WidgetConfig<SliderWidgetData> {
|
||||
private boolean directionDisclock;
|
||||
private CtrlMotionType motionType;
|
||||
private int servoID;
|
||||
|
||||
public SliderConfig() {
|
||||
this.motionType = CtrlMotionType.servo;
|
||||
this.directionDisclock = false;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof SliderConfig)) {
|
||||
return false;
|
||||
}
|
||||
SliderConfig sliderConfig = (SliderConfig) obj;
|
||||
return this.servoID == sliderConfig.servoID && this.directionDisclock == sliderConfig.directionDisclock && this.motionType == sliderConfig.motionType;
|
||||
}
|
||||
|
||||
public CtrlMotionType getMotionType() {
|
||||
return this.motionType;
|
||||
}
|
||||
|
||||
public int getServoID() {
|
||||
return this.servoID;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
int i = this.servoID * 31;
|
||||
CtrlMotionType ctrlMotionType = this.motionType;
|
||||
return ((i + (ctrlMotionType != null ? ctrlMotionType.hashCode() : 0)) * 31) + (this.directionDisclock ? 1 : 0);
|
||||
}
|
||||
|
||||
public boolean isDirectionDisclock() {
|
||||
return this.directionDisclock;
|
||||
}
|
||||
|
||||
public void setDirectionDisclock(boolean z) {
|
||||
this.directionDisclock = z;
|
||||
}
|
||||
|
||||
public void setMotionType(CtrlMotionType ctrlMotionType) {
|
||||
this.motionType = ctrlMotionType;
|
||||
}
|
||||
|
||||
public void setServoID(int i) {
|
||||
this.servoID = i;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.config.WidgetConfig
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(" servoID= " + getServoID());
|
||||
sb.append(" motionType= " + getMotionType());
|
||||
sb.append(" directionDisclock= " + isDirectionDisclock());
|
||||
return super.toString() + sb.toString();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.config.WidgetConfig
|
||||
public SliderWidgetData encapData() {
|
||||
SliderWidgetData sliderWidgetData = new SliderWidgetData();
|
||||
sliderWidgetData.setConfig(this);
|
||||
return sliderWidgetData;
|
||||
}
|
||||
|
||||
public SliderConfig(String str, CtrlMotionType ctrlMotionType, int i, boolean z) {
|
||||
super(str);
|
||||
this.motionType = CtrlMotionType.servo;
|
||||
this.directionDisclock = false;
|
||||
this.servoID = i;
|
||||
this.motionType = ctrlMotionType;
|
||||
this.directionDisclock = z;
|
||||
}
|
||||
}
|
||||
73
sources/com/ubt/jimu/controller/data/config/Wheel.java
Normal file
73
sources/com/ubt/jimu/controller/data/config/Wheel.java
Normal file
@@ -0,0 +1,73 @@
|
||||
package com.ubt.jimu.controller.data.config;
|
||||
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
|
||||
import com.ubt.jimu.controller.data.widget.JockstickDataConverter;
|
||||
|
||||
@XStreamAlias(JockstickDataConverter.WHEEL)
|
||||
/* loaded from: classes.dex */
|
||||
public class Wheel {
|
||||
|
||||
@XStreamAsAttribute
|
||||
private int id;
|
||||
|
||||
@XStreamAsAttribute
|
||||
private int position;
|
||||
|
||||
@XStreamAsAttribute
|
||||
private boolean reverse;
|
||||
|
||||
public Wheel() {
|
||||
this.reverse = false;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof Wheel)) {
|
||||
return false;
|
||||
}
|
||||
Wheel wheel = (Wheel) obj;
|
||||
return this.id == wheel.id && this.position == wheel.position && this.reverse == wheel.reverse;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public int getPosition() {
|
||||
return this.position;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return (((this.id * 31) + this.position) * 31) + (this.reverse ? 1 : 0);
|
||||
}
|
||||
|
||||
public boolean isReverse() {
|
||||
return this.reverse;
|
||||
}
|
||||
|
||||
public void setId(int i) {
|
||||
this.id = i;
|
||||
}
|
||||
|
||||
public void setPosition(int i) {
|
||||
this.position = i;
|
||||
}
|
||||
|
||||
public void setReverse(boolean z) {
|
||||
this.reverse = z;
|
||||
}
|
||||
|
||||
public Wheel(int i, int i2) {
|
||||
this.reverse = false;
|
||||
this.id = i;
|
||||
this.position = i2;
|
||||
}
|
||||
|
||||
public Wheel(int i, int i2, boolean z) {
|
||||
this(i, i2);
|
||||
this.reverse = z;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.ubt.jimu.controller.data.config;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
|
||||
import com.ubt.jimu.controller.data.widget.MoveBaseData;
|
||||
import com.ubt.jimu.controller.util.IDGenerator;
|
||||
import java.io.Serializable;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class WidgetConfig<D extends MoveBaseData> implements Serializable {
|
||||
public static final int CUSTOM = 2;
|
||||
public static final int MAX_ANGLE = 118;
|
||||
public static final int MIN_ANGLE = -118;
|
||||
public static final int OFFICIAL = 1;
|
||||
|
||||
@XStreamAsAttribute
|
||||
private String configID;
|
||||
|
||||
@XStreamAsAttribute
|
||||
private int configType = 2;
|
||||
|
||||
@XStreamAsAttribute
|
||||
private long updateTime;
|
||||
|
||||
public WidgetConfig() {
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
this.configID = IDGenerator.a(currentTimeMillis);
|
||||
this.updateTime = currentTimeMillis;
|
||||
}
|
||||
|
||||
public abstract D encapData();
|
||||
|
||||
public String getConfigID() {
|
||||
return this.configID;
|
||||
}
|
||||
|
||||
public int getConfigType() {
|
||||
return this.configType;
|
||||
}
|
||||
|
||||
public long getUpdateTime() {
|
||||
return this.updateTime;
|
||||
}
|
||||
|
||||
public void setConfigID(String str) {
|
||||
this.configID = str;
|
||||
}
|
||||
|
||||
public void setConfigType(int i) {
|
||||
this.configType = i;
|
||||
}
|
||||
|
||||
public void setUpdateTime(long j) {
|
||||
this.updateTime = j;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(" configID=" + this.configID);
|
||||
sb.append(" configType=" + this.configType);
|
||||
sb.append(" updateTime=" + this.updateTime);
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public WidgetConfig(String str) {
|
||||
if (TextUtils.isEmpty(str)) {
|
||||
init();
|
||||
} else {
|
||||
this.configID = str;
|
||||
}
|
||||
}
|
||||
}
|
||||
19
sources/com/ubt/jimu/controller/data/keymap/ButtonKey.java
Normal file
19
sources/com/ubt/jimu/controller/data/keymap/ButtonKey.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package com.ubt.jimu.controller.data.keymap;
|
||||
|
||||
import com.ubt.jimu.controller.data.keymap.entity.Key;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ButtonKey extends Key {
|
||||
public ButtonKey(String str) {
|
||||
super(str, 1);
|
||||
}
|
||||
|
||||
public static ButtonKey a(int i) {
|
||||
for (PhysicalButton physicalButton : PhysicalButton.values()) {
|
||||
if (physicalButton.getKeyCode() == i) {
|
||||
return new ButtonKey(physicalButton.getName());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
10
sources/com/ubt/jimu/controller/data/keymap/JoyStick.java
Normal file
10
sources/com/ubt/jimu/controller/data/keymap/JoyStick.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.ubt.jimu.controller.data.keymap;
|
||||
|
||||
import com.ubt.jimu.controller.data.keymap.entity.Key;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class JoyStick extends Key {
|
||||
public JoyStick(String str) {
|
||||
super(str, 2);
|
||||
}
|
||||
}
|
||||
50
sources/com/ubt/jimu/controller/data/keymap/KeyMap.java
Normal file
50
sources/com/ubt/jimu/controller/data/keymap/KeyMap.java
Normal file
@@ -0,0 +1,50 @@
|
||||
package com.ubt.jimu.controller.data.keymap;
|
||||
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import com.thoughtworks.xstream.annotations.XStreamOmitField;
|
||||
import com.ubt.jimu.controller.data.keymap.entity.Key;
|
||||
|
||||
@XStreamAlias("KeyMap")
|
||||
/* loaded from: classes.dex */
|
||||
public class KeyMap {
|
||||
|
||||
@XStreamAlias("ActionId")
|
||||
private String a;
|
||||
|
||||
@XStreamAlias("Key")
|
||||
private String b;
|
||||
|
||||
@XStreamOmitField
|
||||
private int c;
|
||||
|
||||
public KeyMap() {
|
||||
this.c = 1;
|
||||
}
|
||||
|
||||
public String a() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
public String b() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
public int c() {
|
||||
return this.c;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "keyName:" + this.b + " actionId:" + this.a + "keyType:" + this.c;
|
||||
}
|
||||
|
||||
public void a(int i) {
|
||||
this.c = i;
|
||||
}
|
||||
|
||||
public KeyMap(Key key, String str) {
|
||||
this.c = 1;
|
||||
this.b = key.a();
|
||||
this.c = key.b();
|
||||
this.a = str;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.ubt.jimu.controller.data.keymap;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public enum PhysicalButton {
|
||||
A(96),
|
||||
B(97),
|
||||
X(99),
|
||||
Y(100),
|
||||
L1(102),
|
||||
L2(104),
|
||||
R1(103),
|
||||
R2(105),
|
||||
DPAD_UP(19),
|
||||
DPAD_DOWN(20),
|
||||
DPAD_LEFT(21),
|
||||
DPAD_RIGHT(22);
|
||||
|
||||
private int keyCode;
|
||||
|
||||
PhysicalButton(int i) {
|
||||
this.keyCode = i;
|
||||
}
|
||||
|
||||
public static PhysicalButton fromKeyCode(int i) {
|
||||
for (PhysicalButton physicalButton : values()) {
|
||||
if (physicalButton.getKeyCode() == i) {
|
||||
return physicalButton;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getKeyCode() {
|
||||
return this.keyCode;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.ubt.jimu.controller.data.keymap.entity;
|
||||
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import com.thoughtworks.xstream.annotations.XStreamImplicit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@XStreamAlias("GameControllerConfigData")
|
||||
/* loaded from: classes.dex */
|
||||
public class GameControllerConfigData {
|
||||
|
||||
@XStreamImplicit
|
||||
private List<KeyMapData> a = new ArrayList();
|
||||
|
||||
public List<KeyMapData> a() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
public void a(List<KeyMapData> list) {
|
||||
this.a = list;
|
||||
}
|
||||
}
|
||||
21
sources/com/ubt/jimu/controller/data/keymap/entity/Key.java
Normal file
21
sources/com/ubt/jimu/controller/data/keymap/entity/Key.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package com.ubt.jimu.controller.data.keymap.entity;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Key {
|
||||
private int a;
|
||||
private String b;
|
||||
|
||||
public Key(String str, int i) {
|
||||
this.a = 1;
|
||||
this.b = str;
|
||||
this.a = i;
|
||||
}
|
||||
|
||||
public String a() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
public int b() {
|
||||
return this.a;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.ubt.jimu.controller.data.keymap.entity;
|
||||
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import com.ubt.jimu.controller.data.keymap.KeyMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
@XStreamAlias("KeyMapData")
|
||||
/* loaded from: classes.dex */
|
||||
public class KeyMapData {
|
||||
|
||||
@XStreamAlias("ButtonKeyMap")
|
||||
private List<KeyMap> a = new ArrayList();
|
||||
|
||||
@XStreamAlias("JoystickKeyMap")
|
||||
private List<KeyMap> b = new ArrayList();
|
||||
|
||||
public List<KeyMap> a() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
public List<KeyMap> b() {
|
||||
Iterator<KeyMap> it = this.b.iterator();
|
||||
while (it.hasNext()) {
|
||||
it.next().a(2);
|
||||
}
|
||||
return this.b;
|
||||
}
|
||||
|
||||
public void a(List<KeyMap> list) {
|
||||
this.a = list;
|
||||
}
|
||||
|
||||
public void b(List<KeyMap> list) {
|
||||
this.b = list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.ubt.jimu.controller.data.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import com.thoughtworks.xstream.annotations.XStreamConverter;
|
||||
import com.thoughtworks.xstream.annotations.XStreamOmitField;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.controller.data.config.AccumulatorConfig;
|
||||
|
||||
@XStreamConverter(priority = 9999, value = AccumulatorDataConverter.class)
|
||||
/* loaded from: classes.dex */
|
||||
public class AccumulatorData extends MoveBaseData<AccumulatorConfig> {
|
||||
|
||||
@XStreamOmitField
|
||||
private AccumulatorConfig config;
|
||||
|
||||
public AccumulatorData() {
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.MoveBaseData
|
||||
public String getShowName(Context context) {
|
||||
return String.format(context.getResources().getString(R.string.servo_mode_servo_index), Integer.valueOf(getConfig().getServoID()));
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.ItemBaseData
|
||||
public String getWidgetInfo(Context context) {
|
||||
return String.format(context.getResources().getString(R.string.servo_mode_servo_index), Integer.valueOf(this.config.getServoID())) + "(" + this.config.getStartAngle() + "°~" + this.config.getLaunchAngle() + "°)";
|
||||
}
|
||||
|
||||
public AccumulatorData(String str) {
|
||||
super(str);
|
||||
}
|
||||
|
||||
/* JADX WARN: Can't rename method to resolve collision */
|
||||
@Override // com.ubt.jimu.controller.data.widget.MoveBaseData
|
||||
public AccumulatorConfig getConfig() {
|
||||
return this.config;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.MoveBaseData
|
||||
public void setConfig(AccumulatorConfig accumulatorConfig) {
|
||||
super.setConfig((AccumulatorData) accumulatorConfig);
|
||||
this.config = accumulatorConfig;
|
||||
}
|
||||
|
||||
public AccumulatorData(String str, float f, float f2) {
|
||||
super(str, f, f2);
|
||||
}
|
||||
|
||||
public AccumulatorData(String str, byte b, int i, int i2, float f, float f2) {
|
||||
super(str, f, f2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package com.ubt.jimu.controller.data.widget;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.thoughtworks.xstream.converters.Converter;
|
||||
import com.thoughtworks.xstream.converters.MarshallingContext;
|
||||
import com.thoughtworks.xstream.converters.UnmarshallingContext;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
|
||||
import com.ubt.jimu.controller.data.config.AccumulatorConfig;
|
||||
import com.ubtech.utils.XLog;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AccumulatorDataConverter implements Converter {
|
||||
public static final String CONFIG_ID = "configID";
|
||||
public static final String MAX_ANGLE = "max_angle";
|
||||
public static final String MIN_ANGLE = "min_angle";
|
||||
public static final String SERVO_ID = "servoID";
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.ConverterMatcher
|
||||
public boolean canConvert(Class cls) {
|
||||
return AccumulatorData.class.equals(cls);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.Converter
|
||||
public void marshal(Object obj, HierarchicalStreamWriter hierarchicalStreamWriter, MarshallingContext marshallingContext) {
|
||||
AccumulatorData accumulatorData = (AccumulatorData) obj;
|
||||
if (!TextUtils.isEmpty(accumulatorData.getWidgetId())) {
|
||||
hierarchicalStreamWriter.addAttribute("widgetId", accumulatorData.getWidgetId());
|
||||
}
|
||||
AccumulatorConfig config = accumulatorData.getConfig();
|
||||
if (config != null && !TextUtils.isEmpty(config.getConfigID())) {
|
||||
hierarchicalStreamWriter.addAttribute("configID", config.getConfigID());
|
||||
}
|
||||
hierarchicalStreamWriter.startNode("pos_x");
|
||||
hierarchicalStreamWriter.setValue(String.valueOf(accumulatorData.getPosX()));
|
||||
hierarchicalStreamWriter.endNode();
|
||||
hierarchicalStreamWriter.startNode("pos_y");
|
||||
hierarchicalStreamWriter.setValue(String.valueOf(accumulatorData.getPosY()));
|
||||
hierarchicalStreamWriter.endNode();
|
||||
}
|
||||
|
||||
/* JADX WARN: Failed to restore switch over string. Please report as a decompilation issue */
|
||||
@Override // com.thoughtworks.xstream.converters.Converter
|
||||
public Object unmarshal(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext) {
|
||||
String attribute = hierarchicalStreamReader.getAttribute("widgetId");
|
||||
if (TextUtils.isEmpty(attribute)) {
|
||||
attribute = hierarchicalStreamReader.getAttribute("widgetID");
|
||||
}
|
||||
AccumulatorData accumulatorData = new AccumulatorData(attribute);
|
||||
AccumulatorConfig accumulatorConfig = new AccumulatorConfig();
|
||||
String attribute2 = hierarchicalStreamReader.getAttribute("configID");
|
||||
if (!TextUtils.isEmpty(attribute2)) {
|
||||
accumulatorConfig.setConfigID(attribute2);
|
||||
}
|
||||
while (hierarchicalStreamReader.hasMoreChildren()) {
|
||||
hierarchicalStreamReader.moveDown();
|
||||
String nodeName = hierarchicalStreamReader.getNodeName();
|
||||
char c = 65535;
|
||||
switch (nodeName.hashCode()) {
|
||||
case -251140552:
|
||||
if (nodeName.equals("max_angle")) {
|
||||
c = 4;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 106854733:
|
||||
if (nodeName.equals("pos_x")) {
|
||||
c = 0;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 106854734:
|
||||
if (nodeName.equals("pos_y")) {
|
||||
c = 1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 521338022:
|
||||
if (nodeName.equals("min_angle")) {
|
||||
c = 3;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 1984158196:
|
||||
if (nodeName.equals("servoID")) {
|
||||
c = 2;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (c == 0) {
|
||||
accumulatorData.setPosX(Float.valueOf(hierarchicalStreamReader.getValue()).floatValue());
|
||||
} else if (c == 1) {
|
||||
accumulatorData.setPosY(Float.valueOf(hierarchicalStreamReader.getValue()).floatValue());
|
||||
} else if (c == 2) {
|
||||
Integer valueOf = Integer.valueOf(hierarchicalStreamReader.getValue());
|
||||
if (valueOf != null && valueOf.intValue() > 0) {
|
||||
accumulatorConfig.setServoID(valueOf.intValue());
|
||||
}
|
||||
} else if (c == 3) {
|
||||
accumulatorConfig.setStartAngle(Integer.valueOf(hierarchicalStreamReader.getValue()).intValue());
|
||||
} else if (c != 4) {
|
||||
XLog.b("woo", "Unknown node name : %s", hierarchicalStreamReader.getNodeName());
|
||||
} else {
|
||||
accumulatorConfig.setLaunchAngle(Integer.valueOf(hierarchicalStreamReader.getValue()).intValue());
|
||||
}
|
||||
hierarchicalStreamReader.moveUp();
|
||||
}
|
||||
accumulatorData.setConfig(accumulatorConfig);
|
||||
return accumulatorData;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.ubt.jimu.controller.data.widget;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.thoughtworks.xstream.converters.Converter;
|
||||
import com.thoughtworks.xstream.converters.MarshallingContext;
|
||||
import com.thoughtworks.xstream.converters.UnmarshallingContext;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
|
||||
import com.ubt.jimu.unity.bluetooth.UnityActivity;
|
||||
import com.ubtech.utils.XLog;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ActionDataConverter implements Converter {
|
||||
@Override // com.thoughtworks.xstream.converters.ConverterMatcher
|
||||
public boolean canConvert(Class cls) {
|
||||
return ActionWidgetData.class.equals(cls);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.Converter
|
||||
public void marshal(Object obj, HierarchicalStreamWriter hierarchicalStreamWriter, MarshallingContext marshallingContext) {
|
||||
ActionWidgetData actionWidgetData = (ActionWidgetData) obj;
|
||||
if (!TextUtils.isEmpty(actionWidgetData.getWidgetId())) {
|
||||
hierarchicalStreamWriter.addAttribute("widgetId", actionWidgetData.getWidgetId());
|
||||
}
|
||||
hierarchicalStreamWriter.startNode("pos_x");
|
||||
hierarchicalStreamWriter.setValue(String.valueOf(actionWidgetData.getPosX()));
|
||||
hierarchicalStreamWriter.endNode();
|
||||
hierarchicalStreamWriter.startNode("pos_y");
|
||||
hierarchicalStreamWriter.setValue(String.valueOf(actionWidgetData.getPosY()));
|
||||
hierarchicalStreamWriter.endNode();
|
||||
if (!TextUtils.isEmpty(actionWidgetData.getActionID())) {
|
||||
hierarchicalStreamWriter.startNode(ActionWidgetData.ACTION_ID);
|
||||
hierarchicalStreamWriter.setValue(String.valueOf(actionWidgetData.getActionID()));
|
||||
hierarchicalStreamWriter.endNode();
|
||||
}
|
||||
if (TextUtils.isEmpty(actionWidgetData.getActionNm())) {
|
||||
return;
|
||||
}
|
||||
hierarchicalStreamWriter.startNode(ActionWidgetData.ACTION_NM);
|
||||
hierarchicalStreamWriter.setValue(String.valueOf(actionWidgetData.getActionNm()));
|
||||
hierarchicalStreamWriter.endNode();
|
||||
}
|
||||
|
||||
/* JADX WARN: Failed to restore switch over string. Please report as a decompilation issue */
|
||||
@Override // com.thoughtworks.xstream.converters.Converter
|
||||
public Object unmarshal(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext) {
|
||||
String attribute = hierarchicalStreamReader.getAttribute("widgetId");
|
||||
if (TextUtils.isEmpty(attribute)) {
|
||||
attribute = hierarchicalStreamReader.getAttribute("widgetID");
|
||||
}
|
||||
ActionWidgetData actionWidgetData = new ActionWidgetData(attribute);
|
||||
while (hierarchicalStreamReader.hasMoreChildren()) {
|
||||
hierarchicalStreamReader.moveDown();
|
||||
String nodeName = hierarchicalStreamReader.getNodeName();
|
||||
char c = 65535;
|
||||
switch (nodeName.hashCode()) {
|
||||
case -1656172079:
|
||||
if (nodeName.equals(ActionWidgetData.ACTION_ID)) {
|
||||
c = 2;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case -1656172047:
|
||||
if (nodeName.equals(UnityActivity.KEY_ACTION_ID)) {
|
||||
c = 3;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case -1656171883:
|
||||
if (nodeName.equals(ActionWidgetData.ACTION_NM)) {
|
||||
c = 4;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 106854733:
|
||||
if (nodeName.equals("pos_x")) {
|
||||
c = 0;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 106854734:
|
||||
if (nodeName.equals("pos_y")) {
|
||||
c = 1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (c == 0) {
|
||||
actionWidgetData.setPosX(Float.valueOf(hierarchicalStreamReader.getValue()).floatValue());
|
||||
} else if (c == 1) {
|
||||
actionWidgetData.setPosY(Float.valueOf(hierarchicalStreamReader.getValue()).floatValue());
|
||||
} else if (c == 2) {
|
||||
actionWidgetData.setActionID(hierarchicalStreamReader.getValue());
|
||||
} else if (c == 3) {
|
||||
actionWidgetData.setActionID(hierarchicalStreamReader.getValue());
|
||||
} else if (c != 4) {
|
||||
XLog.b("woo", "Unknown node name : %s", hierarchicalStreamReader.getNodeName());
|
||||
} else {
|
||||
actionWidgetData.setActionNm(hierarchicalStreamReader.getValue());
|
||||
}
|
||||
hierarchicalStreamReader.moveUp();
|
||||
}
|
||||
return actionWidgetData;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package com.ubt.jimu.controller.data.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import com.thoughtworks.xstream.annotations.XStreamConverter;
|
||||
import com.thoughtworks.xstream.annotations.XStreamOmitField;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.controller.data.action.ActionSequence;
|
||||
import com.ubt.jimu.utils.LocaleUtils;
|
||||
|
||||
@XStreamAlias("actionData")
|
||||
@XStreamConverter(ActionDataConverter.class)
|
||||
/* loaded from: classes.dex */
|
||||
public class ActionWidgetData extends ItemBaseData {
|
||||
public static final String ACTION_ID = "actionID";
|
||||
public static final String ACTION_NM = "actionNm";
|
||||
private String actionID;
|
||||
private String actionNm;
|
||||
|
||||
@XStreamOmitField
|
||||
private ActionSequence actionSequence;
|
||||
|
||||
public ActionWidgetData() {
|
||||
}
|
||||
|
||||
public String getActionID() {
|
||||
return this.actionID;
|
||||
}
|
||||
|
||||
public String getActionNm() {
|
||||
return this.actionNm;
|
||||
}
|
||||
|
||||
public ActionSequence getActionSequence() {
|
||||
return this.actionSequence;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.ItemBaseData
|
||||
public int getImageViewId() {
|
||||
int d;
|
||||
ActionSequence actionSequence = this.actionSequence;
|
||||
return (actionSequence == null || (d = actionSequence.d()) <= 0) ? R.drawable.icon_loudly : d;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.ItemBaseData
|
||||
public String getShowName(String str) {
|
||||
ActionSequence actionSequence = this.actionSequence;
|
||||
if (actionSequence != null) {
|
||||
String a = actionSequence.a(str);
|
||||
if (!TextUtils.isEmpty(a)) {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
return this.actionNm;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.ItemBaseData
|
||||
public String getWidgetInfo(Context context) {
|
||||
return getShowName(LocaleUtils.b());
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.ItemBaseData
|
||||
public boolean isOfficial() {
|
||||
ActionSequence actionSequence = this.actionSequence;
|
||||
if (actionSequence != null) {
|
||||
return actionSequence.j();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setActionID(String str) {
|
||||
this.actionID = str;
|
||||
}
|
||||
|
||||
public void setActionNm(String str) {
|
||||
this.actionNm = str;
|
||||
}
|
||||
|
||||
public void setActionSequence(ActionSequence actionSequence) {
|
||||
this.actionSequence = actionSequence;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.ItemBaseData
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("ActionWidgetData: ");
|
||||
sb.append(" actionID: " + this.actionID);
|
||||
sb.append(" actionNm: " + this.actionNm);
|
||||
return super.toString() + " " + sb.toString();
|
||||
}
|
||||
|
||||
public ActionWidgetData(String str) {
|
||||
super(str);
|
||||
}
|
||||
|
||||
public ActionWidgetData(String str, String str2, String str3, float f, float f2) {
|
||||
super(str, f, f2);
|
||||
this.actionID = str2;
|
||||
this.actionNm = str3;
|
||||
}
|
||||
}
|
||||
27
sources/com/ubt/jimu/controller/data/widget/AddViewData.java
Normal file
27
sources/com/ubt/jimu/controller/data/widget/AddViewData.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package com.ubt.jimu.controller.data.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import com.ubt.jimu.controller.data.config.WidgetConfig;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AddViewData extends MoveBaseData {
|
||||
@Override // com.ubt.jimu.controller.data.widget.MoveBaseData
|
||||
public WidgetConfig getConfig() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.MoveBaseData
|
||||
public String getShowName(Context context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.ItemBaseData
|
||||
public String getWidgetInfo(Context context) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.MoveBaseData, com.ubt.jimu.controller.data.widget.ItemBaseData
|
||||
public boolean isOfficial() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
399
sources/com/ubt/jimu/controller/data/widget/ControllerData.java
Normal file
399
sources/com/ubt/jimu/controller/data/widget/ControllerData.java
Normal file
@@ -0,0 +1,399 @@
|
||||
package com.ubt.jimu.controller.data.widget;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.util.Size;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
|
||||
import com.thoughtworks.xstream.annotations.XStreamImplicit;
|
||||
import com.thoughtworks.xstream.annotations.XStreamOmitField;
|
||||
import com.ubt.jimu.controller.data.config.AccumulatorConfig;
|
||||
import com.ubt.jimu.controller.data.config.HSliderConfig;
|
||||
import com.ubt.jimu.controller.data.config.JockstickConfig;
|
||||
import com.ubt.jimu.controller.data.config.SliderConfig;
|
||||
import com.ubt.jimu.transport.model.TransportFile;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
@XStreamAlias(TransportFile.MODEL_CONTROLLER_DIR)
|
||||
/* loaded from: classes.dex */
|
||||
public class ControllerData {
|
||||
public static final int DEFAULT_SCREEN_HEIGHT = 750;
|
||||
public static final int DEFAULT_SCREEN_WIDTH = 1334;
|
||||
|
||||
@XStreamImplicit(itemFieldName = "xlsliderData")
|
||||
private List<AccumulatorData> accumulatorData;
|
||||
|
||||
@XStreamImplicit(itemFieldName = "actionData")
|
||||
private List<ActionWidgetData> actionData;
|
||||
|
||||
@XStreamAsAttribute
|
||||
private String controllerID;
|
||||
|
||||
@XStreamOmitField
|
||||
private Size displaySize;
|
||||
|
||||
@XStreamImplicit(itemFieldName = "hsliderData")
|
||||
private List<HSliderWidgetData> hsliderData;
|
||||
|
||||
@XStreamImplicit(itemFieldName = "jockstickData")
|
||||
private List<JockstickData> jockstickData;
|
||||
|
||||
@XStreamAlias("ScreenHeight")
|
||||
@XStreamAsAttribute
|
||||
private int screenHeight;
|
||||
|
||||
@XStreamAlias("ScreenWidth")
|
||||
@XStreamAsAttribute
|
||||
private int screenWidth;
|
||||
|
||||
@XStreamImplicit(itemFieldName = "sliderData")
|
||||
private List<SliderWidgetData> sliderData;
|
||||
|
||||
@XStreamOmitField
|
||||
private Size xmlSize;
|
||||
|
||||
public ControllerData() {
|
||||
this.screenWidth = DEFAULT_SCREEN_WIDTH;
|
||||
this.screenHeight = DEFAULT_SCREEN_HEIGHT;
|
||||
this.actionData = new ArrayList();
|
||||
this.sliderData = new ArrayList();
|
||||
this.hsliderData = new ArrayList();
|
||||
this.jockstickData = new ArrayList();
|
||||
this.accumulatorData = new ArrayList();
|
||||
}
|
||||
|
||||
private boolean hasMoveWidget() {
|
||||
List<HSliderWidgetData> list;
|
||||
List<JockstickData> list2;
|
||||
List<SliderWidgetData> list3 = this.sliderData;
|
||||
return (list3 != null && list3.size() > 0) || ((list = this.hsliderData) != null && list.size() > 0) || ((list2 = this.jockstickData) != null && list2.size() > 0);
|
||||
}
|
||||
|
||||
private boolean removeItem(String str, List<? extends ItemBaseData> list) {
|
||||
if (!TextUtils.isEmpty(str) && list != null && list.size() > 0) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
if (str.equals(list.get(i).getWidgetId())) {
|
||||
return list.remove(i) != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void transformInternal(List<? extends ItemBaseData> list, Size size, Size size2) {
|
||||
if (list == null || list.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
for (ItemBaseData itemBaseData : list) {
|
||||
itemBaseData.setDisplaySize(size, size2);
|
||||
itemBaseData.transform();
|
||||
}
|
||||
}
|
||||
|
||||
public void addAccumulatorData(AccumulatorData accumulatorData) {
|
||||
List<AccumulatorData> list = this.accumulatorData;
|
||||
if (list != null) {
|
||||
list.add(accumulatorData);
|
||||
}
|
||||
}
|
||||
|
||||
public void addActionData(ActionWidgetData actionWidgetData) {
|
||||
List<ActionWidgetData> list = this.actionData;
|
||||
if (list == null || actionWidgetData == null) {
|
||||
return;
|
||||
}
|
||||
list.add(actionWidgetData);
|
||||
}
|
||||
|
||||
public void addData(ItemBaseData itemBaseData) {
|
||||
if (itemBaseData == null) {
|
||||
return;
|
||||
}
|
||||
if (itemBaseData instanceof JockstickData) {
|
||||
Log.e("Test", "JockstickData:" + itemBaseData);
|
||||
addJockstickData((JockstickData) itemBaseData);
|
||||
}
|
||||
if (itemBaseData instanceof HSliderWidgetData) {
|
||||
addHsliderData((HSliderWidgetData) itemBaseData);
|
||||
Log.e("Test", "moveBaseData:" + itemBaseData);
|
||||
}
|
||||
if (itemBaseData instanceof SliderWidgetData) {
|
||||
addSliderData((SliderWidgetData) itemBaseData);
|
||||
}
|
||||
if (itemBaseData instanceof ActionWidgetData) {
|
||||
Log.e("Test", "保存动作");
|
||||
addActionData((ActionWidgetData) itemBaseData);
|
||||
}
|
||||
if (itemBaseData instanceof AccumulatorData) {
|
||||
addAccumulatorData((AccumulatorData) itemBaseData);
|
||||
}
|
||||
}
|
||||
|
||||
public void addHsliderData(HSliderWidgetData hSliderWidgetData) {
|
||||
List<HSliderWidgetData> list = this.hsliderData;
|
||||
if (list != null) {
|
||||
list.add(hSliderWidgetData);
|
||||
}
|
||||
}
|
||||
|
||||
public void addJockstickData(JockstickData jockstickData) {
|
||||
List<JockstickData> list = this.jockstickData;
|
||||
if (list != null) {
|
||||
list.add(jockstickData);
|
||||
}
|
||||
}
|
||||
|
||||
public void addSliderData(SliderWidgetData sliderWidgetData) {
|
||||
List<SliderWidgetData> list = this.sliderData;
|
||||
if (list == null || sliderWidgetData == null) {
|
||||
return;
|
||||
}
|
||||
list.add(sliderWidgetData);
|
||||
}
|
||||
|
||||
public boolean clearEmptyWidget() {
|
||||
List<JockstickData> list = this.jockstickData;
|
||||
boolean z = false;
|
||||
if (list != null && list.size() > 0) {
|
||||
for (JockstickData jockstickData : new ArrayList(this.jockstickData)) {
|
||||
JockstickConfig config = jockstickData.getConfig();
|
||||
if (config == null || config.getType() == JockstickConfig.JockType.none || config.getWheelList() == null || config.getWheelList().isEmpty()) {
|
||||
this.jockstickData.remove(jockstickData);
|
||||
z = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
List<SliderWidgetData> list2 = this.sliderData;
|
||||
if (list2 != null && list2.size() > 0) {
|
||||
for (SliderWidgetData sliderWidgetData : new ArrayList(this.sliderData)) {
|
||||
SliderConfig config2 = sliderWidgetData.getConfig();
|
||||
if (config2 == null || config2.getServoID() <= 0) {
|
||||
this.sliderData.remove(sliderWidgetData);
|
||||
z = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
List<HSliderWidgetData> list3 = this.hsliderData;
|
||||
if (list3 != null && list3.size() > 0) {
|
||||
for (HSliderWidgetData hSliderWidgetData : new ArrayList(this.hsliderData)) {
|
||||
HSliderConfig config3 = hSliderWidgetData.getConfig();
|
||||
if (config3 == null || config3.getServoID() <= 0) {
|
||||
this.hsliderData.remove(hSliderWidgetData);
|
||||
z = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
List<AccumulatorData> list4 = this.accumulatorData;
|
||||
if (list4 != null && list4.size() > 0) {
|
||||
for (AccumulatorData accumulatorData : new ArrayList(this.accumulatorData)) {
|
||||
AccumulatorConfig config4 = accumulatorData.getConfig();
|
||||
if (config4 == null || config4.getServoID() <= 0) {
|
||||
this.accumulatorData.remove(accumulatorData);
|
||||
z = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return z;
|
||||
}
|
||||
|
||||
public List<AccumulatorData> getAccumulatorData() {
|
||||
return this.accumulatorData;
|
||||
}
|
||||
|
||||
public List<ActionWidgetData> getActionData() {
|
||||
return this.actionData;
|
||||
}
|
||||
|
||||
public String getControllerID() {
|
||||
return this.controllerID;
|
||||
}
|
||||
|
||||
public List<HSliderWidgetData> getHsliderData() {
|
||||
return this.hsliderData;
|
||||
}
|
||||
|
||||
public List<JockstickData> getJockstickData() {
|
||||
return this.jockstickData;
|
||||
}
|
||||
|
||||
public MoveWidgetData getMoveConfig() {
|
||||
MoveWidgetData moveWidgetData;
|
||||
List<SliderWidgetData> list = this.sliderData;
|
||||
if (list == null || list.size() <= 0) {
|
||||
moveWidgetData = null;
|
||||
} else {
|
||||
ArrayList arrayList = new ArrayList(this.sliderData.size());
|
||||
Iterator<SliderWidgetData> it = this.sliderData.iterator();
|
||||
while (it.hasNext()) {
|
||||
arrayList.add(it.next().getConfig());
|
||||
}
|
||||
moveWidgetData = new MoveWidgetData();
|
||||
moveWidgetData.setSliderConfigList(arrayList);
|
||||
}
|
||||
List<HSliderWidgetData> list2 = this.hsliderData;
|
||||
if (list2 != null && list2.size() > 0) {
|
||||
ArrayList arrayList2 = new ArrayList(this.hsliderData.size());
|
||||
Iterator<HSliderWidgetData> it2 = this.hsliderData.iterator();
|
||||
while (it2.hasNext()) {
|
||||
arrayList2.add(it2.next().getConfig());
|
||||
}
|
||||
if (moveWidgetData == null) {
|
||||
moveWidgetData = new MoveWidgetData();
|
||||
}
|
||||
moveWidgetData.setHSliderConfigList(arrayList2);
|
||||
}
|
||||
List<JockstickData> list3 = this.jockstickData;
|
||||
if (list3 != null && list3.size() > 0) {
|
||||
ArrayList arrayList3 = new ArrayList(this.jockstickData.size());
|
||||
Iterator<JockstickData> it3 = this.jockstickData.iterator();
|
||||
while (it3.hasNext()) {
|
||||
arrayList3.add(it3.next().getConfig());
|
||||
}
|
||||
if (moveWidgetData == null) {
|
||||
moveWidgetData = new MoveWidgetData();
|
||||
}
|
||||
moveWidgetData.setJockstickConfigList(arrayList3);
|
||||
}
|
||||
List<AccumulatorData> list4 = this.accumulatorData;
|
||||
if (list4 != null && list4.size() > 0) {
|
||||
ArrayList arrayList4 = new ArrayList(this.accumulatorData.size());
|
||||
Iterator<AccumulatorData> it4 = this.accumulatorData.iterator();
|
||||
while (it4.hasNext()) {
|
||||
arrayList4.add(it4.next().getConfig());
|
||||
}
|
||||
if (moveWidgetData == null) {
|
||||
moveWidgetData = new MoveWidgetData();
|
||||
}
|
||||
moveWidgetData.setAccumulatorConfigList(arrayList4);
|
||||
}
|
||||
return moveWidgetData;
|
||||
}
|
||||
|
||||
public int getScreenHeight() {
|
||||
return this.screenHeight;
|
||||
}
|
||||
|
||||
public int getScreenWidth() {
|
||||
return this.screenWidth;
|
||||
}
|
||||
|
||||
public List<SliderWidgetData> getSliderData() {
|
||||
return this.sliderData;
|
||||
}
|
||||
|
||||
public float getTransformRatio() {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
public boolean hasAction() {
|
||||
return getActionData() != null && getActionData().size() > 0;
|
||||
}
|
||||
|
||||
public boolean removeAccumulatorData(String str) {
|
||||
return removeItem(str, this.accumulatorData);
|
||||
}
|
||||
|
||||
public boolean removeActionData(String str) {
|
||||
return removeItem(str, this.actionData);
|
||||
}
|
||||
|
||||
public boolean removeHsliderData(String str) {
|
||||
return removeItem(str, this.hsliderData);
|
||||
}
|
||||
|
||||
public boolean removeJockstickData(String str) {
|
||||
return removeItem(str, this.jockstickData);
|
||||
}
|
||||
|
||||
public boolean removeSliderData(String str) {
|
||||
return removeItem(str, this.sliderData);
|
||||
}
|
||||
|
||||
public void setAccumulatorData(List<AccumulatorData> list) {
|
||||
this.accumulatorData = list;
|
||||
}
|
||||
|
||||
public void setActionData(List<ActionWidgetData> list) {
|
||||
this.actionData = list;
|
||||
}
|
||||
|
||||
public void setControllerID(String str) {
|
||||
this.controllerID = str;
|
||||
}
|
||||
|
||||
public void setHsliderData(List<HSliderWidgetData> list) {
|
||||
this.hsliderData = list;
|
||||
}
|
||||
|
||||
public void setJockstickData(List<JockstickData> list) {
|
||||
this.jockstickData = list;
|
||||
}
|
||||
|
||||
public void setScreenHeight(int i) {
|
||||
this.screenHeight = i;
|
||||
}
|
||||
|
||||
public void setScreenWidth(int i) {
|
||||
this.screenWidth = i;
|
||||
}
|
||||
|
||||
public void setSliderData(List<SliderWidgetData> list) {
|
||||
this.sliderData = list;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("ControllerData: ");
|
||||
sb.append(" controllerID : " + this.controllerID);
|
||||
sb.append(" screenWidth: " + this.screenWidth);
|
||||
sb.append(" screenHeight" + this.screenHeight);
|
||||
StringBuilder sb2 = new StringBuilder();
|
||||
sb2.append(" actionData: ");
|
||||
List<ActionWidgetData> list = this.actionData;
|
||||
sb2.append(list != null ? list.toString() : "null");
|
||||
sb.append(sb2.toString());
|
||||
StringBuilder sb3 = new StringBuilder();
|
||||
sb3.append(" sliderData: ");
|
||||
List<SliderWidgetData> list2 = this.sliderData;
|
||||
sb3.append(list2 != null ? list2.toString() : "null");
|
||||
sb.append(sb3.toString());
|
||||
StringBuilder sb4 = new StringBuilder();
|
||||
sb4.append(" hsliderData: ");
|
||||
List<HSliderWidgetData> list3 = this.hsliderData;
|
||||
sb4.append(list3 != null ? list3.toString() : "null");
|
||||
sb.append(sb4.toString());
|
||||
StringBuilder sb5 = new StringBuilder();
|
||||
sb5.append(" jockstickData: ");
|
||||
List<JockstickData> list4 = this.jockstickData;
|
||||
sb5.append(list4 != null ? list4.toString() : "null");
|
||||
sb.append(sb5.toString());
|
||||
StringBuilder sb6 = new StringBuilder();
|
||||
sb6.append(" accumulatorData: ");
|
||||
List<AccumulatorData> list5 = this.accumulatorData;
|
||||
sb6.append(list5 != null ? list5.toString() : "null");
|
||||
sb.append(sb6.toString());
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public void transform(Size size, Size size2) {
|
||||
transformInternal(this.actionData, size, size2);
|
||||
transformInternal(this.jockstickData, size, size2);
|
||||
transformInternal(this.sliderData, size, size2);
|
||||
transformInternal(this.hsliderData, size, size2);
|
||||
transformInternal(this.accumulatorData, size, size2);
|
||||
}
|
||||
|
||||
public boolean removeActionData(ActionWidgetData actionWidgetData) {
|
||||
List<ActionWidgetData> list = this.actionData;
|
||||
if (list == null || list.size() <= 0) {
|
||||
return false;
|
||||
}
|
||||
return this.actionData.remove(actionWidgetData);
|
||||
}
|
||||
|
||||
public ControllerData(String str) {
|
||||
this();
|
||||
this.controllerID = str;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package com.ubt.jimu.controller.data.widget;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.thoughtworks.xstream.converters.Converter;
|
||||
import com.thoughtworks.xstream.converters.MarshallingContext;
|
||||
import com.thoughtworks.xstream.converters.UnmarshallingContext;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
|
||||
import com.ubt.jimu.controller.data.config.HSliderConfig;
|
||||
import com.ubtech.utils.XLog;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class HSliderDataConverter implements Converter {
|
||||
public static final String CONFIG_ID = "configID";
|
||||
public static final String MAX_ANGLE = "max_angle";
|
||||
public static final String MIN_ANGLE = "min_angle";
|
||||
public static final String SERVO_ID = "servoID";
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.ConverterMatcher
|
||||
public boolean canConvert(Class cls) {
|
||||
return HSliderWidgetData.class.equals(cls);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.Converter
|
||||
public void marshal(Object obj, HierarchicalStreamWriter hierarchicalStreamWriter, MarshallingContext marshallingContext) {
|
||||
HSliderWidgetData hSliderWidgetData = (HSliderWidgetData) obj;
|
||||
if (!TextUtils.isEmpty(hSliderWidgetData.getWidgetId())) {
|
||||
hierarchicalStreamWriter.addAttribute("widgetId", hSliderWidgetData.getWidgetId());
|
||||
}
|
||||
HSliderConfig config = hSliderWidgetData.getConfig();
|
||||
if (config != null && !TextUtils.isEmpty(config.getConfigID())) {
|
||||
hierarchicalStreamWriter.addAttribute("configID", config.getConfigID());
|
||||
}
|
||||
hierarchicalStreamWriter.startNode("pos_x");
|
||||
hierarchicalStreamWriter.setValue(String.valueOf(hSliderWidgetData.getPosX()));
|
||||
hierarchicalStreamWriter.endNode();
|
||||
hierarchicalStreamWriter.startNode("pos_y");
|
||||
hierarchicalStreamWriter.setValue(String.valueOf(hSliderWidgetData.getPosY()));
|
||||
hierarchicalStreamWriter.endNode();
|
||||
}
|
||||
|
||||
/* JADX WARN: Failed to restore switch over string. Please report as a decompilation issue */
|
||||
@Override // com.thoughtworks.xstream.converters.Converter
|
||||
public Object unmarshal(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext) {
|
||||
String attribute = hierarchicalStreamReader.getAttribute("widgetId");
|
||||
if (TextUtils.isEmpty(attribute)) {
|
||||
attribute = hierarchicalStreamReader.getAttribute("widgetID");
|
||||
}
|
||||
HSliderWidgetData hSliderWidgetData = new HSliderWidgetData(attribute);
|
||||
HSliderConfig hSliderConfig = new HSliderConfig();
|
||||
String attribute2 = hierarchicalStreamReader.getAttribute("configID");
|
||||
if (!TextUtils.isEmpty(attribute2)) {
|
||||
hSliderConfig.setConfigID(attribute2);
|
||||
}
|
||||
while (hierarchicalStreamReader.hasMoreChildren()) {
|
||||
hierarchicalStreamReader.moveDown();
|
||||
String nodeName = hierarchicalStreamReader.getNodeName();
|
||||
char c = 65535;
|
||||
switch (nodeName.hashCode()) {
|
||||
case -251140552:
|
||||
if (nodeName.equals("max_angle")) {
|
||||
c = 4;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 106854733:
|
||||
if (nodeName.equals("pos_x")) {
|
||||
c = 0;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 106854734:
|
||||
if (nodeName.equals("pos_y")) {
|
||||
c = 1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 521338022:
|
||||
if (nodeName.equals("min_angle")) {
|
||||
c = 3;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 1984158196:
|
||||
if (nodeName.equals("servoID")) {
|
||||
c = 2;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (c == 0) {
|
||||
hSliderWidgetData.setPosX(Float.valueOf(hierarchicalStreamReader.getValue()).floatValue());
|
||||
} else if (c == 1) {
|
||||
hSliderWidgetData.setPosY(Float.valueOf(hierarchicalStreamReader.getValue()).floatValue());
|
||||
} else if (c == 2) {
|
||||
Integer valueOf = Integer.valueOf(hierarchicalStreamReader.getValue());
|
||||
if (valueOf != null && valueOf.intValue() > 0) {
|
||||
hSliderConfig.setServoID(valueOf.intValue());
|
||||
}
|
||||
} else if (c == 3) {
|
||||
hSliderConfig.setMinAngle(Integer.valueOf(hierarchicalStreamReader.getValue()).intValue());
|
||||
} else if (c != 4) {
|
||||
XLog.b("woo", "Unknown node name : %s", hierarchicalStreamReader.getNodeName());
|
||||
} else {
|
||||
hSliderConfig.setMaxAngle(Integer.valueOf(hierarchicalStreamReader.getValue()).intValue());
|
||||
}
|
||||
hierarchicalStreamReader.moveUp();
|
||||
}
|
||||
hSliderWidgetData.setConfig(hSliderConfig);
|
||||
return hSliderWidgetData;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.ubt.jimu.controller.data.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import com.thoughtworks.xstream.annotations.XStreamConverter;
|
||||
import com.thoughtworks.xstream.annotations.XStreamOmitField;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.controller.data.config.HSliderConfig;
|
||||
|
||||
@XStreamConverter(priority = 9999, value = HSliderDataConverter.class)
|
||||
/* loaded from: classes.dex */
|
||||
public class HSliderWidgetData extends MoveBaseData<HSliderConfig> {
|
||||
|
||||
@XStreamOmitField
|
||||
private HSliderConfig config;
|
||||
|
||||
public HSliderWidgetData() {
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.MoveBaseData
|
||||
public String getShowName(Context context) {
|
||||
return String.format(context.getResources().getString(R.string.servo_mode_servo_index), Integer.valueOf(getConfig().getServoID()));
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.ItemBaseData
|
||||
public String getWidgetInfo(Context context) {
|
||||
HSliderConfig config = getConfig();
|
||||
if (config == null) {
|
||||
return "";
|
||||
}
|
||||
return String.format(context.getResources().getString(R.string.servo_mode_servo_index), Integer.valueOf(config.getServoID())) + "(" + config.getMinAngle() + "°~" + config.getMaxAngle() + "°)";
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.ItemBaseData
|
||||
public String toString() {
|
||||
return super.toString() + " " + getConfig().toString();
|
||||
}
|
||||
|
||||
public HSliderWidgetData(String str) {
|
||||
super(str);
|
||||
}
|
||||
|
||||
/* JADX WARN: Can't rename method to resolve collision */
|
||||
@Override // com.ubt.jimu.controller.data.widget.MoveBaseData
|
||||
public HSliderConfig getConfig() {
|
||||
return this.config;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.MoveBaseData
|
||||
public void setConfig(HSliderConfig hSliderConfig) {
|
||||
super.setConfig((HSliderWidgetData) hSliderConfig);
|
||||
this.config = hSliderConfig;
|
||||
}
|
||||
|
||||
public HSliderWidgetData(String str, float f, float f2) {
|
||||
super(str, f, f2);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public HSliderWidgetData(String str, byte b, int i, int i2, float f, float f2) {
|
||||
super(str, f, f2);
|
||||
}
|
||||
}
|
||||
169
sources/com/ubt/jimu/controller/data/widget/ItemBaseData.java
Normal file
169
sources/com/ubt/jimu/controller/data/widget/ItemBaseData.java
Normal file
@@ -0,0 +1,169 @@
|
||||
package com.ubt.jimu.controller.data.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Size;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
|
||||
import com.thoughtworks.xstream.annotations.XStreamOmitField;
|
||||
import com.ubt.jimu.controller.util.IDGenerator;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class ItemBaseData {
|
||||
static final String ALIAS_POS_X = "pos_x";
|
||||
static final String ALIAS_POS_Y = "pos_y";
|
||||
static final String ALIAS_WIDGET_ID = "widgetId";
|
||||
|
||||
@XStreamOmitField
|
||||
private int ImageViewId;
|
||||
|
||||
@XStreamOmitField
|
||||
private float currentX;
|
||||
|
||||
@XStreamOmitField
|
||||
private float currentY;
|
||||
|
||||
@XStreamOmitField
|
||||
private Size displaySize;
|
||||
|
||||
@XStreamAlias(ALIAS_POS_X)
|
||||
private float posX;
|
||||
|
||||
@XStreamAlias(ALIAS_POS_Y)
|
||||
private float posY;
|
||||
|
||||
@XStreamOmitField
|
||||
private String showName;
|
||||
|
||||
@XStreamAsAttribute
|
||||
private String widgetId;
|
||||
|
||||
@XStreamOmitField
|
||||
private Size xmlSize;
|
||||
|
||||
public ItemBaseData() {
|
||||
this.widgetId = IDGenerator.a(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
private float getDisplayRatio() {
|
||||
float height = this.displaySize.getHeight() / this.xmlSize.getHeight();
|
||||
float width = this.displaySize.getWidth() / this.xmlSize.getWidth();
|
||||
return width > height ? height : width;
|
||||
}
|
||||
|
||||
private float getSaveRatio() {
|
||||
float height = this.xmlSize.getHeight() / this.displaySize.getHeight();
|
||||
float width = this.xmlSize.getWidth() / this.displaySize.getWidth();
|
||||
return width < height ? height : width;
|
||||
}
|
||||
|
||||
private void transformX(float f) {
|
||||
if (Math.abs(f) > 1.0E-6f) {
|
||||
if (this.displaySize == null || this.xmlSize == null) {
|
||||
this.posX = f;
|
||||
} else {
|
||||
this.posX = (f - (r0.getWidth() / 2.0f)) * getSaveRatio();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void transformY(float f) {
|
||||
if (Math.abs(f) > 1.0E-6f) {
|
||||
if (this.displaySize == null || this.xmlSize == null) {
|
||||
this.posY = f;
|
||||
} else {
|
||||
this.posY = ((r0.getHeight() / 2.0f) - f) * getSaveRatio();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public float getCurrentX() {
|
||||
if (Math.abs(this.currentX) < 1.0E-6f && this.displaySize != null && this.xmlSize != null) {
|
||||
this.currentX = (this.posX * getDisplayRatio()) + (this.displaySize.getWidth() / 2.0f);
|
||||
}
|
||||
return this.currentX;
|
||||
}
|
||||
|
||||
public float getCurrentY() {
|
||||
if (Math.abs(this.currentY) < 1.0E-6f && this.displaySize != null && this.xmlSize != null) {
|
||||
this.currentY = (this.displaySize.getHeight() / 2.0f) - (this.posY * getDisplayRatio());
|
||||
}
|
||||
return this.currentY;
|
||||
}
|
||||
|
||||
public int getImageViewId() {
|
||||
return this.ImageViewId;
|
||||
}
|
||||
|
||||
public float getPosX() {
|
||||
return this.posX;
|
||||
}
|
||||
|
||||
public float getPosY() {
|
||||
return this.posY;
|
||||
}
|
||||
|
||||
public String getShowName(String str) {
|
||||
return this.showName;
|
||||
}
|
||||
|
||||
public String getWidgetId() {
|
||||
return this.widgetId;
|
||||
}
|
||||
|
||||
public abstract String getWidgetInfo(Context context);
|
||||
|
||||
public abstract boolean isOfficial();
|
||||
|
||||
public void setCurrentPos(float f, float f2) {
|
||||
setCurrentX(f);
|
||||
setCurrentY(f2);
|
||||
}
|
||||
|
||||
public void setCurrentX(float f) {
|
||||
this.currentX = f;
|
||||
}
|
||||
|
||||
public void setCurrentY(float f) {
|
||||
this.currentY = f;
|
||||
}
|
||||
|
||||
protected void setDisplaySize(Size size, Size size2) {
|
||||
this.displaySize = size;
|
||||
this.xmlSize = size2;
|
||||
}
|
||||
|
||||
public void setImageViewId(int i) {
|
||||
this.ImageViewId = i;
|
||||
}
|
||||
|
||||
protected void setPosX(float f) {
|
||||
this.posX = f;
|
||||
}
|
||||
|
||||
protected void setPosY(float f) {
|
||||
this.posY = f;
|
||||
}
|
||||
|
||||
public void setShowName(String str) {
|
||||
this.showName = str;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "ItemBaseData{widgetId='" + this.widgetId + "', posX=" + this.posX + ", posY=" + this.posY + ", ImageViewId=" + getImageViewId() + ", showName='" + this.showName + "', displaySize=" + this.displaySize + ", xmlSize=" + this.xmlSize + ", currentX=" + getCurrentX() + ", currentY=" + getCurrentY() + '}';
|
||||
}
|
||||
|
||||
protected void transform() {
|
||||
transformX(this.currentX);
|
||||
transformY(this.currentY);
|
||||
}
|
||||
|
||||
public ItemBaseData(String str) {
|
||||
this.widgetId = str;
|
||||
}
|
||||
|
||||
public ItemBaseData(String str, float f, float f2) {
|
||||
this(str);
|
||||
this.posX = f;
|
||||
this.posY = f2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.ubt.jimu.controller.data.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import com.thoughtworks.xstream.annotations.XStreamConverter;
|
||||
import com.thoughtworks.xstream.annotations.XStreamOmitField;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.controller.data.config.JockstickConfig;
|
||||
|
||||
@XStreamConverter(priority = 9999, value = JockstickDataConverter.class)
|
||||
/* loaded from: classes.dex */
|
||||
public class JockstickData extends MoveBaseData<JockstickConfig> {
|
||||
|
||||
@XStreamOmitField
|
||||
private JockstickConfig config;
|
||||
|
||||
public JockstickData() {
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.MoveBaseData
|
||||
public String getShowName(Context context) {
|
||||
String string = context.getResources().getString(R.string.control_two_engine);
|
||||
if (getConfig().getType() == JockstickConfig.JockType.fourServo) {
|
||||
string = context.getResources().getString(R.string.control_four_engine);
|
||||
}
|
||||
if (getConfig().getType() == JockstickConfig.JockType.sixServo) {
|
||||
string = context.getResources().getString(R.string.control_six_engine);
|
||||
}
|
||||
int index = getConfig().getIndex();
|
||||
if (index <= 1) {
|
||||
return string;
|
||||
}
|
||||
return string + index;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.ItemBaseData
|
||||
public String getWidgetInfo(Context context) {
|
||||
return getShowName(context);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.ItemBaseData
|
||||
public String toString() {
|
||||
return super.toString() + " " + getConfig().toString();
|
||||
}
|
||||
|
||||
public JockstickData(String str) {
|
||||
super(str);
|
||||
}
|
||||
|
||||
/* JADX WARN: Can't rename method to resolve collision */
|
||||
@Override // com.ubt.jimu.controller.data.widget.MoveBaseData
|
||||
public JockstickConfig getConfig() {
|
||||
return this.config;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.MoveBaseData
|
||||
public void setConfig(JockstickConfig jockstickConfig) {
|
||||
super.setConfig((JockstickData) jockstickConfig);
|
||||
this.config = jockstickConfig;
|
||||
}
|
||||
|
||||
public JockstickData(String str, float f, float f2) {
|
||||
super(str, f, f2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
package com.ubt.jimu.controller.data.widget;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.thoughtworks.xstream.converters.Converter;
|
||||
import com.thoughtworks.xstream.converters.MarshallingContext;
|
||||
import com.thoughtworks.xstream.converters.UnmarshallingContext;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
|
||||
import com.ubt.jimu.base.data.CtrlMotionType;
|
||||
import com.ubt.jimu.controller.data.config.JockstickConfig;
|
||||
import com.ubt.jimu.controller.data.config.Wheel;
|
||||
import com.ubt.jimu.transport.model.TransportFile;
|
||||
import com.ubtech.utils.XLog;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class JockstickDataConverter implements Converter {
|
||||
public static final String CONFIG_ID = "configID";
|
||||
public static final String ID = "id";
|
||||
public static final String MOTION_TYPE = "motionType";
|
||||
public static final String POS = "pos";
|
||||
public static final String REVERSE = "reverse";
|
||||
public static final String TYPE = "type";
|
||||
public static final String WHEEL = "wheel";
|
||||
|
||||
private void marshalConfig(HierarchicalStreamWriter hierarchicalStreamWriter, MarshallingContext marshallingContext, JockstickConfig jockstickConfig) {
|
||||
if (jockstickConfig != null) {
|
||||
JockstickConfig.JockType type = jockstickConfig.getType();
|
||||
if (type != null) {
|
||||
hierarchicalStreamWriter.startNode("type");
|
||||
hierarchicalStreamWriter.setValue(type.name());
|
||||
hierarchicalStreamWriter.endNode();
|
||||
}
|
||||
CtrlMotionType motionType = jockstickConfig.getMotionType();
|
||||
if (motionType != null) {
|
||||
hierarchicalStreamWriter.startNode("motionType");
|
||||
hierarchicalStreamWriter.setValue(motionType.name());
|
||||
hierarchicalStreamWriter.endNode();
|
||||
}
|
||||
List<Wheel> wheelList = jockstickConfig.getWheelList();
|
||||
if (wheelList == null || wheelList.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
for (Wheel wheel : wheelList) {
|
||||
hierarchicalStreamWriter.startNode(WHEEL);
|
||||
marshallingContext.convertAnother(wheel);
|
||||
hierarchicalStreamWriter.endNode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.ConverterMatcher
|
||||
public boolean canConvert(Class cls) {
|
||||
return JockstickData.class.equals(cls);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.Converter
|
||||
public void marshal(Object obj, HierarchicalStreamWriter hierarchicalStreamWriter, MarshallingContext marshallingContext) {
|
||||
JockstickData jockstickData = (JockstickData) obj;
|
||||
if (!TextUtils.isEmpty(jockstickData.getWidgetId())) {
|
||||
hierarchicalStreamWriter.addAttribute("widgetId", jockstickData.getWidgetId());
|
||||
}
|
||||
JockstickConfig config = jockstickData.getConfig();
|
||||
if (config != null && !TextUtils.isEmpty(config.getConfigID())) {
|
||||
hierarchicalStreamWriter.addAttribute("configID", config.getConfigID());
|
||||
}
|
||||
hierarchicalStreamWriter.startNode("pos_x");
|
||||
hierarchicalStreamWriter.setValue(String.valueOf(jockstickData.getPosX()));
|
||||
hierarchicalStreamWriter.endNode();
|
||||
hierarchicalStreamWriter.startNode("pos_y");
|
||||
hierarchicalStreamWriter.setValue(String.valueOf(jockstickData.getPosY()));
|
||||
hierarchicalStreamWriter.endNode();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.Converter
|
||||
public Object unmarshal(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext) {
|
||||
String attribute = hierarchicalStreamReader.getAttribute("widgetId");
|
||||
if (TextUtils.isEmpty(attribute)) {
|
||||
attribute = hierarchicalStreamReader.getAttribute("widgetID");
|
||||
}
|
||||
JockstickData jockstickData = new JockstickData(attribute);
|
||||
JockstickConfig jockstickConfig = new JockstickConfig();
|
||||
String attribute2 = hierarchicalStreamReader.getAttribute("configID");
|
||||
if (!TextUtils.isEmpty(attribute2)) {
|
||||
jockstickConfig.setConfigID(attribute2);
|
||||
}
|
||||
while (hierarchicalStreamReader.hasMoreChildren()) {
|
||||
hierarchicalStreamReader.moveDown();
|
||||
switch (hierarchicalStreamReader.getNodeName()) {
|
||||
case "pos_x":
|
||||
jockstickData.setPosX(Float.valueOf(hierarchicalStreamReader.getValue()).floatValue());
|
||||
break;
|
||||
case "pos_y":
|
||||
jockstickData.setPosY(Float.valueOf(hierarchicalStreamReader.getValue()).floatValue());
|
||||
break;
|
||||
case "type":
|
||||
try {
|
||||
jockstickConfig.setType((JockstickConfig.JockType) unmarshallingContext.convertAnother(jockstickData, JockstickConfig.JockType.class));
|
||||
break;
|
||||
} catch (Exception e) {
|
||||
XLog.b(TransportFile.TYPE_CONTROLLER, "unknown JockType");
|
||||
e.printStackTrace();
|
||||
jockstickConfig.setType(JockstickConfig.JockType.twoServo);
|
||||
break;
|
||||
}
|
||||
case "motionType":
|
||||
try {
|
||||
jockstickConfig.setMotionType((CtrlMotionType) unmarshallingContext.convertAnother(jockstickData, CtrlMotionType.class));
|
||||
break;
|
||||
} catch (Exception e2) {
|
||||
e2.printStackTrace();
|
||||
jockstickConfig.setMotionType(CtrlMotionType.servo);
|
||||
break;
|
||||
}
|
||||
case "leftUpID":
|
||||
Integer valueOf = Integer.valueOf(hierarchicalStreamReader.getValue());
|
||||
if (valueOf != null && valueOf.intValue() > 0) {
|
||||
jockstickConfig.putWheel(1, new Wheel(valueOf.intValue(), 1));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case "rightUpID":
|
||||
Integer valueOf2 = Integer.valueOf(hierarchicalStreamReader.getValue());
|
||||
if (valueOf2 != null && valueOf2.intValue() > 0) {
|
||||
jockstickConfig.putWheel(2, new Wheel(valueOf2.intValue(), 2));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case "leftBottomID":
|
||||
Integer valueOf3 = Integer.valueOf(hierarchicalStreamReader.getValue());
|
||||
if (valueOf3 != null && valueOf3.intValue() > 0) {
|
||||
jockstickConfig.putWheel(3, new Wheel(valueOf3.intValue(), 3));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case "rightBottomID":
|
||||
Integer valueOf4 = Integer.valueOf(hierarchicalStreamReader.getValue());
|
||||
if (valueOf4 != null && valueOf4.intValue() > 0) {
|
||||
jockstickConfig.putWheel(4, new Wheel(valueOf4.intValue(), 4));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case "wheel":
|
||||
Wheel wheel = (Wheel) unmarshallingContext.convertAnother(jockstickData, Wheel.class);
|
||||
jockstickConfig.putWheel(wheel.getPosition(), wheel);
|
||||
break;
|
||||
default:
|
||||
XLog.b("woo", "Unknown node name : %s", hierarchicalStreamReader.getNodeName());
|
||||
break;
|
||||
}
|
||||
hierarchicalStreamReader.moveUp();
|
||||
}
|
||||
jockstickData.setConfig(jockstickConfig);
|
||||
return jockstickData;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.ubt.jimu.controller.data.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
|
||||
import com.ubt.jimu.controller.data.config.WidgetConfig;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class MoveBaseData<C extends WidgetConfig> extends ItemBaseData {
|
||||
|
||||
@XStreamAsAttribute
|
||||
private String configID;
|
||||
|
||||
public MoveBaseData() {
|
||||
}
|
||||
|
||||
public abstract C getConfig();
|
||||
|
||||
public String getConfigID() {
|
||||
return this.configID;
|
||||
}
|
||||
|
||||
public abstract String getShowName(Context context);
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.ItemBaseData
|
||||
public boolean isOfficial() {
|
||||
return getConfig() != null && getConfig().getConfigType() == 1;
|
||||
}
|
||||
|
||||
public void setConfig(C c) {
|
||||
this.configID = c.getConfigID();
|
||||
}
|
||||
|
||||
public void setConfigID(String str) {
|
||||
this.configID = str;
|
||||
}
|
||||
|
||||
public void updateConfig(C c) {
|
||||
setConfig(c);
|
||||
}
|
||||
|
||||
public MoveBaseData(String str) {
|
||||
super(str);
|
||||
}
|
||||
|
||||
public MoveBaseData(String str, float f, float f2) {
|
||||
super(str, f, f2);
|
||||
}
|
||||
}
|
||||
250
sources/com/ubt/jimu/controller/data/widget/MoveWidgetData.java
Normal file
250
sources/com/ubt/jimu/controller/data/widget/MoveWidgetData.java
Normal file
@@ -0,0 +1,250 @@
|
||||
package com.ubt.jimu.controller.data.widget;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import com.thoughtworks.xstream.annotations.XStreamImplicit;
|
||||
import com.ubt.jimu.controller.data.config.AccumulatorConfig;
|
||||
import com.ubt.jimu.controller.data.config.HSliderConfig;
|
||||
import com.ubt.jimu.controller.data.config.JockstickConfig;
|
||||
import com.ubt.jimu.controller.data.config.SliderConfig;
|
||||
import com.ubt.jimu.controller.data.config.WidgetConfig;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
@XStreamAlias("MoveWidgetData")
|
||||
/* loaded from: classes.dex */
|
||||
public class MoveWidgetData {
|
||||
|
||||
@XStreamImplicit
|
||||
private List<AccumulatorConfig> accumulatorConfigList;
|
||||
|
||||
@XStreamImplicit
|
||||
private List<HSliderConfig> hSliderConfigList;
|
||||
|
||||
@XStreamImplicit
|
||||
private List<JockstickConfig> jockstickConfigList;
|
||||
|
||||
@XStreamImplicit
|
||||
private List<SliderConfig> sliderConfigList;
|
||||
|
||||
static /* synthetic */ int a(WidgetConfig widgetConfig, WidgetConfig widgetConfig2) {
|
||||
return widgetConfig2.getConfigType() != widgetConfig.getConfigType() ? widgetConfig2.getConfigType() - widgetConfig.getConfigType() : widgetConfig2.getConfigID().compareTo(widgetConfig.getConfigID());
|
||||
}
|
||||
|
||||
private boolean isExclusive(List<? extends WidgetConfig> list, WidgetConfig widgetConfig) {
|
||||
for (WidgetConfig widgetConfig2 : list) {
|
||||
if (widgetConfig2.equals(widgetConfig)) {
|
||||
widgetConfig.setConfigID(widgetConfig2.getConfigID());
|
||||
return false;
|
||||
}
|
||||
if (!TextUtils.isEmpty(widgetConfig.getConfigID()) && widgetConfig2.getConfigID().equals(widgetConfig.getConfigID())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean addAccumulatorConfig(AccumulatorConfig accumulatorConfig) {
|
||||
List<AccumulatorConfig> list = this.accumulatorConfigList;
|
||||
if (list == null) {
|
||||
this.accumulatorConfigList = new ArrayList();
|
||||
this.accumulatorConfigList.add(accumulatorConfig);
|
||||
return true;
|
||||
}
|
||||
if (!isExclusive(list, accumulatorConfig)) {
|
||||
return false;
|
||||
}
|
||||
this.accumulatorConfigList.add(accumulatorConfig);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean addHSliderConfig(HSliderConfig hSliderConfig) {
|
||||
List<HSliderConfig> list = this.hSliderConfigList;
|
||||
if (list == null) {
|
||||
this.hSliderConfigList = new ArrayList();
|
||||
this.hSliderConfigList.add(hSliderConfig);
|
||||
return true;
|
||||
}
|
||||
if (!isExclusive(list, hSliderConfig)) {
|
||||
return false;
|
||||
}
|
||||
this.hSliderConfigList.add(hSliderConfig);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean addJockstickConfig(JockstickConfig jockstickConfig) {
|
||||
List<JockstickConfig> list = this.jockstickConfigList;
|
||||
if (list == null) {
|
||||
this.jockstickConfigList = new ArrayList();
|
||||
this.jockstickConfigList.add(jockstickConfig);
|
||||
return true;
|
||||
}
|
||||
if (!isExclusive(list, jockstickConfig)) {
|
||||
return false;
|
||||
}
|
||||
this.jockstickConfigList.add(jockstickConfig);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean addSliderConfig(SliderConfig sliderConfig) {
|
||||
List<SliderConfig> list = this.sliderConfigList;
|
||||
if (list == null) {
|
||||
this.sliderConfigList = new ArrayList();
|
||||
this.sliderConfigList.add(sliderConfig);
|
||||
return true;
|
||||
}
|
||||
if (!isExclusive(list, sliderConfig)) {
|
||||
return false;
|
||||
}
|
||||
this.sliderConfigList.add(sliderConfig);
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<AccumulatorConfig> getAccumulatorConfigList() {
|
||||
return this.accumulatorConfigList;
|
||||
}
|
||||
|
||||
public List<WidgetConfig> getConfigList() {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
List<JockstickConfig> list = this.jockstickConfigList;
|
||||
if (list != null && list.size() > 0) {
|
||||
arrayList.addAll(this.jockstickConfigList);
|
||||
}
|
||||
List<SliderConfig> list2 = this.sliderConfigList;
|
||||
if (list2 != null && list2.size() > 0) {
|
||||
arrayList.addAll(this.sliderConfigList);
|
||||
}
|
||||
List<HSliderConfig> list3 = this.hSliderConfigList;
|
||||
if (list3 != null && list3.size() > 0) {
|
||||
arrayList.addAll(this.hSliderConfigList);
|
||||
}
|
||||
List<AccumulatorConfig> list4 = this.accumulatorConfigList;
|
||||
if (list4 != null && list4.size() > 0) {
|
||||
arrayList.addAll(this.accumulatorConfigList);
|
||||
}
|
||||
Collections.sort(arrayList, new Comparator() { // from class: com.ubt.jimu.controller.data.widget.a
|
||||
@Override // java.util.Comparator
|
||||
public final int compare(Object obj, Object obj2) {
|
||||
return MoveWidgetData.a((WidgetConfig) obj, (WidgetConfig) obj2);
|
||||
}
|
||||
});
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
public List<HSliderConfig> getHSliderConfigList() {
|
||||
return this.hSliderConfigList;
|
||||
}
|
||||
|
||||
public List<JockstickConfig> getJockstickConfigList() {
|
||||
return this.jockstickConfigList;
|
||||
}
|
||||
|
||||
public List<SliderConfig> getSliderConfigList() {
|
||||
return this.sliderConfigList;
|
||||
}
|
||||
|
||||
public boolean merge(ControllerData controllerData) {
|
||||
boolean z = false;
|
||||
if (controllerData != null) {
|
||||
List<SliderWidgetData> sliderData = controllerData.getSliderData();
|
||||
if (sliderData != null && sliderData.size() > 0) {
|
||||
for (SliderWidgetData sliderWidgetData : sliderData) {
|
||||
SliderConfig config = sliderWidgetData.getConfig();
|
||||
if (addSliderConfig(config)) {
|
||||
z = true;
|
||||
} else {
|
||||
sliderWidgetData.setConfig(config);
|
||||
}
|
||||
}
|
||||
}
|
||||
List<HSliderWidgetData> hsliderData = controllerData.getHsliderData();
|
||||
if (hsliderData != null && hsliderData.size() > 0) {
|
||||
for (HSliderWidgetData hSliderWidgetData : hsliderData) {
|
||||
HSliderConfig config2 = hSliderWidgetData.getConfig();
|
||||
if (addHSliderConfig(config2)) {
|
||||
z = true;
|
||||
} else {
|
||||
hSliderWidgetData.setConfig(config2);
|
||||
}
|
||||
}
|
||||
}
|
||||
List<JockstickData> jockstickData = controllerData.getJockstickData();
|
||||
if (jockstickData != null && jockstickData.size() > 0) {
|
||||
for (JockstickData jockstickData2 : jockstickData) {
|
||||
JockstickConfig config3 = jockstickData2.getConfig();
|
||||
if (addJockstickConfig(config3)) {
|
||||
z = true;
|
||||
} else {
|
||||
jockstickData2.setConfig(config3);
|
||||
}
|
||||
}
|
||||
}
|
||||
List<AccumulatorData> accumulatorData = controllerData.getAccumulatorData();
|
||||
if (accumulatorData != null && accumulatorData.size() > 0) {
|
||||
for (AccumulatorData accumulatorData2 : accumulatorData) {
|
||||
AccumulatorConfig config4 = accumulatorData2.getConfig();
|
||||
if (addAccumulatorConfig(config4)) {
|
||||
z = true;
|
||||
} else {
|
||||
accumulatorData2.setConfig(config4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return z;
|
||||
}
|
||||
|
||||
public boolean removeAccumulatorConfig(AccumulatorConfig accumulatorConfig) {
|
||||
List<AccumulatorConfig> list;
|
||||
if (accumulatorConfig == null || (list = this.accumulatorConfigList) == null || list.size() <= 0) {
|
||||
return true;
|
||||
}
|
||||
return this.accumulatorConfigList.remove(accumulatorConfig);
|
||||
}
|
||||
|
||||
public boolean removeHSliderconfig(HSliderConfig hSliderConfig) {
|
||||
List<HSliderConfig> list;
|
||||
if (hSliderConfig == null || (list = this.hSliderConfigList) == null || list.size() <= 0) {
|
||||
return true;
|
||||
}
|
||||
return this.hSliderConfigList.remove(hSliderConfig);
|
||||
}
|
||||
|
||||
public boolean removeJockstickConfig(JockstickConfig jockstickConfig) {
|
||||
List<JockstickConfig> list;
|
||||
if (jockstickConfig == null || (list = this.jockstickConfigList) == null || list.size() <= 0) {
|
||||
return true;
|
||||
}
|
||||
return this.jockstickConfigList.remove(jockstickConfig);
|
||||
}
|
||||
|
||||
public boolean removeSliderconfig(SliderConfig sliderConfig) {
|
||||
List<SliderConfig> list;
|
||||
if (sliderConfig == null || (list = this.sliderConfigList) == null || list.size() <= 0) {
|
||||
return true;
|
||||
}
|
||||
return this.sliderConfigList.remove(sliderConfig);
|
||||
}
|
||||
|
||||
public void setAccumulatorConfigList(List<AccumulatorConfig> list) {
|
||||
this.accumulatorConfigList = list;
|
||||
}
|
||||
|
||||
public void setHSliderConfigList(List<HSliderConfig> list) {
|
||||
this.hSliderConfigList = list;
|
||||
}
|
||||
|
||||
public void setJockstickConfigList(List<JockstickConfig> list) {
|
||||
this.jockstickConfigList = list;
|
||||
}
|
||||
|
||||
public void setSliderConfigList(List<SliderConfig> list) {
|
||||
this.sliderConfigList = list;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "MoveWidgetData{sliderConfigList=" + this.sliderConfigList + ", hSliderConfigList=" + this.hSliderConfigList + ", jockstickConfigList=" + this.jockstickConfigList + ", accumulatorConfigList=" + this.accumulatorConfigList + '}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.ubt.jimu.controller.data.widget;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.thoughtworks.xstream.converters.Converter;
|
||||
import com.thoughtworks.xstream.converters.MarshallingContext;
|
||||
import com.thoughtworks.xstream.converters.UnmarshallingContext;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
|
||||
import com.ubt.jimu.base.data.CtrlMotionType;
|
||||
import com.ubt.jimu.controller.data.config.SliderConfig;
|
||||
import com.ubtech.utils.XLog;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class SliderDataConverter implements Converter {
|
||||
public static final String CONFIG_ID = "configID";
|
||||
public static final String DIRECTION = "directionDisclock";
|
||||
public static final String MOTION_TYPE = "motionType";
|
||||
public static final String SERVO_ID = "servoID";
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.ConverterMatcher
|
||||
public boolean canConvert(Class cls) {
|
||||
return SliderWidgetData.class.equals(cls);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.Converter
|
||||
public void marshal(Object obj, HierarchicalStreamWriter hierarchicalStreamWriter, MarshallingContext marshallingContext) {
|
||||
SliderWidgetData sliderWidgetData = (SliderWidgetData) obj;
|
||||
if (!TextUtils.isEmpty(sliderWidgetData.getWidgetId())) {
|
||||
hierarchicalStreamWriter.addAttribute("widgetId", sliderWidgetData.getWidgetId());
|
||||
}
|
||||
SliderConfig config = sliderWidgetData.getConfig();
|
||||
if (config != null && !TextUtils.isEmpty(config.getConfigID())) {
|
||||
hierarchicalStreamWriter.addAttribute("configID", config.getConfigID());
|
||||
}
|
||||
hierarchicalStreamWriter.startNode("pos_x");
|
||||
hierarchicalStreamWriter.setValue(String.valueOf(sliderWidgetData.getPosX()));
|
||||
hierarchicalStreamWriter.endNode();
|
||||
hierarchicalStreamWriter.startNode("pos_y");
|
||||
hierarchicalStreamWriter.setValue(String.valueOf(sliderWidgetData.getPosY()));
|
||||
hierarchicalStreamWriter.endNode();
|
||||
}
|
||||
|
||||
/* JADX WARN: Failed to restore switch over string. Please report as a decompilation issue */
|
||||
@Override // com.thoughtworks.xstream.converters.Converter
|
||||
public Object unmarshal(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext) {
|
||||
String attribute = hierarchicalStreamReader.getAttribute("widgetId");
|
||||
if (TextUtils.isEmpty(attribute)) {
|
||||
attribute = hierarchicalStreamReader.getAttribute("widgetID");
|
||||
}
|
||||
SliderWidgetData sliderWidgetData = new SliderWidgetData(attribute);
|
||||
SliderConfig sliderConfig = new SliderConfig();
|
||||
String attribute2 = hierarchicalStreamReader.getAttribute("configID");
|
||||
if (!TextUtils.isEmpty(attribute2)) {
|
||||
sliderConfig.setConfigID(attribute2);
|
||||
}
|
||||
while (hierarchicalStreamReader.hasMoreChildren()) {
|
||||
hierarchicalStreamReader.moveDown();
|
||||
String nodeName = hierarchicalStreamReader.getNodeName();
|
||||
char c = 65535;
|
||||
switch (nodeName.hashCode()) {
|
||||
case -1480753953:
|
||||
if (nodeName.equals(DIRECTION)) {
|
||||
c = 4;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case -720898032:
|
||||
if (nodeName.equals("motionType")) {
|
||||
c = 2;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 106854733:
|
||||
if (nodeName.equals("pos_x")) {
|
||||
c = 0;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 106854734:
|
||||
if (nodeName.equals("pos_y")) {
|
||||
c = 1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 1984158196:
|
||||
if (nodeName.equals("servoID")) {
|
||||
c = 3;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (c == 0) {
|
||||
sliderWidgetData.setPosX(Float.valueOf(hierarchicalStreamReader.getValue()).floatValue());
|
||||
} else if (c == 1) {
|
||||
sliderWidgetData.setPosY(Float.valueOf(hierarchicalStreamReader.getValue()).floatValue());
|
||||
} else if (c == 2) {
|
||||
sliderConfig.setMotionType((CtrlMotionType) unmarshallingContext.convertAnother(sliderWidgetData, CtrlMotionType.class));
|
||||
} else if (c == 3) {
|
||||
Integer valueOf = Integer.valueOf(hierarchicalStreamReader.getValue());
|
||||
if (valueOf != null && valueOf.intValue() > 0) {
|
||||
sliderConfig.setServoID(valueOf.intValue());
|
||||
}
|
||||
} else if (c != 4) {
|
||||
XLog.b("woo", "Unknown node name : %s", hierarchicalStreamReader.getNodeName());
|
||||
} else {
|
||||
sliderConfig.setDirectionDisclock(Boolean.valueOf(hierarchicalStreamReader.getValue()).booleanValue());
|
||||
}
|
||||
hierarchicalStreamReader.moveUp();
|
||||
}
|
||||
sliderWidgetData.setConfig(sliderConfig);
|
||||
return sliderWidgetData;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.ubt.jimu.controller.data.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import com.thoughtworks.xstream.annotations.XStreamConverter;
|
||||
import com.thoughtworks.xstream.annotations.XStreamOmitField;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.base.data.CtrlMotionType;
|
||||
import com.ubt.jimu.controller.data.config.SliderConfig;
|
||||
|
||||
@XStreamConverter(priority = 9999, value = SliderDataConverter.class)
|
||||
/* loaded from: classes.dex */
|
||||
public class SliderWidgetData extends MoveBaseData<SliderConfig> {
|
||||
|
||||
@XStreamOmitField
|
||||
private SliderConfig config;
|
||||
|
||||
public SliderWidgetData() {
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.MoveBaseData
|
||||
public String getShowName(Context context) {
|
||||
String string = context.getResources().getString(R.string.servo_mode_servo_index);
|
||||
if (getConfig().getMotionType() == CtrlMotionType.motor) {
|
||||
string = context.getResources().getString(R.string.control_motor_index);
|
||||
}
|
||||
return String.format(string, Integer.valueOf(getConfig().getServoID()));
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.ItemBaseData
|
||||
public String getWidgetInfo(Context context) {
|
||||
if (this.config == null) {
|
||||
return "";
|
||||
}
|
||||
StringBuilder sb = new StringBuilder(String.format(context.getResources().getString(R.string.servo_mode_servo_index), Integer.valueOf(this.config.getServoID())));
|
||||
sb.append("(");
|
||||
sb.append(this.config.isDirectionDisclock() ? context.getResources().getString(R.string.engine_rotate_anticlockwise) : context.getResources().getString(R.string.engine_rotate_clockwise));
|
||||
sb.append(")");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.ItemBaseData
|
||||
public String toString() {
|
||||
return super.toString() + " " + getConfig().toString();
|
||||
}
|
||||
|
||||
public SliderWidgetData(String str) {
|
||||
super(str);
|
||||
}
|
||||
|
||||
/* JADX WARN: Can't rename method to resolve collision */
|
||||
@Override // com.ubt.jimu.controller.data.widget.MoveBaseData
|
||||
public SliderConfig getConfig() {
|
||||
return this.config;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.MoveBaseData
|
||||
public void setConfig(SliderConfig sliderConfig) {
|
||||
super.setConfig((SliderWidgetData) sliderConfig);
|
||||
this.config = sliderConfig;
|
||||
}
|
||||
|
||||
public SliderWidgetData(String str, float f, float f2) {
|
||||
super(str, f, f2);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public SliderWidgetData(String str, CtrlMotionType ctrlMotionType, byte b, boolean z, float f, float f2) {
|
||||
super(str, f, f2);
|
||||
}
|
||||
}
|
||||
364
sources/com/ubt/jimu/controller/manager/ActionManager.java
Normal file
364
sources/com/ubt/jimu/controller/manager/ActionManager.java
Normal file
@@ -0,0 +1,364 @@
|
||||
package com.ubt.jimu.controller.manager;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.Build;
|
||||
import android.text.TextUtils;
|
||||
import android.util.SparseArray;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.base.entities.RobotLite;
|
||||
import com.ubt.jimu.base.util.PathHelper;
|
||||
import com.ubt.jimu.controller.data.action.Action;
|
||||
import com.ubt.jimu.controller.data.action.ActionIcon;
|
||||
import com.ubt.jimu.controller.data.action.ActionSequence;
|
||||
import com.ubt.jimu.controller.data.action.MotorData;
|
||||
import com.ubt.jimu.controller.data.action.TurnData;
|
||||
import com.ubt.jimu.controller.data.widget.ActionWidgetData;
|
||||
import com.ubt.jimu.controller.data.widget.JockstickDataConverter;
|
||||
import com.ubt.jimu.transport.model.TransportFile;
|
||||
import com.unity3d.ads.metadata.MediationMetaData;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
import org.xmlpull.v1.XmlPullParserFactory;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ActionManager {
|
||||
private static ActionManager e;
|
||||
private Context a;
|
||||
private List<ActionSequence> b = new CopyOnWriteArrayList();
|
||||
private final Map<String, ActionIcon> c = new HashMap();
|
||||
private RobotLite d;
|
||||
|
||||
private ActionManager(Context context) {
|
||||
this.a = context.getApplicationContext();
|
||||
d();
|
||||
}
|
||||
|
||||
public static synchronized ActionManager a(Context context) {
|
||||
ActionManager actionManager;
|
||||
synchronized (ActionManager.class) {
|
||||
if (e == null) {
|
||||
e = new ActionManager(context);
|
||||
}
|
||||
actionManager = e;
|
||||
}
|
||||
return actionManager;
|
||||
}
|
||||
|
||||
private void c() {
|
||||
List<ActionSequence> list = this.b;
|
||||
if (list != null) {
|
||||
list.clear();
|
||||
}
|
||||
}
|
||||
|
||||
private void d() {
|
||||
String[] stringArray = this.a.getResources().getStringArray(R.array.action_icon_key);
|
||||
TypedArray obtainTypedArray = this.a.getResources().obtainTypedArray(R.array.action_icon_drawable);
|
||||
for (int i = 0; i < stringArray.length; i++) {
|
||||
this.c.put(stringArray[i], new ActionIcon(stringArray[i], obtainTypedArray.getResourceId(i, 0)));
|
||||
}
|
||||
}
|
||||
|
||||
public void b() {
|
||||
if (this.d != null) {
|
||||
c();
|
||||
a(this.d.isOfficial());
|
||||
}
|
||||
}
|
||||
|
||||
private void c(XmlPullParser xmlPullParser, Action action) {
|
||||
String attributeValue = xmlPullParser.getAttributeValue(null, TransportFile.TYPE_DIY_SHOW);
|
||||
if (TextUtils.isEmpty(attributeValue)) {
|
||||
return;
|
||||
}
|
||||
String[] split = attributeValue.split(";");
|
||||
if (split.length > 0) {
|
||||
ArrayList arrayList = new ArrayList(split.length);
|
||||
for (String str : split) {
|
||||
arrayList.add(Integer.valueOf(str.trim()));
|
||||
}
|
||||
action.a(arrayList);
|
||||
}
|
||||
}
|
||||
|
||||
public void a(RobotLite robotLite) {
|
||||
this.d = robotLite;
|
||||
b();
|
||||
}
|
||||
|
||||
public ActionIcon b(String str) {
|
||||
Map<String, ActionIcon> map = this.c;
|
||||
if (map == null || map.size() <= 0) {
|
||||
return null;
|
||||
}
|
||||
return this.c.get(str);
|
||||
}
|
||||
|
||||
private void b(boolean z) {
|
||||
File[] listFiles;
|
||||
File file = new File(PathHelper.getActionDir(this.a, this.d, z));
|
||||
if (!file.exists() || !file.isDirectory() || (listFiles = file.listFiles()) == null || listFiles.length <= 0) {
|
||||
return;
|
||||
}
|
||||
a(listFiles, z);
|
||||
}
|
||||
|
||||
private void d(XmlPullParser xmlPullParser, Action action) {
|
||||
String attributeValue = xmlPullParser.getAttributeValue(null, "turns");
|
||||
if (TextUtils.isEmpty(attributeValue)) {
|
||||
return;
|
||||
}
|
||||
String[] split = attributeValue.split(";");
|
||||
TreeMap treeMap = new TreeMap();
|
||||
for (String str : split) {
|
||||
String[] split2 = str.split("\\$");
|
||||
if (split2.length > 1) {
|
||||
String[] split3 = split2[1].split(",");
|
||||
int intValue = Integer.valueOf(split3[0].trim()).intValue();
|
||||
if (intValue == 2) {
|
||||
intValue = -1;
|
||||
}
|
||||
treeMap.put(Integer.valueOf(split2[0].trim()), new TurnData(intValue, Integer.valueOf(split3[1].trim()).intValue()));
|
||||
}
|
||||
}
|
||||
action.c(treeMap);
|
||||
}
|
||||
|
||||
public ActionSequence a(String str) {
|
||||
List<ActionSequence> list = this.b;
|
||||
if (list == null || list.size() <= 0) {
|
||||
return null;
|
||||
}
|
||||
for (ActionSequence actionSequence : this.b) {
|
||||
if (actionSequence.e().equals(str)) {
|
||||
return actionSequence;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void a(boolean z) {
|
||||
if (z) {
|
||||
b(false);
|
||||
b(true);
|
||||
} else {
|
||||
b(true);
|
||||
}
|
||||
List<ActionSequence> list = this.b;
|
||||
if (list == null || list.size() <= 1) {
|
||||
return;
|
||||
}
|
||||
a aVar = new Comparator() { // from class: com.ubt.jimu.controller.manager.a
|
||||
@Override // java.util.Comparator
|
||||
public final int compare(Object obj, Object obj2) {
|
||||
return ActionManager.a((ActionSequence) obj, (ActionSequence) obj2);
|
||||
}
|
||||
};
|
||||
if (Build.VERSION.SDK_INT >= 24) {
|
||||
this.b.sort(aVar);
|
||||
return;
|
||||
}
|
||||
ArrayList arrayList = new ArrayList(this.b);
|
||||
Collections.sort(arrayList, aVar);
|
||||
this.b.clear();
|
||||
this.b.addAll(arrayList);
|
||||
}
|
||||
|
||||
private int c(String str) {
|
||||
if (!TextUtils.isEmpty(str)) {
|
||||
try {
|
||||
return Integer.valueOf(str.trim()).intValue();
|
||||
} catch (NumberFormatException e2) {
|
||||
e2.printStackTrace();
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private void b(ActionSequence actionSequence, XmlPullParser xmlPullParser) {
|
||||
actionSequence.e(xmlPullParser.getAttributeValue(null, MediationMetaData.KEY_NAME));
|
||||
a(actionSequence, xmlPullParser.getAttributeValue(null, "showName"));
|
||||
actionSequence.f(xmlPullParser.getAttributeValue(null, "robotID"));
|
||||
actionSequence.c(xmlPullParser.getAttributeValue(null, JockstickDataConverter.ID));
|
||||
actionSequence.b(xmlPullParser.getAttributeValue(null, "icon"));
|
||||
actionSequence.a(Long.valueOf(xmlPullParser.getAttributeValue(null, "createTime")).longValue());
|
||||
}
|
||||
|
||||
private void b(XmlPullParser xmlPullParser, Action action) {
|
||||
String attributeValue = xmlPullParser.getAttributeValue(null, "rotas");
|
||||
if (TextUtils.isEmpty(attributeValue)) {
|
||||
return;
|
||||
}
|
||||
String[] split = attributeValue.split(";");
|
||||
TreeMap treeMap = new TreeMap();
|
||||
for (String str : split) {
|
||||
String[] split2 = str.split("\\$");
|
||||
if (split2.length > 1) {
|
||||
treeMap.put(Integer.valueOf(split2[0].trim()), Integer.valueOf(split2[1].trim()));
|
||||
}
|
||||
}
|
||||
action.b(treeMap);
|
||||
}
|
||||
|
||||
static /* synthetic */ int a(ActionSequence actionSequence, ActionSequence actionSequence2) {
|
||||
if (actionSequence.j() != actionSequence2.j()) {
|
||||
return actionSequence.j() ? 1 : -1;
|
||||
}
|
||||
long b = actionSequence2.b() - actionSequence.b();
|
||||
if (b > 0) {
|
||||
return 1;
|
||||
}
|
||||
return b < 0 ? -1 : 0;
|
||||
}
|
||||
|
||||
private void a(File[] fileArr, boolean z) {
|
||||
ActionSequence a;
|
||||
for (File file : fileArr) {
|
||||
if (file.isFile() && (a = a(file)) != null) {
|
||||
ActionIcon b = b(a.c());
|
||||
if (b != null) {
|
||||
a.a(b.a());
|
||||
}
|
||||
a.a(!z);
|
||||
String soundPath = PathHelper.getSoundPath(this.a, this.d, a);
|
||||
if (!TextUtils.isEmpty(soundPath)) {
|
||||
a.d(soundPath);
|
||||
}
|
||||
this.b.add(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ActionSequence a(File file) {
|
||||
try {
|
||||
FileInputStream fileInputStream = new FileInputStream(file);
|
||||
try {
|
||||
XmlPullParser newPullParser = XmlPullParserFactory.newInstance().newPullParser();
|
||||
newPullParser.setInput(fileInputStream, "utf-8");
|
||||
ActionSequence actionSequence = null;
|
||||
for (int eventType = newPullParser.getEventType(); eventType != 1; eventType = newPullParser.next()) {
|
||||
if (eventType != 0) {
|
||||
if (eventType == 2 && "Root".equals(newPullParser.getName())) {
|
||||
String attributeValue = newPullParser.getAttributeValue(null, "nodeType");
|
||||
if ("head".equals(attributeValue)) {
|
||||
b(actionSequence, newPullParser);
|
||||
} else if ("body".equals(attributeValue)) {
|
||||
a(actionSequence, newPullParser);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
actionSequence = new ActionSequence();
|
||||
}
|
||||
}
|
||||
fileInputStream.close();
|
||||
return actionSequence;
|
||||
} catch (Throwable th) {
|
||||
try {
|
||||
throw th;
|
||||
} catch (Throwable th2) {
|
||||
try {
|
||||
fileInputStream.close();
|
||||
} catch (Throwable th3) {
|
||||
th.addSuppressed(th3);
|
||||
}
|
||||
throw th2;
|
||||
}
|
||||
}
|
||||
} catch (IOException | NumberFormatException | XmlPullParserException e2) {
|
||||
e2.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void a(ActionSequence actionSequence, XmlPullParser xmlPullParser) {
|
||||
Action action = new Action();
|
||||
action.a(c(xmlPullParser.getAttributeValue(null, "index")));
|
||||
int c = c(xmlPullParser.getAttributeValue(null, "sportTime"));
|
||||
if (c > -1) {
|
||||
action.b(c);
|
||||
}
|
||||
int c2 = c(xmlPullParser.getAttributeValue(null, "waitTime"));
|
||||
if (c2 > -1) {
|
||||
action.c(c2);
|
||||
}
|
||||
b(xmlPullParser, action);
|
||||
d(xmlPullParser, action);
|
||||
a(xmlPullParser, action);
|
||||
c(xmlPullParser, action);
|
||||
actionSequence.a(action);
|
||||
}
|
||||
|
||||
private void a(XmlPullParser xmlPullParser, Action action) {
|
||||
String attributeValue = xmlPullParser.getAttributeValue(null, "motors");
|
||||
if (TextUtils.isEmpty(attributeValue)) {
|
||||
return;
|
||||
}
|
||||
String[] split = attributeValue.split(";");
|
||||
TreeMap treeMap = new TreeMap();
|
||||
for (String str : split) {
|
||||
String[] split2 = str.split("\\$");
|
||||
if (split2.length > 1) {
|
||||
String[] split3 = split2[1].split(",");
|
||||
if (split3.length >= 3) {
|
||||
int intValue = Integer.valueOf(split3[0].trim()).intValue();
|
||||
if (intValue == 2) {
|
||||
intValue = -1;
|
||||
}
|
||||
treeMap.put(Integer.valueOf(split2[0].trim()), new MotorData(intValue, Integer.valueOf(split3[1].trim()).intValue(), Integer.valueOf(split3[2].trim()).intValue()));
|
||||
} else if (split3.length >= 2) {
|
||||
int intValue2 = Integer.valueOf(split3[0].trim()).intValue();
|
||||
if (intValue2 == 2) {
|
||||
intValue2 = -1;
|
||||
}
|
||||
treeMap.put(Integer.valueOf(split2[0].trim()), new MotorData(intValue2, Integer.valueOf(split3[1].trim()).intValue(), 6553500));
|
||||
} else if (split3.length <= 1) {
|
||||
treeMap.put(Integer.valueOf(split2[0].trim()), new MotorData(0, 0, 6553500));
|
||||
}
|
||||
}
|
||||
}
|
||||
action.a(treeMap);
|
||||
}
|
||||
|
||||
private void a(ActionSequence actionSequence, String str) {
|
||||
if (TextUtils.isEmpty(str)) {
|
||||
return;
|
||||
}
|
||||
String[] split = str.split(";");
|
||||
SparseArray<String> sparseArray = new SparseArray<>(split.length);
|
||||
for (String str2 : split) {
|
||||
String[] split2 = str2.split("\\$");
|
||||
if (split2.length > 1) {
|
||||
sparseArray.put(Integer.valueOf(split2[0]).intValue(), split2[1]);
|
||||
}
|
||||
}
|
||||
actionSequence.a(sparseArray);
|
||||
}
|
||||
|
||||
public List<ActionWidgetData> a() {
|
||||
List<ActionSequence> list = this.b;
|
||||
if (list == null || list.size() <= 0) {
|
||||
return null;
|
||||
}
|
||||
ArrayList arrayList = new ArrayList(this.b.size());
|
||||
for (ActionSequence actionSequence : this.b) {
|
||||
ActionWidgetData actionWidgetData = new ActionWidgetData();
|
||||
actionWidgetData.setActionID(actionSequence.e());
|
||||
actionWidgetData.setActionNm(actionSequence.h());
|
||||
actionWidgetData.setActionSequence(actionSequence);
|
||||
arrayList.add(actionWidgetData);
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
}
|
||||
401
sources/com/ubt/jimu/controller/manager/CommandManager.java
Normal file
401
sources/com/ubt/jimu/controller/manager/CommandManager.java
Normal file
@@ -0,0 +1,401 @@
|
||||
package com.ubt.jimu.controller.manager;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.os.SystemClock;
|
||||
import com.ubt.jimu.base.EngineManager;
|
||||
import com.ubt.jimu.base.cache.Cache;
|
||||
import com.ubt.jimu.base.data.CtrlMotionType;
|
||||
import com.ubt.jimu.base.data.Engine;
|
||||
import com.ubt.jimu.base.data.Servo;
|
||||
import com.ubt.jimu.base.data.ServoMode;
|
||||
import com.ubt.jimu.controller.data.action.ActionSequence;
|
||||
import com.ubt.jimu.controller.data.action.MotorData;
|
||||
import com.ubt.jimu.controller.data.action.TurnData;
|
||||
import com.ubt.jimu.controller.data.command.ActionSequenceTask;
|
||||
import com.ubt.jimu.controller.data.command.MotorCommand;
|
||||
import com.ubt.jimu.controller.data.command.MoveCommand;
|
||||
import com.ubt.jimu.controller.data.command.MoveTask;
|
||||
import com.ubt.jimu.controller.data.command.TurnCommand;
|
||||
import com.ubt.jimu.utils.LogUtils;
|
||||
import com.ubtech.utils.XLog;
|
||||
import com.ubtrobot.jimu.exception.EngineProtectException;
|
||||
import com.ubtrobot.jimu.robotapi.BoardInfo;
|
||||
import com.ubtrobot.jimu.robotapi.JimuException;
|
||||
import com.ubtrobot.jimu.robotapi.JimuManager;
|
||||
import com.ubtrobot.jimu.robotapi.MotorException;
|
||||
import com.ubtrobot.jimu.robotapi.PeripheralType;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class CommandManager implements ICommandExecutor {
|
||||
private static CommandManager i;
|
||||
private JimuManager a;
|
||||
private Handler b;
|
||||
private Handler c;
|
||||
private ActionSequenceTask d;
|
||||
private ActionSequenceTask e;
|
||||
private HandlerThread f;
|
||||
private HandlerThread g;
|
||||
private EngineManager h;
|
||||
|
||||
private CommandManager(Context context) {
|
||||
context.getApplicationContext();
|
||||
}
|
||||
|
||||
public static synchronized CommandManager a(Context context) {
|
||||
CommandManager commandManager;
|
||||
synchronized (CommandManager.class) {
|
||||
if (i == null) {
|
||||
i = new CommandManager(context);
|
||||
}
|
||||
commandManager = i;
|
||||
}
|
||||
return commandManager;
|
||||
}
|
||||
|
||||
private void b() {
|
||||
ActionSequenceTask actionSequenceTask = this.e;
|
||||
if (actionSequenceTask != null) {
|
||||
actionSequenceTask.cancel();
|
||||
}
|
||||
ActionSequenceTask actionSequenceTask2 = this.d;
|
||||
if (actionSequenceTask2 != null) {
|
||||
actionSequenceTask2.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
private void d() {
|
||||
Handler handler = this.c;
|
||||
if (handler != null) {
|
||||
handler.removeCallbacksAndMessages("move");
|
||||
}
|
||||
}
|
||||
|
||||
private void e(List<Servo> list) {
|
||||
if (list == null || list.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
HashMap hashMap = new HashMap(list.size());
|
||||
Iterator<Servo> it = list.iterator();
|
||||
while (it.hasNext()) {
|
||||
hashMap.put(Integer.valueOf(it.next().getId()), new TurnData(0, 0));
|
||||
}
|
||||
a((MoveCommand) new TurnCommand(hashMap), true);
|
||||
}
|
||||
|
||||
private boolean f() {
|
||||
BoardInfo boardInfo = Cache.getInstance().getBoardInfo();
|
||||
return boardInfo != null && boardInfo.e() == 113;
|
||||
}
|
||||
|
||||
private void g() {
|
||||
if (this.a == null) {
|
||||
return;
|
||||
}
|
||||
if (this.c == null) {
|
||||
e();
|
||||
}
|
||||
this.c.post(new Runnable() { // from class: com.ubt.jimu.controller.manager.b
|
||||
@Override // java.lang.Runnable
|
||||
public final void run() {
|
||||
CommandManager.this.a();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void c(ActionSequence actionSequence) {
|
||||
ActionSequenceTask actionSequenceTask = this.e;
|
||||
if (actionSequenceTask != null) {
|
||||
if (this.d != actionSequenceTask) {
|
||||
this.d = actionSequenceTask;
|
||||
XLog.a("woo", "setLoop false");
|
||||
this.d.a(false);
|
||||
this.e = null;
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
ActionSequenceTask actionSequenceTask2 = this.d;
|
||||
if (actionSequenceTask2 == null || !actionSequenceTask2.a().equals(actionSequence) || this.d.g()) {
|
||||
return;
|
||||
}
|
||||
XLog.a("woo", "stopAction ");
|
||||
b(actionSequence);
|
||||
this.e = null;
|
||||
}
|
||||
|
||||
private void d(List<Engine> list) {
|
||||
if (list == null || list.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
HashMap hashMap = new HashMap(list.size());
|
||||
Iterator<Engine> it = list.iterator();
|
||||
while (it.hasNext()) {
|
||||
hashMap.put(Integer.valueOf(it.next().getId()), new MotorData(0, 0, 6553500));
|
||||
}
|
||||
a((MoveCommand) new MotorCommand(hashMap), true);
|
||||
}
|
||||
|
||||
public void a(JimuManager jimuManager) {
|
||||
this.a = jimuManager;
|
||||
}
|
||||
|
||||
public void a(ActionSequence actionSequence) {
|
||||
ActionSequenceTask actionSequenceTask = this.d;
|
||||
if (actionSequenceTask == null || !actionSequenceTask.a().equals(actionSequence) || this.d.g()) {
|
||||
b();
|
||||
if (this.b == null) {
|
||||
this.f = new HandlerThread("ActionThread");
|
||||
this.f.start();
|
||||
this.b = new Handler(this.f.getLooper());
|
||||
}
|
||||
LogUtils.c("playAction sequence" + actionSequence.a().get(0).c());
|
||||
ActionSequenceTask actionSequenceTask2 = new ActionSequenceTask(actionSequence, this);
|
||||
actionSequenceTask2.a(true);
|
||||
this.b.removeCallbacksAndMessages(null);
|
||||
this.b.post(actionSequenceTask2);
|
||||
this.e = actionSequenceTask2;
|
||||
}
|
||||
}
|
||||
|
||||
public void b(ActionSequence actionSequence) {
|
||||
if (actionSequence != null) {
|
||||
b();
|
||||
d(actionSequence.f());
|
||||
e(actionSequence.i());
|
||||
}
|
||||
}
|
||||
|
||||
private void e() {
|
||||
this.g = new HandlerThread("MoveThread");
|
||||
this.g.start();
|
||||
this.c = new Handler(this.g.getLooper());
|
||||
}
|
||||
|
||||
public void b(List<Engine> list) {
|
||||
b();
|
||||
c();
|
||||
d();
|
||||
g();
|
||||
d(c(list));
|
||||
}
|
||||
|
||||
private void c() {
|
||||
Handler handler = this.b;
|
||||
if (handler != null) {
|
||||
handler.removeCallbacksAndMessages(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.manager.ICommandExecutor
|
||||
public void b(Map<Integer, TurnData> map) {
|
||||
if (this.a == null) {
|
||||
return;
|
||||
}
|
||||
a(map, ServoMode.SERVO_MODE_TURN);
|
||||
if (map == null || map.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
Collections.sort(new ArrayList(map.entrySet()), new Comparator() { // from class: com.ubt.jimu.controller.manager.c
|
||||
@Override // java.util.Comparator
|
||||
public final int compare(Object obj, Object obj2) {
|
||||
return CommandManager.a((Map.Entry) obj, (Map.Entry) obj2);
|
||||
}
|
||||
});
|
||||
int[] iArr = new int[map.size()];
|
||||
int[] iArr2 = new int[map.size()];
|
||||
int i2 = 0;
|
||||
int i3 = -1;
|
||||
Iterator<Integer> it = map.keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
int intValue = it.next().intValue();
|
||||
iArr[i2] = intValue;
|
||||
iArr2[i2] = map.get(Integer.valueOf(intValue)).a();
|
||||
if (i2 > 0) {
|
||||
int i4 = i2 - 1;
|
||||
if (iArr2[i2] != iArr2[i4]) {
|
||||
a(iArr, iArr2[i4], i2, i3);
|
||||
i3 = i4;
|
||||
}
|
||||
}
|
||||
i2++;
|
||||
}
|
||||
a(iArr, iArr2[i2 - 1], i2, i3);
|
||||
}
|
||||
|
||||
private List<Engine> c(List<? extends Engine> list) {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
if (list != null && list.size() > 0) {
|
||||
for (Engine engine : list) {
|
||||
if (engine.getMotionType() == CtrlMotionType.motor) {
|
||||
arrayList.add(engine);
|
||||
}
|
||||
}
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
public void a(List<? extends Engine> list) {
|
||||
b();
|
||||
c();
|
||||
d();
|
||||
g();
|
||||
d(c(list));
|
||||
}
|
||||
|
||||
public void a(MoveCommand moveCommand, boolean z) {
|
||||
if (this.c == null) {
|
||||
e();
|
||||
}
|
||||
this.c.removeCallbacksAndMessages("move");
|
||||
this.c.postAtTime(new MoveTask(moveCommand, this), z ? "stop" : "move", SystemClock.uptimeMillis());
|
||||
}
|
||||
|
||||
public /* synthetic */ void a() {
|
||||
try {
|
||||
this.a.i();
|
||||
} catch (JimuException e) {
|
||||
e.printStackTrace();
|
||||
XLog.b("Exception", e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.manager.ICommandExecutor
|
||||
public int a(Map<Integer, Integer> map, int i2, int i3) {
|
||||
if (this.a == null) {
|
||||
return 0;
|
||||
}
|
||||
a(map, ServoMode.SERVO_MODE_ANGLE);
|
||||
if (map != null && map.size() > 0) {
|
||||
int[] iArr = new int[map.size()];
|
||||
float[] fArr = new float[map.size()];
|
||||
Iterator<Integer> it = map.keySet().iterator();
|
||||
int i4 = 0;
|
||||
while (it.hasNext()) {
|
||||
iArr[i4] = it.next().intValue();
|
||||
fArr[i4] = map.get(Integer.valueOf(r5)).intValue();
|
||||
i4++;
|
||||
}
|
||||
XLog.a("woo", "run rotas ids.length: %d, servos.length: %d sportTime: %d, waitTime: %d", Integer.valueOf(iArr.length), Integer.valueOf(fArr.length), Integer.valueOf(i2), Integer.valueOf(i3));
|
||||
try {
|
||||
this.a.a(iArr, fArr, i2, i3);
|
||||
} catch (MotorException e) {
|
||||
e.printStackTrace();
|
||||
XLog.b("Controller", "RequestException: %s", e.toString());
|
||||
if (e.getCode() == -21 && f()) {
|
||||
EventBus.b().b(a(a(iArr, e.getFailIds()), 2, "Servo is protected", PeripheralType.SERVO));
|
||||
}
|
||||
return e.getCode();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private Integer[] a(int[] iArr, ArrayList<Integer> arrayList) {
|
||||
if (arrayList != null && arrayList.size() > 0) {
|
||||
Integer[] numArr = new Integer[arrayList.size()];
|
||||
arrayList.toArray(numArr);
|
||||
return numArr;
|
||||
}
|
||||
Integer[] numArr2 = new Integer[iArr.length];
|
||||
for (int i2 = 0; i2 < iArr.length; i2++) {
|
||||
numArr2[i2] = Integer.valueOf(iArr[i2]);
|
||||
}
|
||||
return numArr2;
|
||||
}
|
||||
|
||||
private EngineProtectException a(Integer[] numArr, int i2, String str, int i3) {
|
||||
HashMap hashMap = new HashMap(1);
|
||||
ArrayList arrayList = new ArrayList(numArr.length);
|
||||
arrayList.addAll(Arrays.asList(numArr));
|
||||
hashMap.put(32, arrayList);
|
||||
return new EngineProtectException(i2, str, i3, hashMap);
|
||||
}
|
||||
|
||||
private void a(Map<Integer, ?> map, ServoMode servoMode) {
|
||||
if (this.h == null || map == null || map.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
Integer[] numArr = new Integer[map.size()];
|
||||
map.keySet().toArray(numArr);
|
||||
for (Integer num : numArr) {
|
||||
int intValue = num.intValue();
|
||||
if (this.h.getServoMode(intValue) != servoMode) {
|
||||
map.remove(Integer.valueOf(intValue));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static /* synthetic */ int a(Map.Entry entry, Map.Entry entry2) {
|
||||
if (entry.getValue() == null && entry2.getValue() == null) {
|
||||
return 0;
|
||||
}
|
||||
if (entry.getValue() == null) {
|
||||
return -1;
|
||||
}
|
||||
if (entry2.getValue() == null) {
|
||||
return 1;
|
||||
}
|
||||
return Integer.compare(((TurnData) entry.getValue()).a(), ((TurnData) entry2.getValue()).a());
|
||||
}
|
||||
|
||||
private void a(int[] iArr, int i2, int i3, int i4) {
|
||||
int i5 = (i3 - 1) - i4;
|
||||
int[] iArr2 = new int[i5];
|
||||
System.arraycopy(iArr, i4 + 1, iArr2, 0, i5);
|
||||
XLog.a("woo", "runTurns ids.length: %s, speed: %d ", Integer.valueOf(iArr2.length), Integer.valueOf(i2));
|
||||
try {
|
||||
this.a.a(iArr2, i2);
|
||||
} catch (MotorException e) {
|
||||
e.printStackTrace();
|
||||
XLog.b("Controller", "RequestException: %s", e.toString());
|
||||
if (e.getCode() == -21 && f()) {
|
||||
EventBus.b().b(a(a(iArr, e.getFailIds()), 2, "Servo is protected", PeripheralType.SERVO));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.manager.ICommandExecutor
|
||||
public void a(Map<Integer, MotorData> map) {
|
||||
if (this.a == null || map == null || map.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
int[] iArr = new int[map.size()];
|
||||
int[] iArr2 = new int[map.size()];
|
||||
int[] iArr3 = new int[map.size()];
|
||||
Iterator<Integer> it = map.keySet().iterator();
|
||||
int i2 = 0;
|
||||
while (it.hasNext()) {
|
||||
int intValue = it.next().intValue();
|
||||
iArr[i2] = intValue;
|
||||
MotorData motorData = map.get(Integer.valueOf(intValue));
|
||||
iArr2[i2] = motorData.a();
|
||||
iArr3[i2] = motorData.f();
|
||||
i2++;
|
||||
}
|
||||
XLog.a("woo", "runMotors ids: %s, speeds: %s, durations: %s", Arrays.toString(iArr), Arrays.toString(iArr2), Arrays.toString(iArr3));
|
||||
try {
|
||||
this.a.a(iArr, iArr2, iArr3);
|
||||
} catch (MotorException e) {
|
||||
e.printStackTrace();
|
||||
XLog.b("Controller", "RequestException: %s", e.toString());
|
||||
if (e.getCode() == -21 && f()) {
|
||||
EventBus.b().b(a(a(iArr, e.getFailIds()), 4, "Motor is protected", 10));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void a(EngineManager engineManager) {
|
||||
this.h = engineManager;
|
||||
}
|
||||
}
|
||||
144
sources/com/ubt/jimu/controller/manager/CommandSendManager.java
Normal file
144
sources/com/ubt/jimu/controller/manager/CommandSendManager.java
Normal file
@@ -0,0 +1,144 @@
|
||||
package com.ubt.jimu.controller.manager;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import com.ubt.jimu.controller.data.widget.HSliderWidgetData;
|
||||
import com.ubt.jimu.controller.data.widget.ItemBaseData;
|
||||
import com.ubt.jimu.controller.data.widget.SliderWidgetData;
|
||||
import com.ubt.jimu.controller.manager.CommandSendManager;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class CommandSendManager<T extends ItemBaseData> {
|
||||
private float a;
|
||||
private T b;
|
||||
private Timer c;
|
||||
private CommandSendManager<T>.CommandTimerTask d;
|
||||
private boolean e;
|
||||
private int f = 100;
|
||||
private Handler g;
|
||||
private HSliderViewCommandSendListener h;
|
||||
private VSliderViewCommandSendListener i;
|
||||
|
||||
class CommandTimerTask extends TimerTask {
|
||||
CommandTimerTask() {
|
||||
}
|
||||
|
||||
public /* synthetic */ void a() {
|
||||
CommandSendManager.this.h.b(CommandSendManager.this.a, CommandSendManager.this.b);
|
||||
}
|
||||
|
||||
public /* synthetic */ void b() {
|
||||
CommandSendManager.this.i.a(CommandSendManager.this.a, CommandSendManager.this.b);
|
||||
}
|
||||
|
||||
@Override // java.util.TimerTask, java.lang.Runnable
|
||||
public void run() {
|
||||
if (CommandSendManager.this.b == null) {
|
||||
return;
|
||||
}
|
||||
if ((CommandSendManager.this.b instanceof HSliderWidgetData) && CommandSendManager.this.h != null) {
|
||||
CommandSendManager.this.g.post(new Runnable() { // from class: com.ubt.jimu.controller.manager.d
|
||||
@Override // java.lang.Runnable
|
||||
public final void run() {
|
||||
CommandSendManager.CommandTimerTask.this.a();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (!(CommandSendManager.this.b instanceof SliderWidgetData) || CommandSendManager.this.i == null) {
|
||||
return;
|
||||
}
|
||||
CommandSendManager.this.g.post(new Runnable() { // from class: com.ubt.jimu.controller.manager.e
|
||||
@Override // java.lang.Runnable
|
||||
public final void run() {
|
||||
CommandSendManager.CommandTimerTask.this.b();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface HSliderViewCommandSendListener<T> {
|
||||
void a(T t);
|
||||
|
||||
void b(float f, T t);
|
||||
}
|
||||
|
||||
public interface VSliderViewCommandSendListener<T> {
|
||||
void a(float f, T t);
|
||||
|
||||
void c(float f, T t);
|
||||
}
|
||||
|
||||
public CommandSendManager() {
|
||||
c();
|
||||
this.g = new Handler(Looper.getMainLooper());
|
||||
}
|
||||
|
||||
private void c() {
|
||||
this.c = new Timer();
|
||||
this.d = new CommandTimerTask();
|
||||
}
|
||||
|
||||
public void a(float f) {
|
||||
this.a = f;
|
||||
}
|
||||
|
||||
public void b() {
|
||||
VSliderViewCommandSendListener vSliderViewCommandSendListener;
|
||||
HSliderViewCommandSendListener hSliderViewCommandSendListener;
|
||||
if (this.e) {
|
||||
Timer timer = this.c;
|
||||
if (timer != null) {
|
||||
timer.cancel();
|
||||
}
|
||||
CommandSendManager<T>.CommandTimerTask commandTimerTask = this.d;
|
||||
if (commandTimerTask != null) {
|
||||
commandTimerTask.cancel();
|
||||
}
|
||||
this.c = null;
|
||||
this.d = null;
|
||||
this.e = false;
|
||||
T t = this.b;
|
||||
if (t == null) {
|
||||
return;
|
||||
}
|
||||
if ((t instanceof HSliderWidgetData) && (hSliderViewCommandSendListener = this.h) != null) {
|
||||
hSliderViewCommandSendListener.a(t);
|
||||
return;
|
||||
}
|
||||
T t2 = this.b;
|
||||
if (!(t2 instanceof SliderWidgetData) || (vSliderViewCommandSendListener = this.i) == null) {
|
||||
return;
|
||||
}
|
||||
vSliderViewCommandSendListener.c(this.a, t2);
|
||||
}
|
||||
}
|
||||
|
||||
public void a(T t) {
|
||||
this.b = t;
|
||||
}
|
||||
|
||||
public void a() {
|
||||
if (this.e) {
|
||||
return;
|
||||
}
|
||||
if (this.c == null) {
|
||||
this.c = new Timer();
|
||||
}
|
||||
if (this.d == null) {
|
||||
this.d = new CommandTimerTask();
|
||||
}
|
||||
this.c.schedule(this.d, 0L, this.f);
|
||||
this.e = true;
|
||||
}
|
||||
|
||||
public void a(HSliderViewCommandSendListener hSliderViewCommandSendListener) {
|
||||
this.h = hSliderViewCommandSendListener;
|
||||
}
|
||||
|
||||
public void a(VSliderViewCommandSendListener vSliderViewCommandSendListener) {
|
||||
this.i = vSliderViewCommandSendListener;
|
||||
}
|
||||
}
|
||||
203
sources/com/ubt/jimu/controller/manager/ControllerManager.java
Normal file
203
sources/com/ubt/jimu/controller/manager/ControllerManager.java
Normal file
@@ -0,0 +1,203 @@
|
||||
package com.ubt.jimu.controller.manager;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Size;
|
||||
import com.ubt.jimu.base.db.diy.DiyDBModel;
|
||||
import com.ubt.jimu.base.db.diy.DiyHelper;
|
||||
import com.ubt.jimu.base.db.robot.RobotDbHandler;
|
||||
import com.ubt.jimu.base.entities.Robot;
|
||||
import com.ubt.jimu.base.entities.RobotLite;
|
||||
import com.ubt.jimu.base.util.FileUtil;
|
||||
import com.ubt.jimu.base.util.PathHelper;
|
||||
import com.ubt.jimu.controller.data.action.ActionSequence;
|
||||
import com.ubt.jimu.controller.data.config.WidgetConfig;
|
||||
import com.ubt.jimu.controller.data.widget.ActionWidgetData;
|
||||
import com.ubt.jimu.controller.data.widget.ControllerData;
|
||||
import com.ubt.jimu.controller.data.widget.MoveBaseData;
|
||||
import com.ubt.jimu.controller.data.widget.MoveWidgetData;
|
||||
import com.ubt.jimu.controller.util.ScreenUtil;
|
||||
import com.ubt.jimu.controller.util.XmlUtils;
|
||||
import com.ubt.jimu.transport3.UnityFileOperator;
|
||||
import com.ubtech.utils.XLog;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ControllerManager {
|
||||
private static ControllerManager d;
|
||||
private Context a;
|
||||
private ControllerData b;
|
||||
private RobotLite c;
|
||||
|
||||
private ControllerManager(Context context) {
|
||||
this.a = context.getApplicationContext();
|
||||
}
|
||||
|
||||
public static synchronized ControllerManager a(Context context) {
|
||||
ControllerManager controllerManager;
|
||||
synchronized (ControllerManager.class) {
|
||||
if (d == null) {
|
||||
d = new ControllerManager(context);
|
||||
}
|
||||
controllerManager = d;
|
||||
}
|
||||
return controllerManager;
|
||||
}
|
||||
|
||||
private void b(ControllerData controllerData) {
|
||||
a(controllerData.getJockstickData());
|
||||
a(controllerData.getSliderData());
|
||||
a(controllerData.getHsliderData());
|
||||
a(controllerData.getAccumulatorData());
|
||||
}
|
||||
|
||||
private void c(ControllerData controllerData) {
|
||||
MoveWidgetData moveConfig = controllerData.getMoveConfig();
|
||||
if (moveConfig == null) {
|
||||
return;
|
||||
}
|
||||
List<WidgetConfig> configList = moveConfig.getConfigList();
|
||||
if (configList != null && configList.size() > 0) {
|
||||
Iterator<WidgetConfig> it = configList.iterator();
|
||||
while (it.hasNext()) {
|
||||
it.next().setConfigType(this.c.isOfficial() ? 1 : 2);
|
||||
}
|
||||
}
|
||||
XLog.a("woo", "MoveWidgetData: %s", moveConfig.toString());
|
||||
MoveConfigManager a = MoveConfigManager.a(this.a);
|
||||
if (a.a(controllerData)) {
|
||||
a(controllerData, true);
|
||||
a.a(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void a(RobotLite robotLite) {
|
||||
this.c = robotLite;
|
||||
ActionManager.a(this.a).a(robotLite);
|
||||
MoveConfigManager.a(this.a).a(robotLite);
|
||||
}
|
||||
|
||||
public ControllerData a() {
|
||||
String controllerDir = PathHelper.getControllerDir(this.a, this.c, true);
|
||||
String controllerPath = PathHelper.getControllerPath(controllerDir);
|
||||
if (TextUtils.isEmpty(controllerPath) && this.c.isOfficial()) {
|
||||
controllerPath = a(controllerDir, controllerPath);
|
||||
}
|
||||
if (TextUtils.isEmpty(controllerPath)) {
|
||||
return null;
|
||||
}
|
||||
this.b = (ControllerData) XmlUtils.a(ControllerData.class, controllerPath);
|
||||
ControllerData controllerData = this.b;
|
||||
if (controllerData == null) {
|
||||
return null;
|
||||
}
|
||||
b(controllerData);
|
||||
boolean clearEmptyWidget = this.b.clearEmptyWidget();
|
||||
boolean a = a(this.b);
|
||||
if (clearEmptyWidget || a) {
|
||||
a(this.b, false);
|
||||
}
|
||||
this.b.transform(ScreenUtil.c(this.a), new Size(this.b.getScreenWidth(), this.b.getScreenHeight()));
|
||||
c(this.b);
|
||||
return this.b;
|
||||
}
|
||||
|
||||
private String a(String str, String str2) {
|
||||
XLog.c("woo", "copy official controller file to user/default");
|
||||
String controllerPath = PathHelper.getControllerPath(PathHelper.getControllerDir(this.a, this.c, false));
|
||||
if (TextUtils.isEmpty(controllerPath)) {
|
||||
return str2;
|
||||
}
|
||||
File file = new File(controllerPath);
|
||||
if (!file.exists() || !file.isFile()) {
|
||||
return str2;
|
||||
}
|
||||
File file2 = new File(str, file.getName());
|
||||
File parentFile = file2.getParentFile();
|
||||
if (!parentFile.exists()) {
|
||||
parentFile.mkdirs();
|
||||
}
|
||||
FileUtil.copy(file, file2);
|
||||
return file2.getPath();
|
||||
}
|
||||
|
||||
private void a(List<? extends MoveBaseData> list) {
|
||||
WidgetConfig a;
|
||||
if (list == null || list.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
for (MoveBaseData moveBaseData : list) {
|
||||
if (!TextUtils.isEmpty(moveBaseData.getConfigID()) && (a = MoveConfigManager.a(this.a).a(moveBaseData.getConfigID())) != null) {
|
||||
moveBaseData.setConfig(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean a(ControllerData controllerData) {
|
||||
boolean z = false;
|
||||
if (controllerData != null && controllerData.hasAction()) {
|
||||
ArrayList<ActionWidgetData> arrayList = new ArrayList(controllerData.getActionData().size());
|
||||
arrayList.addAll(controllerData.getActionData());
|
||||
for (ActionWidgetData actionWidgetData : arrayList) {
|
||||
String actionID = actionWidgetData.getActionID();
|
||||
if (TextUtils.isEmpty(actionID)) {
|
||||
controllerData.removeActionData(actionWidgetData);
|
||||
} else {
|
||||
ActionSequence a = ActionManager.a(this.a).a(actionID);
|
||||
if (a == null) {
|
||||
controllerData.removeActionData(actionWidgetData);
|
||||
} else {
|
||||
actionWidgetData.setActionSequence(a);
|
||||
}
|
||||
}
|
||||
z = true;
|
||||
}
|
||||
}
|
||||
return z;
|
||||
}
|
||||
|
||||
public void a(ControllerData controllerData, boolean z) {
|
||||
String str;
|
||||
int i;
|
||||
if (controllerData == null || this.c == null) {
|
||||
return;
|
||||
}
|
||||
controllerData.transform(ScreenUtil.c(this.a), new Size(controllerData.getScreenWidth(), controllerData.getScreenHeight()));
|
||||
String controllerDir = PathHelper.getControllerDir(this.a, this.c, true);
|
||||
if (TextUtils.isEmpty(controllerDir)) {
|
||||
return;
|
||||
}
|
||||
String controllerPath = PathHelper.getControllerPath(controllerDir);
|
||||
if (TextUtils.isEmpty(controllerPath)) {
|
||||
File file = new File(controllerDir);
|
||||
if (!file.exists()) {
|
||||
file.mkdirs();
|
||||
}
|
||||
str = controllerDir + PathHelper.newControllerFileName(this.c.getModelId());
|
||||
i = 1;
|
||||
} else {
|
||||
str = controllerPath;
|
||||
i = 2;
|
||||
}
|
||||
XLog.a("woo", "save : %s", controllerData.toString());
|
||||
XmlUtils.a(controllerData, str);
|
||||
if (z) {
|
||||
if (!this.c.isOfficial()) {
|
||||
DiyDBModel queryForUUid = DiyHelper.getInstance().queryForUUid(this.c.getModelId());
|
||||
if (queryForUUid != null) {
|
||||
new UnityFileOperator(queryForUUid.getModelId().intValue(), queryForUUid.getCustomModelId(), 1, str, i).operateFile();
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
Robot robotByModelName = RobotDbHandler.getRobotByModelName(this.c.getModelId());
|
||||
if (robotByModelName == null || robotByModelName.getModelId() <= 0) {
|
||||
return;
|
||||
}
|
||||
new UnityFileOperator((int) robotByModelName.getModelId(), this.c.getModelId(), 0, str, i).officialModelFileOperator();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.ubt.jimu.controller.manager;
|
||||
|
||||
import com.ubt.jimu.controller.data.action.MotorData;
|
||||
import com.ubt.jimu.controller.data.action.TurnData;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface ICommandExecutor {
|
||||
int a(Map<Integer, Integer> map, int i, int i2);
|
||||
|
||||
void a(Map<Integer, MotorData> map);
|
||||
|
||||
void b(Map<Integer, TurnData> map);
|
||||
}
|
||||
173
sources/com/ubt/jimu/controller/manager/KeyMapManager.java
Normal file
173
sources/com/ubt/jimu/controller/manager/KeyMapManager.java
Normal file
@@ -0,0 +1,173 @@
|
||||
package com.ubt.jimu.controller.manager;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import com.ubt.jimu.base.entities.RobotLite;
|
||||
import com.ubt.jimu.base.util.PathHelper;
|
||||
import com.ubt.jimu.controller.data.keymap.KeyMap;
|
||||
import com.ubt.jimu.controller.data.keymap.entity.GameControllerConfigData;
|
||||
import com.ubt.jimu.controller.data.keymap.entity.Key;
|
||||
import com.ubt.jimu.controller.data.keymap.entity.KeyMapData;
|
||||
import com.ubt.jimu.controller.util.XmlUtils;
|
||||
import com.ubtrobot.log.ALog;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class KeyMapManager {
|
||||
private Context a;
|
||||
private RobotLite b;
|
||||
private GameControllerConfigData c = new GameControllerConfigData();
|
||||
private List<KeyMap> d = new ArrayList();
|
||||
private List<KeyMap> e = new ArrayList();
|
||||
|
||||
public KeyMapManager(Context context) {
|
||||
this.a = context.getApplicationContext();
|
||||
}
|
||||
|
||||
private synchronized void e() {
|
||||
this.d.clear();
|
||||
this.e.clear();
|
||||
}
|
||||
|
||||
public void a(RobotLite robotLite) {
|
||||
this.b = robotLite;
|
||||
}
|
||||
|
||||
public synchronized List<KeyMap> b() {
|
||||
return this.e;
|
||||
}
|
||||
|
||||
public synchronized void c() {
|
||||
String gameControllerKeyMapFilePath = PathHelper.getGameControllerKeyMapFilePath(this.a, this.b);
|
||||
if (!TextUtils.isEmpty(gameControllerKeyMapFilePath)) {
|
||||
Object a = XmlUtils.a(GameControllerConfigData.class, gameControllerKeyMapFilePath);
|
||||
if (a != null) {
|
||||
this.c = (GameControllerConfigData) a;
|
||||
if (this.c != null && this.c.a() != null) {
|
||||
List<KeyMapData> a2 = this.c.a();
|
||||
if (a2 != null && !a2.isEmpty()) {
|
||||
KeyMapData keyMapData = a2.get(0);
|
||||
this.d = keyMapData.a();
|
||||
this.e = keyMapData.b();
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
Log.w("KeyMapManagerDemo", "keymap.xml not exit!");
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void d() {
|
||||
ALog.a("KeyMapManagerDemo").d("save");
|
||||
if (this.c == null) {
|
||||
return;
|
||||
}
|
||||
KeyMapData keyMapData = new KeyMapData();
|
||||
keyMapData.a(this.d);
|
||||
keyMapData.b(this.e);
|
||||
ArrayList arrayList = new ArrayList();
|
||||
arrayList.add(keyMapData);
|
||||
this.c.a(arrayList);
|
||||
String gameControllerKeyMapFilePath = PathHelper.getGameControllerKeyMapFilePath(this.a, this.b);
|
||||
File parentFile = new File(gameControllerKeyMapFilePath).getParentFile();
|
||||
if (!parentFile.exists()) {
|
||||
parentFile.mkdirs();
|
||||
}
|
||||
XmlUtils.a(this.c, gameControllerKeyMapFilePath);
|
||||
for (KeyMap keyMap : this.e) {
|
||||
ALog.a("KeyMapManagerDemo").d("saved Joystick keymap:" + keyMap);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void b(KeyMap keyMap) {
|
||||
ALog.a("KeyMapManagerDemo").d("Add keymap -- " + keyMap);
|
||||
if (keyMap == null) {
|
||||
return;
|
||||
}
|
||||
if (keyMap.c() == 1) {
|
||||
this.d.add(keyMap);
|
||||
} else if (keyMap.c() == 2) {
|
||||
this.e.add(keyMap);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized List<KeyMap> a() {
|
||||
return this.d;
|
||||
}
|
||||
|
||||
public synchronized void a(KeyMap keyMap) {
|
||||
ALog.a("KeyMapManagerDemo").d("delete keyMap:" + keyMap);
|
||||
if (keyMap == null) {
|
||||
return;
|
||||
}
|
||||
if (keyMap.c() == 2) {
|
||||
this.e.remove(keyMap);
|
||||
} else if (keyMap.c() == 1) {
|
||||
this.d.remove(keyMap);
|
||||
}
|
||||
d();
|
||||
}
|
||||
|
||||
public synchronized KeyMap b(String str) {
|
||||
if (this.d != null) {
|
||||
for (KeyMap keyMap : this.d) {
|
||||
if (str.equals(keyMap.a())) {
|
||||
return keyMap;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.e != null) {
|
||||
for (KeyMap keyMap2 : this.e) {
|
||||
if (str.equals(keyMap2.a())) {
|
||||
return keyMap2;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void a(List<KeyMap> list) {
|
||||
Iterator<KeyMap> it = list.iterator();
|
||||
while (it.hasNext()) {
|
||||
b(it.next());
|
||||
}
|
||||
}
|
||||
|
||||
public void a(String str) {
|
||||
ALog.a("KeyMapManagerDemo").d("delete action:" + str);
|
||||
KeyMap b = b(str);
|
||||
if (b != null) {
|
||||
a(b);
|
||||
d();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized String a(Key key) {
|
||||
List<KeyMap> list;
|
||||
if (key.b() == 2) {
|
||||
list = this.e;
|
||||
} else {
|
||||
list = key.b() == 1 ? this.d : null;
|
||||
}
|
||||
if (list == null) {
|
||||
return null;
|
||||
}
|
||||
for (KeyMap keyMap : list) {
|
||||
if (key.a().equals(keyMap.b())) {
|
||||
return keyMap.a();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void b(List<KeyMap> list) {
|
||||
e();
|
||||
a(list);
|
||||
d();
|
||||
}
|
||||
}
|
||||
260
sources/com/ubt/jimu/controller/manager/MoveConfigManager.java
Normal file
260
sources/com/ubt/jimu/controller/manager/MoveConfigManager.java
Normal file
@@ -0,0 +1,260 @@
|
||||
package com.ubt.jimu.controller.manager;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import com.ubt.jimu.base.cache.Cache;
|
||||
import com.ubt.jimu.base.db.diy.DiyDBModel;
|
||||
import com.ubt.jimu.base.db.diy.DiyHelper;
|
||||
import com.ubt.jimu.base.db.robot.RobotDbHandler;
|
||||
import com.ubt.jimu.base.entities.Robot;
|
||||
import com.ubt.jimu.base.entities.RobotLite;
|
||||
import com.ubt.jimu.base.util.FileUtil;
|
||||
import com.ubt.jimu.base.util.PathHelper;
|
||||
import com.ubt.jimu.controller.data.config.AccumulatorConfig;
|
||||
import com.ubt.jimu.controller.data.config.HSliderConfig;
|
||||
import com.ubt.jimu.controller.data.config.JockstickConfig;
|
||||
import com.ubt.jimu.controller.data.config.SliderConfig;
|
||||
import com.ubt.jimu.controller.data.config.WidgetConfig;
|
||||
import com.ubt.jimu.controller.data.widget.ControllerData;
|
||||
import com.ubt.jimu.controller.data.widget.MoveBaseData;
|
||||
import com.ubt.jimu.controller.data.widget.MoveWidgetData;
|
||||
import com.ubt.jimu.controller.util.XmlUtils;
|
||||
import com.ubt.jimu.transport.model.TransportFile;
|
||||
import com.ubt.jimu.transport3.UnityFileOperator;
|
||||
import com.ubt.jimu.transport3.dao.TransportFileDbHandler2;
|
||||
import com.ubt.jimu.utils.SystemUtils;
|
||||
import com.ubtech.utils.XLog;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class MoveConfigManager {
|
||||
private static MoveConfigManager d;
|
||||
private MoveWidgetData a;
|
||||
private RobotLite b;
|
||||
private Context c;
|
||||
|
||||
private MoveConfigManager(Context context) {
|
||||
this.c = context.getApplicationContext();
|
||||
}
|
||||
|
||||
public static synchronized MoveConfigManager a(Context context) {
|
||||
MoveConfigManager moveConfigManager;
|
||||
synchronized (MoveConfigManager.class) {
|
||||
if (d == null) {
|
||||
d = new MoveConfigManager(context);
|
||||
}
|
||||
moveConfigManager = d;
|
||||
}
|
||||
return moveConfigManager;
|
||||
}
|
||||
|
||||
public boolean b(SliderConfig sliderConfig) {
|
||||
MoveWidgetData moveWidgetData = this.a;
|
||||
return moveWidgetData == null || moveWidgetData.removeSliderconfig(sliderConfig);
|
||||
}
|
||||
|
||||
public List<HSliderConfig> c() {
|
||||
MoveWidgetData moveWidgetData = this.a;
|
||||
if (moveWidgetData != null) {
|
||||
return moveWidgetData.getHSliderConfigList();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<JockstickConfig> d() {
|
||||
MoveWidgetData moveWidgetData = this.a;
|
||||
if (moveWidgetData != null) {
|
||||
return moveWidgetData.getJockstickConfigList();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<MoveBaseData> e() {
|
||||
List<WidgetConfig> b = b();
|
||||
if (b == null || b.size() <= 0) {
|
||||
return null;
|
||||
}
|
||||
ArrayList arrayList = new ArrayList(b.size());
|
||||
Iterator<WidgetConfig> it = b.iterator();
|
||||
while (it.hasNext()) {
|
||||
arrayList.add(it.next().encapData());
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
public List<SliderConfig> f() {
|
||||
MoveWidgetData moveWidgetData = this.a;
|
||||
if (moveWidgetData != null) {
|
||||
return moveWidgetData.getSliderConfigList();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void g() {
|
||||
Object a;
|
||||
String moveConfigPath = PathHelper.getMoveConfigPath(this.c, this.b, true);
|
||||
File file = new File(moveConfigPath);
|
||||
if (this.b.isOfficial() && !file.exists()) {
|
||||
String moveConfigPath2 = PathHelper.getMoveConfigPath(this.c, this.b, false);
|
||||
if (!TextUtils.isEmpty(moveConfigPath2)) {
|
||||
File file2 = new File(moveConfigPath2);
|
||||
if (file2.exists() && file2.isFile()) {
|
||||
File parentFile = file.getParentFile();
|
||||
if (!parentFile.exists()) {
|
||||
parentFile.mkdirs();
|
||||
}
|
||||
FileUtil.copy(file2, file);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (TextUtils.isEmpty(moveConfigPath) || (a = XmlUtils.a(MoveWidgetData.class, moveConfigPath)) == null) {
|
||||
return;
|
||||
}
|
||||
this.a = (MoveWidgetData) a;
|
||||
}
|
||||
|
||||
public boolean b(HSliderConfig hSliderConfig) {
|
||||
MoveWidgetData moveWidgetData = this.a;
|
||||
return moveWidgetData == null || moveWidgetData.removeHSliderconfig(hSliderConfig);
|
||||
}
|
||||
|
||||
public boolean b(JockstickConfig jockstickConfig) {
|
||||
MoveWidgetData moveWidgetData = this.a;
|
||||
return moveWidgetData == null || moveWidgetData.removeJockstickConfig(jockstickConfig);
|
||||
}
|
||||
|
||||
public void a(RobotLite robotLite) {
|
||||
this.b = robotLite;
|
||||
this.a = null;
|
||||
g();
|
||||
}
|
||||
|
||||
public boolean b(AccumulatorConfig accumulatorConfig) {
|
||||
MoveWidgetData moveWidgetData = this.a;
|
||||
return moveWidgetData == null || moveWidgetData.removeAccumulatorConfig(accumulatorConfig);
|
||||
}
|
||||
|
||||
public List<WidgetConfig> b() {
|
||||
MoveWidgetData moveWidgetData = this.a;
|
||||
if (moveWidgetData != null) {
|
||||
return moveWidgetData.getConfigList();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean a(ControllerData controllerData) {
|
||||
if (controllerData == null) {
|
||||
return false;
|
||||
}
|
||||
MoveWidgetData moveWidgetData = this.a;
|
||||
if (moveWidgetData == null) {
|
||||
this.a = controllerData.getMoveConfig();
|
||||
return true;
|
||||
}
|
||||
return moveWidgetData.merge(controllerData);
|
||||
}
|
||||
|
||||
public void a(SliderConfig sliderConfig) {
|
||||
if (sliderConfig != null) {
|
||||
if (this.a == null) {
|
||||
this.a = new MoveWidgetData();
|
||||
}
|
||||
this.a.addSliderConfig(sliderConfig);
|
||||
}
|
||||
}
|
||||
|
||||
public void a(HSliderConfig hSliderConfig) {
|
||||
if (hSliderConfig != null) {
|
||||
if (this.a == null) {
|
||||
this.a = new MoveWidgetData();
|
||||
}
|
||||
this.a.addHSliderConfig(hSliderConfig);
|
||||
}
|
||||
}
|
||||
|
||||
public void a(JockstickConfig jockstickConfig) {
|
||||
if (jockstickConfig != null) {
|
||||
if (this.a == null) {
|
||||
this.a = new MoveWidgetData();
|
||||
}
|
||||
this.a.addJockstickConfig(jockstickConfig);
|
||||
}
|
||||
}
|
||||
|
||||
public void a(AccumulatorConfig accumulatorConfig) {
|
||||
if (accumulatorConfig != null) {
|
||||
if (this.a == null) {
|
||||
this.a = new MoveWidgetData();
|
||||
}
|
||||
this.a.addAccumulatorConfig(accumulatorConfig);
|
||||
}
|
||||
}
|
||||
|
||||
public void a(boolean z) {
|
||||
RobotLite robotLite;
|
||||
TransportFile transportModelFile;
|
||||
if (this.a == null || (robotLite = this.b) == null) {
|
||||
return;
|
||||
}
|
||||
String moveConfigPath = PathHelper.getMoveConfigPath(this.c, robotLite, true);
|
||||
File file = new File(moveConfigPath);
|
||||
int i = file.exists() ? 2 : 1;
|
||||
File parentFile = file.getParentFile();
|
||||
if (!parentFile.exists()) {
|
||||
parentFile.mkdirs();
|
||||
}
|
||||
XLog.c("woo", "save moveConfig to xml : %s", this.a.toString());
|
||||
XmlUtils.a(this.a, moveConfigPath);
|
||||
if (z) {
|
||||
if (!this.b.isOfficial()) {
|
||||
DiyDBModel queryForUUid = DiyHelper.getInstance().queryForUUid(this.b.getModelId());
|
||||
if (queryForUUid != null) {
|
||||
new UnityFileOperator(queryForUUid.getModelId().intValue(), queryForUUid.getCustomModelId(), 1, moveConfigPath, i).operateFile();
|
||||
String str = PathHelper.getControllerDir(this.c, this.b, true) + PathHelper.newControllerFileName(this.b.getModelId());
|
||||
if (!new File(str).exists() || (transportModelFile = TransportFileDbHandler2.getInstance().getTransportModelFile(Cache.getInstance().getUserId(), queryForUUid.getCustomModelId(), new File(str))) == null) {
|
||||
return;
|
||||
}
|
||||
long a = SystemUtils.a();
|
||||
transportModelFile.setModifyTime(a);
|
||||
transportModelFile.setLastUploadTime(a);
|
||||
transportModelFile.setUploaded(false);
|
||||
transportModelFile.setIsModify(true);
|
||||
TransportFileDbHandler2.getInstance().update(transportModelFile);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
String modelId = this.b.getModelId();
|
||||
Cache.getInstance().getUserId();
|
||||
Robot robotByModelName = RobotDbHandler.getRobotByModelName(modelId);
|
||||
long modelId2 = robotByModelName.getModelId();
|
||||
if (robotByModelName == null || modelId2 <= 0) {
|
||||
return;
|
||||
}
|
||||
new UnityFileOperator((int) modelId2, modelId, 1, moveConfigPath, i).officialModelFileOperator();
|
||||
}
|
||||
}
|
||||
|
||||
public List<AccumulatorConfig> a() {
|
||||
MoveWidgetData moveWidgetData = this.a;
|
||||
if (moveWidgetData != null) {
|
||||
return moveWidgetData.getAccumulatorConfigList();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public WidgetConfig a(String str) {
|
||||
List<WidgetConfig> b;
|
||||
if (!TextUtils.isEmpty(str) && (b = b()) != null && b.size() != 0) {
|
||||
for (WidgetConfig widgetConfig : b) {
|
||||
if (str.equals(widgetConfig.getConfigID())) {
|
||||
return widgetConfig;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
package com.ubt.jimu.controller.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.SystemClock;
|
||||
import android.text.TextUtils;
|
||||
import com.ubt.jimu.R;
|
||||
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.controller.data.command.AngleCommand;
|
||||
import com.ubt.jimu.controller.data.command.MoveCommand;
|
||||
import com.ubt.jimu.controller.data.config.AccumulatorConfig;
|
||||
import com.ubt.jimu.controller.manager.CommandManager;
|
||||
import com.ubt.jimu.controller.manager.MoveConfigManager;
|
||||
import com.ubt.jimu.controller.view.IAccumulatorSettingView;
|
||||
import com.ubtech.utils.XLog;
|
||||
import com.ubtrobot.jimu.robotapi.ServoAngleReadInfo;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.ObservableEmitter;
|
||||
import io.reactivex.ObservableOnSubscribe;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.functions.Consumer;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AccumulatorSettingPresenter extends SuperControllerPresenter<IAccumulatorSettingView> {
|
||||
public AccumulatorSettingPresenter(Context context, RobotLite robotLite) {
|
||||
super(context, robotLite);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.presenter.SuperControllerPresenter
|
||||
public boolean a(RobotLite robotLite) {
|
||||
IAccumulatorSettingView iAccumulatorSettingView;
|
||||
boolean a = super.a(robotLite);
|
||||
if (!a && (iAccumulatorSettingView = (IAccumulatorSettingView) b()) != null) {
|
||||
iAccumulatorSettingView.Y();
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.presenter.SuperControllerPresenter
|
||||
protected void b(List<? extends Engine> list) {
|
||||
List<AccumulatorConfig> a;
|
||||
if (list == null || list.size() <= 0 || (a = MoveConfigManager.a(this.c.getApplicationContext()).a()) == null || a.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
Iterator<AccumulatorConfig> it = a.iterator();
|
||||
while (it.hasNext()) {
|
||||
int servoID = it.next().getServoID();
|
||||
for (Engine engine : list) {
|
||||
if (servoID == engine.getId()) {
|
||||
engine.setConfigged(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.presenter.SuperControllerPresenter
|
||||
public boolean c(RobotLite robotLite) {
|
||||
return super.c(robotLite);
|
||||
}
|
||||
|
||||
public void a(AccumulatorConfig accumulatorConfig) {
|
||||
MoveConfigManager a = MoveConfigManager.a(this.c.getApplicationContext());
|
||||
a.b(accumulatorConfig);
|
||||
a.a(true);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.presenter.SuperControllerPresenter
|
||||
public String a(int i, ServoMode servoMode) {
|
||||
IAccumulatorSettingView iAccumulatorSettingView;
|
||||
String a = super.a(i, servoMode);
|
||||
if (TextUtils.isEmpty(a) || (iAccumulatorSettingView = (IAccumulatorSettingView) b()) == null) {
|
||||
return "";
|
||||
}
|
||||
iAccumulatorSettingView.d(String.format(this.c.getResources().getString(R.string.control_servo_mode_set), a));
|
||||
return "";
|
||||
}
|
||||
|
||||
public void a(RobotLite robotLite, int i, int i2) {
|
||||
if (!c(robotLite) || super.e()) {
|
||||
return;
|
||||
}
|
||||
HashMap hashMap = new HashMap(1);
|
||||
hashMap.put(Integer.valueOf(i), Integer.valueOf(i2 + 120));
|
||||
CommandManager.a(this.c.getApplicationContext()).a((MoveCommand) new AngleCommand(hashMap, 200, 0), false);
|
||||
}
|
||||
|
||||
public void a(final int i) {
|
||||
if (c(this.d)) {
|
||||
Observable.create(new ObservableOnSubscribe<List<ServoAngleReadInfo>>() { // from class: com.ubt.jimu.controller.presenter.AccumulatorSettingPresenter.1
|
||||
@Override // io.reactivex.ObservableOnSubscribe
|
||||
public void subscribe(ObservableEmitter<List<ServoAngleReadInfo>> observableEmitter) throws Exception {
|
||||
if (AccumulatorSettingPresenter.this.d() != null) {
|
||||
long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||
List<ServoAngleReadInfo> a = AccumulatorSettingPresenter.this.d().a(i, true);
|
||||
if (a == null || a.size() <= 0) {
|
||||
observableEmitter.onError(new Throwable("read servo angle failed"));
|
||||
return;
|
||||
}
|
||||
for (ServoAngleReadInfo servoAngleReadInfo : a) {
|
||||
servoAngleReadInfo.a(servoAngleReadInfo.a() - 120.0f);
|
||||
}
|
||||
XLog.a("Controller", "readAllServoAngle cost time: %d", Long.valueOf(SystemClock.elapsedRealtime() - elapsedRealtime));
|
||||
observableEmitter.onNext(a);
|
||||
}
|
||||
}
|
||||
}).subscribeOn(Schedulers.b()).observeOn(AndroidSchedulers.a()).subscribe(new Consumer<List<ServoAngleReadInfo>>() { // from class: com.ubt.jimu.controller.presenter.AccumulatorSettingPresenter.2
|
||||
@Override // io.reactivex.functions.Consumer
|
||||
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
||||
public void accept(List<ServoAngleReadInfo> list) throws Exception {
|
||||
XLog.a("Controller", "servoAngle: %s", list.toString());
|
||||
IAccumulatorSettingView iAccumulatorSettingView = (IAccumulatorSettingView) AccumulatorSettingPresenter.this.b();
|
||||
if (iAccumulatorSettingView != null) {
|
||||
iAccumulatorSettingView.g(list);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.ubt.jimu.controller.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.SystemClock;
|
||||
import android.text.TextUtils;
|
||||
import com.ubt.jimu.R;
|
||||
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.controller.data.command.AngleCommand;
|
||||
import com.ubt.jimu.controller.data.command.MoveCommand;
|
||||
import com.ubt.jimu.controller.data.config.HSliderConfig;
|
||||
import com.ubt.jimu.controller.manager.CommandManager;
|
||||
import com.ubt.jimu.controller.manager.MoveConfigManager;
|
||||
import com.ubt.jimu.controller.view.IAngleSettingView;
|
||||
import com.ubtech.utils.XLog;
|
||||
import com.ubtrobot.jimu.robotapi.ServoAngleReadInfo;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.ObservableEmitter;
|
||||
import io.reactivex.ObservableOnSubscribe;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.functions.Consumer;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AngleSettingPresenter extends SuperControllerPresenter<IAngleSettingView> {
|
||||
public AngleSettingPresenter(Context context, RobotLite robotLite) {
|
||||
super(context, robotLite);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.presenter.SuperControllerPresenter
|
||||
public String a(int i, ServoMode servoMode) {
|
||||
IAngleSettingView iAngleSettingView;
|
||||
String a = super.a(i, servoMode);
|
||||
if (TextUtils.isEmpty(a) || (iAngleSettingView = (IAngleSettingView) b()) == null) {
|
||||
return "";
|
||||
}
|
||||
iAngleSettingView.d(String.format(this.c.getResources().getString(R.string.control_servo_mode_set), a));
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.presenter.SuperControllerPresenter
|
||||
void b(List<? extends Engine> list) {
|
||||
if (list == null || list.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
XLog.a("woo", "servolist: %s", list.toString());
|
||||
List<HSliderConfig> c = MoveConfigManager.a(this.c.getApplicationContext()).c();
|
||||
if (c == null || c.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
Iterator<HSliderConfig> it = c.iterator();
|
||||
while (it.hasNext()) {
|
||||
int servoID = it.next().getServoID();
|
||||
for (Engine engine : list) {
|
||||
if (servoID == engine.getId()) {
|
||||
engine.setConfigged(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void a(HSliderConfig hSliderConfig) {
|
||||
MoveConfigManager a = MoveConfigManager.a(this.c.getApplicationContext());
|
||||
a.b(hSliderConfig);
|
||||
a.a(true);
|
||||
}
|
||||
|
||||
public void a(RobotLite robotLite, int i, int i2) {
|
||||
if (!c(robotLite) || super.e()) {
|
||||
return;
|
||||
}
|
||||
HashMap hashMap = new HashMap(1);
|
||||
hashMap.put(Integer.valueOf(i), Integer.valueOf(i2 + 120));
|
||||
CommandManager.a(this.c.getApplicationContext()).a((MoveCommand) new AngleCommand(hashMap, 200, 0), false);
|
||||
}
|
||||
|
||||
public void a(final int i) {
|
||||
if (c(this.d)) {
|
||||
Observable.create(new ObservableOnSubscribe<List<ServoAngleReadInfo>>() { // from class: com.ubt.jimu.controller.presenter.AngleSettingPresenter.1
|
||||
@Override // io.reactivex.ObservableOnSubscribe
|
||||
public void subscribe(ObservableEmitter<List<ServoAngleReadInfo>> observableEmitter) throws Exception {
|
||||
if (AngleSettingPresenter.this.d() != null) {
|
||||
long elapsedRealtime = SystemClock.elapsedRealtime();
|
||||
List<ServoAngleReadInfo> a = AngleSettingPresenter.this.d().a(i, true);
|
||||
if (a == null || a.size() <= 0) {
|
||||
observableEmitter.onError(new Throwable("read servo angle failed"));
|
||||
return;
|
||||
}
|
||||
for (ServoAngleReadInfo servoAngleReadInfo : a) {
|
||||
servoAngleReadInfo.a(servoAngleReadInfo.a() - 120.0f);
|
||||
}
|
||||
XLog.a("Controller", "readAllServoAngle cost time: %d", Long.valueOf(SystemClock.elapsedRealtime() - elapsedRealtime));
|
||||
observableEmitter.onNext(a);
|
||||
}
|
||||
}
|
||||
}).subscribeOn(Schedulers.b()).observeOn(AndroidSchedulers.a()).subscribe(new Consumer<List<ServoAngleReadInfo>>() { // from class: com.ubt.jimu.controller.presenter.AngleSettingPresenter.2
|
||||
@Override // io.reactivex.functions.Consumer
|
||||
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
||||
public void accept(List<ServoAngleReadInfo> list) throws Exception {
|
||||
XLog.a("Controller", "servoAngle: %s", list.toString());
|
||||
IAngleSettingView iAngleSettingView = (IAngleSettingView) AngleSettingPresenter.this.b();
|
||||
if (iAngleSettingView != null) {
|
||||
iAngleSettingView.g(list);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
28
sources/com/ubt/jimu/controller/presenter/BasePresenter.java
Normal file
28
sources/com/ubt/jimu/controller/presenter/BasePresenter.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package com.ubt.jimu.controller.presenter;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class BasePresenter<V> {
|
||||
private WeakReference<V> a;
|
||||
|
||||
protected void a(V v) {
|
||||
this.a = new WeakReference<>(v);
|
||||
}
|
||||
|
||||
protected V b() {
|
||||
WeakReference<V> weakReference = this.a;
|
||||
if (weakReference != null) {
|
||||
return weakReference.get();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void a() {
|
||||
WeakReference<V> weakReference = this.a;
|
||||
if (weakReference != null) {
|
||||
weakReference.clear();
|
||||
this.a = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,704 @@
|
||||
package com.ubt.jimu.controller.presenter;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.InputDevice;
|
||||
import com.orhanobut.logger.Printer;
|
||||
import com.ubt.jimu.JimuApplication;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.base.EngineManager;
|
||||
import com.ubt.jimu.base.cache.Cache;
|
||||
import com.ubt.jimu.base.cache.SharePreferenceHelper;
|
||||
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.db.diy.DiyDBModel;
|
||||
import com.ubt.jimu.base.db.diy.DiyHelper;
|
||||
import com.ubt.jimu.base.db.robot.RobotDbHandler;
|
||||
import com.ubt.jimu.base.entities.Robot;
|
||||
import com.ubt.jimu.base.entities.RobotLite;
|
||||
import com.ubt.jimu.base.http.ApiResponse;
|
||||
import com.ubt.jimu.connect.ConnectActivity;
|
||||
import com.ubt.jimu.controller.data.action.ActionSequence;
|
||||
import com.ubt.jimu.controller.data.action.MotorData;
|
||||
import com.ubt.jimu.controller.data.action.TurnData;
|
||||
import com.ubt.jimu.controller.data.command.AccumulatorGear;
|
||||
import com.ubt.jimu.controller.data.command.AngleCommand;
|
||||
import com.ubt.jimu.controller.data.command.Gear;
|
||||
import com.ubt.jimu.controller.data.command.MotorCommand;
|
||||
import com.ubt.jimu.controller.data.command.MoveCommand;
|
||||
import com.ubt.jimu.controller.data.command.ShootCommand;
|
||||
import com.ubt.jimu.controller.data.command.TurnCommand;
|
||||
import com.ubt.jimu.controller.data.config.AccumulatorConfig;
|
||||
import com.ubt.jimu.controller.data.config.HSliderConfig;
|
||||
import com.ubt.jimu.controller.data.config.JockstickConfig;
|
||||
import com.ubt.jimu.controller.data.config.SliderConfig;
|
||||
import com.ubt.jimu.controller.data.config.Wheel;
|
||||
import com.ubt.jimu.controller.data.config.WidgetConfig;
|
||||
import com.ubt.jimu.controller.data.keymap.KeyMap;
|
||||
import com.ubt.jimu.controller.data.keymap.entity.Key;
|
||||
import com.ubt.jimu.controller.data.widget.ControllerData;
|
||||
import com.ubt.jimu.controller.manager.ActionManager;
|
||||
import com.ubt.jimu.controller.manager.CommandManager;
|
||||
import com.ubt.jimu.controller.manager.ControllerManager;
|
||||
import com.ubt.jimu.controller.manager.KeyMapManager;
|
||||
import com.ubt.jimu.controller.manager.MoveConfigManager;
|
||||
import com.ubt.jimu.controller.syn.OfficialSyncExecutor;
|
||||
import com.ubt.jimu.controller.view.IControllerView;
|
||||
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.LocaleUtils;
|
||||
import com.ubt.jimu.utils.LogUtils;
|
||||
import com.ubt.jimu.utils.SystemUtils;
|
||||
import com.ubtech.utils.XLog;
|
||||
import com.ubtrobot.jimu.bluetooth.ConnectionState;
|
||||
import com.ubtrobot.jimu.robotapi.BatteryInfo;
|
||||
import com.ubtrobot.jimu.robotapi.JimuException;
|
||||
import com.ubtrobot.jimu.robotapi.JimuManager;
|
||||
import com.ubtrobot.log.ALog;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.TreeMap;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ControllerPresenter extends SuperControllerPresenter<IControllerView> {
|
||||
private HandlerThread f;
|
||||
private Handler g;
|
||||
private KeyMapManager h;
|
||||
private List<KeyMap> i;
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
public ControllerPresenter(Context context, RobotLite robotLite) {
|
||||
super(context, robotLite);
|
||||
this.i = new ArrayList();
|
||||
a((ControllerPresenter) context);
|
||||
this.f = new HandlerThread("ControllerThread");
|
||||
this.f.start();
|
||||
this.g = new Handler(this.f.getLooper());
|
||||
CommandManager.a(this.c.getApplicationContext()).a(JimuApplication.l().f());
|
||||
this.h = new KeyMapManager(context);
|
||||
}
|
||||
|
||||
private void A() {
|
||||
IControllerView iControllerView = (IControllerView) b();
|
||||
if (iControllerView != null) {
|
||||
iControllerView.z();
|
||||
}
|
||||
}
|
||||
|
||||
private MoveCommand c(int i, Gear gear, int i2, Gear gear2, JockstickConfig jockstickConfig) {
|
||||
TreeMap treeMap = new TreeMap();
|
||||
List<Wheel> wheelList = jockstickConfig.getWheelList();
|
||||
if (wheelList == null || wheelList.size() <= 0) {
|
||||
return null;
|
||||
}
|
||||
for (Wheel wheel : wheelList) {
|
||||
if (wheel != null) {
|
||||
if (wheel.getPosition() % 2 == 0) {
|
||||
treeMap.put(Integer.valueOf(wheel.getId()), new TurnData(wheel.isReverse() ? -i2 : i2, gear2.getTurnSpeed()));
|
||||
} else {
|
||||
treeMap.put(Integer.valueOf(wheel.getId()), new TurnData(wheel.isReverse() ? -i : i, gear.getTurnSpeed()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return new TurnCommand(treeMap);
|
||||
}
|
||||
|
||||
public float a(float f) {
|
||||
if (f < 0.1f) {
|
||||
return 0.0f;
|
||||
}
|
||||
if (f < 0.4f) {
|
||||
return 0.4f;
|
||||
}
|
||||
return f < 0.7f ? 0.7f : 1.0f;
|
||||
}
|
||||
|
||||
public void a(RobotLite robotLite, String str) {
|
||||
IControllerView iControllerView = (IControllerView) b();
|
||||
if (robotLite == null || TextUtils.isEmpty(robotLite.getModelId())) {
|
||||
XLog.b("woo", "Robot is null");
|
||||
if (iControllerView != null) {
|
||||
iControllerView.j();
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
this.d = robotLite;
|
||||
ControllerManager.a(this.c.getApplicationContext()).a(robotLite);
|
||||
ControllerData a = ControllerManager.a(this.c.getApplicationContext()).a();
|
||||
Printer a2 = ALog.a("woo");
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("controllerData: ");
|
||||
sb.append(a != null ? a.toString() : "ControllerData is Null!");
|
||||
a2.d(sb.toString());
|
||||
if (this.b == null) {
|
||||
b(robotLite);
|
||||
this.b.createPeripheralConn(str);
|
||||
}
|
||||
CommandManager.a(this.c.getApplicationContext()).a(this.b);
|
||||
m();
|
||||
if (iControllerView != null) {
|
||||
iControllerView.a(a);
|
||||
}
|
||||
}
|
||||
|
||||
public void b(ActionSequence actionSequence) {
|
||||
if (actionSequence != null) {
|
||||
CommandManager.a(this.c.getApplicationContext()).c(actionSequence);
|
||||
A();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.presenter.SuperControllerPresenter
|
||||
void b(List<? extends Engine> list) {
|
||||
}
|
||||
|
||||
public void d(RobotLite robotLite) {
|
||||
this.h.a(robotLite);
|
||||
this.h.c();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.presenter.SuperControllerPresenter
|
||||
public boolean e() {
|
||||
BatteryInfo f = JimuApplication.l().f().f();
|
||||
if (f == null || !f.d()) {
|
||||
return false;
|
||||
}
|
||||
return new SharePreferenceHelper().getBoolean(SharePreferenceHelper.SP_KEY_ELECTRICITY_PROTECT, true).booleanValue();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.presenter.SuperControllerPresenter
|
||||
public void h() {
|
||||
if (r()) {
|
||||
y();
|
||||
}
|
||||
Handler handler = this.g;
|
||||
if (handler != null) {
|
||||
handler.removeCallbacksAndMessages(null);
|
||||
this.f.quit();
|
||||
this.f = null;
|
||||
}
|
||||
super.h();
|
||||
}
|
||||
|
||||
public void k() {
|
||||
ALog.a("ControllerPresenter").d("clearTmpMapList");
|
||||
this.i.clear();
|
||||
}
|
||||
|
||||
public void l() {
|
||||
if (this.d.isOfficial()) {
|
||||
Robot robotByModelName = RobotDbHandler.getRobotByModelName(this.d.getModelId());
|
||||
if (robotByModelName != null) {
|
||||
ConnectActivity.a(101, (Activity) this.c, robotByModelName.getRobotLite());
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
DiyDBModel queryForUUid = DiyHelper.getInstance().queryForUUid(this.d.getModelId());
|
||||
if (queryForUUid != null) {
|
||||
ConnectActivity.a(101, (Activity) this.c, queryForUUid.getRobotLite());
|
||||
}
|
||||
}
|
||||
|
||||
public void m() {
|
||||
List<KeyMap> o = o();
|
||||
ArrayList<KeyMap> arrayList = new ArrayList();
|
||||
for (KeyMap keyMap : o) {
|
||||
if (ActionManager.a(this.c).a(keyMap.a()) == null) {
|
||||
arrayList.add(keyMap);
|
||||
}
|
||||
}
|
||||
for (KeyMap keyMap2 : arrayList) {
|
||||
this.h.a(keyMap2);
|
||||
ALog.a("ControllerPresenter").d("Action has be deleted! delete keymap:" + keyMap2);
|
||||
}
|
||||
}
|
||||
|
||||
public void n() {
|
||||
if (this.d.isOfficial()) {
|
||||
Robot robotByModelName = RobotDbHandler.getRobotByModelName(this.d.getModelId());
|
||||
if (robotByModelName != null) {
|
||||
ConnectActivity.b(102, (Activity) this.c, robotByModelName.getRobotLite());
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
DiyDBModel queryForUUid = DiyHelper.getInstance().queryForUUid(this.d.getModelId());
|
||||
if (queryForUUid != null) {
|
||||
ConnectActivity.b(102, (Activity) this.c, queryForUUid.getRobotLite());
|
||||
}
|
||||
}
|
||||
|
||||
public List<KeyMap> o() {
|
||||
return this.h.a();
|
||||
}
|
||||
|
||||
public ArrayList<Integer> p() {
|
||||
ArrayList<Integer> arrayList = new ArrayList<>();
|
||||
for (int i : InputDevice.getDeviceIds()) {
|
||||
int sources = InputDevice.getDevice(i).getSources();
|
||||
if ((sources & 1025) == 1025 && (sources & 16777232) == 16777232 && !arrayList.contains(Integer.valueOf(i))) {
|
||||
arrayList.add(Integer.valueOf(i));
|
||||
}
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
public List<KeyMap> q() {
|
||||
return this.h.b();
|
||||
}
|
||||
|
||||
public boolean r() {
|
||||
JimuManager f = JimuApplication.l().f();
|
||||
return f != null && f.b(this.d.getModelId()) == ConnectionState.STATE_CONNECTED;
|
||||
}
|
||||
|
||||
public boolean s() {
|
||||
ArrayList<Integer> p = p();
|
||||
return (p == null || p.isEmpty()) ? false : true;
|
||||
}
|
||||
|
||||
public /* synthetic */ void t() {
|
||||
try {
|
||||
a(JimuApplication.l().f().k());
|
||||
} catch (JimuException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void u() {
|
||||
ALog.a("ControllerPresenter").d("loadTmpKeyMapList");
|
||||
k();
|
||||
c(o());
|
||||
List<KeyMap> q = q();
|
||||
if (q == null || q.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
c(q);
|
||||
}
|
||||
|
||||
public void v() {
|
||||
CommandManager.a(this.c.getApplicationContext()).b(this.b.getEngineList(Cache.getInstance().getUserId()));
|
||||
}
|
||||
|
||||
public void w() {
|
||||
this.g.post(new Runnable() { // from class: com.ubt.jimu.controller.presenter.b
|
||||
@Override // java.lang.Runnable
|
||||
public final void run() {
|
||||
ControllerPresenter.this.t();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void x() {
|
||||
ALog.a("ControllerPresenter").d("saveMapList");
|
||||
this.h.b(this.i);
|
||||
}
|
||||
|
||||
public void y() {
|
||||
if (this.b != null) {
|
||||
CommandManager.a(this.c.getApplicationContext()).a(this.b.getEngineList(Cache.getInstance().getUserId()));
|
||||
}
|
||||
}
|
||||
|
||||
public void z() {
|
||||
DiyDBModel queryForUUid;
|
||||
if (this.d.isOfficial() || (queryForUUid = DiyHelper.getInstance().queryForUUid(this.d.getModelId())) == null || queryForUUid.isControllerComplete()) {
|
||||
return;
|
||||
}
|
||||
queryForUUid.setControllerComplete();
|
||||
long a = SystemUtils.a();
|
||||
queryForUUid.setModifyTime(a);
|
||||
queryForUUid.setLastUploadTime(a);
|
||||
queryForUUid.setIsModify(true);
|
||||
DiyDBModelDBHandler.getInstance().insertOrUpdate(queryForUUid);
|
||||
a(queryForUUid);
|
||||
}
|
||||
|
||||
private void b(List<Integer> list, ServoMode servoMode) {
|
||||
IControllerView iControllerView = (IControllerView) b();
|
||||
if (iControllerView != null) {
|
||||
iControllerView.a(list, servoMode);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean b(int i, ServoMode servoMode) {
|
||||
EngineManager engineManager = this.b;
|
||||
if (engineManager == null || engineManager.getServoMode(i) == servoMode) {
|
||||
return true;
|
||||
}
|
||||
ArrayList arrayList = new ArrayList();
|
||||
arrayList.add(Integer.valueOf(i));
|
||||
b(arrayList, servoMode);
|
||||
return false;
|
||||
}
|
||||
|
||||
public void e(RobotLite robotLite) {
|
||||
IControllerView iControllerView = (IControllerView) b();
|
||||
if (iControllerView != null) {
|
||||
iControllerView.c();
|
||||
}
|
||||
this.d = robotLite;
|
||||
ExecutorService newSingleThreadExecutor = Executors.newSingleThreadExecutor();
|
||||
OfficialSyncExecutor officialSyncExecutor = new OfficialSyncExecutor(this.d);
|
||||
officialSyncExecutor.a(new OfficialSyncExecutor.SyncCompletedListener() { // from class: com.ubt.jimu.controller.presenter.ControllerPresenter.2
|
||||
@Override // com.ubt.jimu.controller.syn.OfficialSyncExecutor.SyncCompletedListener
|
||||
public void a() {
|
||||
LogUtils.c("syncOfficialData 下载逻辑全部完成");
|
||||
ControllerPresenter controllerPresenter = ControllerPresenter.this;
|
||||
controllerPresenter.a(controllerPresenter.d, Cache.getInstance().getUserId());
|
||||
}
|
||||
});
|
||||
newSingleThreadExecutor.submit(officialSyncExecutor);
|
||||
}
|
||||
|
||||
private MoveCommand b(int i, Gear gear, int i2, Gear gear2, JockstickConfig jockstickConfig) {
|
||||
TreeMap treeMap = new TreeMap();
|
||||
List<Wheel> wheelList = jockstickConfig.getWheelList();
|
||||
if (wheelList == null || wheelList.size() <= 0) {
|
||||
return null;
|
||||
}
|
||||
for (Wheel wheel : wheelList) {
|
||||
if (wheel != null) {
|
||||
if (wheel.getPosition() % 2 == 0) {
|
||||
treeMap.put(Integer.valueOf(wheel.getId()), new MotorData(wheel.isReverse() ? -i2 : i2, gear2.getMotorSpeed(), 6553500));
|
||||
} else {
|
||||
treeMap.put(Integer.valueOf(wheel.getId()), new MotorData(wheel.isReverse() ? -i : i, gear.getMotorSpeed(), 6553500));
|
||||
}
|
||||
}
|
||||
}
|
||||
return new MotorCommand(treeMap);
|
||||
}
|
||||
|
||||
private MoveCommand c(int i, float f, int i2, float f2, JockstickConfig jockstickConfig) {
|
||||
TreeMap treeMap = new TreeMap();
|
||||
List<Wheel> wheelList = jockstickConfig.getWheelList();
|
||||
if (wheelList == null || wheelList.size() <= 0) {
|
||||
return null;
|
||||
}
|
||||
for (Wheel wheel : wheelList) {
|
||||
if (wheel != null) {
|
||||
if (wheel.getPosition() % 2 == 0) {
|
||||
treeMap.put(Integer.valueOf(wheel.getId()), new TurnData(wheel.isReverse() ? -i2 : i2, (int) (TurnData.e() * f2)));
|
||||
} else {
|
||||
treeMap.put(Integer.valueOf(wheel.getId()), new TurnData(wheel.isReverse() ? -i : i, (int) (TurnData.e() * f)));
|
||||
}
|
||||
}
|
||||
}
|
||||
return new TurnCommand(treeMap);
|
||||
}
|
||||
|
||||
public void a(ControllerData controllerData) {
|
||||
ControllerManager.a(this.c.getApplicationContext()).a(controllerData, true);
|
||||
}
|
||||
|
||||
public void a(DiyDBModel diyDBModel) {
|
||||
if (diyDBModel.getModelId().intValue() <= 0) {
|
||||
return;
|
||||
}
|
||||
DiyTransportServiceImpl.getInstance().updateModel(diyDBModel, new Observer<ApiResponse<SaveOrUpdateModelBean>>(this) { // from class: com.ubt.jimu.controller.presenter.ControllerPresenter.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) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void a(ActionSequence actionSequence) {
|
||||
if (actionSequence != null) {
|
||||
LogUtils.c("ControllerPresenter playAction:" + actionSequence.a().get(0).c());
|
||||
String a = actionSequence.a(LocaleUtils.b());
|
||||
if (TextUtils.isEmpty(a)) {
|
||||
a = actionSequence.h();
|
||||
}
|
||||
a((String) null, a, (String) null);
|
||||
CommandManager.a(this.c.getApplicationContext()).a(actionSequence);
|
||||
}
|
||||
}
|
||||
|
||||
private MoveCommand b(int i, float f, int i2, float f2, JockstickConfig jockstickConfig) {
|
||||
TreeMap treeMap = new TreeMap();
|
||||
List<Wheel> wheelList = jockstickConfig.getWheelList();
|
||||
if (wheelList == null || wheelList.size() <= 0) {
|
||||
return null;
|
||||
}
|
||||
for (Wheel wheel : wheelList) {
|
||||
if (wheel != null) {
|
||||
if (wheel.getPosition() % 2 == 0) {
|
||||
treeMap.put(Integer.valueOf(wheel.getId()), new MotorData(wheel.isReverse() ? -i2 : i2, (int) (MotorData.e() * f2), 6553500));
|
||||
} else {
|
||||
treeMap.put(Integer.valueOf(wheel.getId()), new MotorData(wheel.isReverse() ? -i : i, (int) (MotorData.e() * f), 6553500));
|
||||
}
|
||||
}
|
||||
}
|
||||
return new MotorCommand(treeMap);
|
||||
}
|
||||
|
||||
public void c(List<KeyMap> list) {
|
||||
ALog.a("ControllerPresenter").d("addTmpKeyMapAllList");
|
||||
for (KeyMap keyMap : list) {
|
||||
ALog.a("ControllerPresenter").d("add tmp keyMap:" + keyMap);
|
||||
}
|
||||
this.i.addAll(list);
|
||||
}
|
||||
|
||||
private void a(String str, String str2, String str3) {
|
||||
IControllerView iControllerView = (IControllerView) b();
|
||||
if (iControllerView != null) {
|
||||
iControllerView.a(str, str2, str3);
|
||||
}
|
||||
}
|
||||
|
||||
private void a(BatteryInfo batteryInfo) {
|
||||
XLog.c("woo", "BatteryInfo : %s", batteryInfo.toString());
|
||||
IControllerView iControllerView = (IControllerView) b();
|
||||
if (iControllerView != null) {
|
||||
iControllerView.a(batteryInfo);
|
||||
}
|
||||
}
|
||||
|
||||
private Gear b(float f) {
|
||||
if (f < 0.1f) {
|
||||
return Gear.EMPTY;
|
||||
}
|
||||
if (f < 0.3f) {
|
||||
return Gear.FIRST;
|
||||
}
|
||||
if (f < 0.5f) {
|
||||
return Gear.SECOND;
|
||||
}
|
||||
if (f < 0.7f) {
|
||||
return Gear.THIRD;
|
||||
}
|
||||
if (f < 0.9f) {
|
||||
return Gear.FOURTH;
|
||||
}
|
||||
return Gear.FIFTH;
|
||||
}
|
||||
|
||||
public void a(MoveCommand moveCommand, boolean z) {
|
||||
CommandManager.a(this.c.getApplicationContext()).a(moveCommand, z);
|
||||
}
|
||||
|
||||
public void a(SliderConfig sliderConfig, Gear gear, int i) {
|
||||
MoveCommand a;
|
||||
int servoID = sliderConfig.getServoID();
|
||||
sliderConfig.getMotionType();
|
||||
if ((sliderConfig.getMotionType() != CtrlMotionType.servo || b(servoID, ServoMode.SERVO_MODE_TURN)) && (a = a(sliderConfig, gear, i, servoID)) != null) {
|
||||
a(a, gear == Gear.EMPTY || i == 0);
|
||||
}
|
||||
}
|
||||
|
||||
private MoveCommand a(SliderConfig sliderConfig, Gear gear, int i, int i2) {
|
||||
if (sliderConfig.getMotionType() == CtrlMotionType.servo) {
|
||||
HashMap hashMap = new HashMap(1);
|
||||
hashMap.put(Integer.valueOf(i2), new TurnData(i, gear.getTurnSpeed()));
|
||||
return new TurnCommand(hashMap);
|
||||
}
|
||||
if (sliderConfig.getMotionType() != CtrlMotionType.motor) {
|
||||
return null;
|
||||
}
|
||||
HashMap hashMap2 = new HashMap(1);
|
||||
hashMap2.put(Integer.valueOf(i2), new MotorData(i, gear.getMotorSpeed(), 6553500));
|
||||
return new MotorCommand(hashMap2);
|
||||
}
|
||||
|
||||
private boolean a(List<Integer> list, ServoMode servoMode) {
|
||||
boolean z = true;
|
||||
if (this.b != null && list != null && list.size() > 0) {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
Iterator<Integer> it = list.iterator();
|
||||
while (it.hasNext()) {
|
||||
int intValue = it.next().intValue();
|
||||
if (this.b.getServoMode(intValue) != servoMode) {
|
||||
arrayList.add(Integer.valueOf(intValue));
|
||||
z = false;
|
||||
}
|
||||
}
|
||||
if (!z) {
|
||||
b(arrayList, servoMode);
|
||||
}
|
||||
}
|
||||
return z;
|
||||
}
|
||||
|
||||
public void a(HSliderConfig hSliderConfig, int i) {
|
||||
HashMap hashMap = new HashMap(1);
|
||||
int servoID = hSliderConfig.getServoID();
|
||||
CtrlMotionType ctrlMotionType = CtrlMotionType.servo;
|
||||
if (b(servoID, ServoMode.SERVO_MODE_ANGLE)) {
|
||||
hashMap.put(Integer.valueOf(servoID), Integer.valueOf(i + 120));
|
||||
a((MoveCommand) new AngleCommand(hashMap, 200, 0), false);
|
||||
}
|
||||
}
|
||||
|
||||
public void a(AccumulatorConfig accumulatorConfig, int i) {
|
||||
int servoID = accumulatorConfig.getServoID();
|
||||
CtrlMotionType ctrlMotionType = CtrlMotionType.servo;
|
||||
if (b(servoID, ServoMode.SERVO_MODE_ANGLE)) {
|
||||
a((MoveCommand) new ShootCommand(accumulatorConfig, i), false);
|
||||
}
|
||||
}
|
||||
|
||||
public void a(int i, Gear gear, int i2, Gear gear2, JockstickConfig jockstickConfig) {
|
||||
if (jockstickConfig != null) {
|
||||
MoveCommand moveCommand = null;
|
||||
jockstickConfig.getMotionType();
|
||||
if (jockstickConfig.getMotionType() == CtrlMotionType.servo) {
|
||||
if (!a(jockstickConfig.getServoList(), ServoMode.SERVO_MODE_TURN)) {
|
||||
return;
|
||||
} else {
|
||||
moveCommand = c(i, gear, i2, gear2, jockstickConfig);
|
||||
}
|
||||
} else if (jockstickConfig.getMotionType() == CtrlMotionType.motor) {
|
||||
moveCommand = b(i, gear, i2, gear2, jockstickConfig);
|
||||
}
|
||||
if (moveCommand != null) {
|
||||
a(moveCommand, (gear == Gear.EMPTY || i == 0) && (gear2 == Gear.EMPTY || i2 == 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void a(int i, float f, int i2, float f2, JockstickConfig jockstickConfig) {
|
||||
if (jockstickConfig != null) {
|
||||
MoveCommand moveCommand = null;
|
||||
jockstickConfig.getMotionType();
|
||||
if (jockstickConfig.getMotionType() == CtrlMotionType.servo) {
|
||||
if (!a(jockstickConfig.getServoList(), ServoMode.SERVO_MODE_TURN)) {
|
||||
return;
|
||||
} else {
|
||||
moveCommand = c(i, f, i2, f2, jockstickConfig);
|
||||
}
|
||||
} else if (jockstickConfig.getMotionType() == CtrlMotionType.motor) {
|
||||
moveCommand = b(i, f, i2, f2, jockstickConfig);
|
||||
}
|
||||
if (moveCommand != null) {
|
||||
a(moveCommand, (f == 0.0f || i == 0) && (f2 == 0.0f || i2 == 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void a(AccumulatorConfig accumulatorConfig) {
|
||||
HashMap hashMap = new HashMap(1);
|
||||
hashMap.put(Integer.valueOf(accumulatorConfig.getServoID()), Integer.valueOf(accumulatorConfig.getStartAngle() + 120));
|
||||
CommandManager.a(this.c).a((MoveCommand) new AngleCommand(hashMap, 200, 0), false);
|
||||
}
|
||||
|
||||
/* JADX WARN: Removed duplicated region for block: B:18:0x0161 */
|
||||
/* JADX WARN: Removed duplicated region for block: B:21:? A[RETURN, SYNTHETIC] */
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
public void a(float r33, float r34, float r35, com.ubt.jimu.controller.data.config.JockstickConfig r36) {
|
||||
/*
|
||||
Method dump skipped, instructions count: 369
|
||||
To view this dump change 'Code comments level' option to 'DEBUG'
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.ubt.jimu.controller.presenter.ControllerPresenter.a(float, float, float, com.ubt.jimu.controller.data.config.JockstickConfig):void");
|
||||
}
|
||||
|
||||
private boolean a(double d) {
|
||||
return d <= 11.25d || 360.0d - d <= 11.25d || Math.abs(d - 90.0d) <= 11.25d || Math.abs(d - 180.0d) <= 11.25d || Math.abs(d - 270.0d) <= 11.25d;
|
||||
}
|
||||
|
||||
public void a(float f, HSliderConfig hSliderConfig) {
|
||||
float f2 = (f + 100.0f) / 200.0f;
|
||||
if (f2 > 1.0f) {
|
||||
f2 = 1.0f;
|
||||
} else if (f2 < 0.0f) {
|
||||
f2 = 0.0f;
|
||||
}
|
||||
int minAngle = hSliderConfig.getMinAngle() + ((int) (f2 * (hSliderConfig.getMaxAngle() - hSliderConfig.getMinAngle())));
|
||||
a(this.c.getResources().getString(R.string.angle_min_txt) + ": " + hSliderConfig.getMinAngle() + "°", String.format(this.c.getResources().getString(R.string.servo_mode_servo_index), Integer.valueOf(hSliderConfig.getServoID())) + ": " + minAngle + "°", this.c.getResources().getString(R.string.angle_max_txt) + ": " + hSliderConfig.getMaxAngle() + "°");
|
||||
a(hSliderConfig, minAngle);
|
||||
}
|
||||
|
||||
public void a(float f, SliderConfig sliderConfig) {
|
||||
int i = f > 0.0f ? 1 : f < 0.0f ? -1 : 0;
|
||||
if (sliderConfig.isDirectionDisclock()) {
|
||||
i = -i;
|
||||
}
|
||||
Gear b = b(Math.abs(f) / 100.0f);
|
||||
String format = String.format(this.c.getResources().getString(R.string.servo_mode_servo_index), Integer.valueOf(sliderConfig.getServoID()));
|
||||
int turnSpeed = b.getTurnSpeed();
|
||||
if (sliderConfig.getMotionType() == CtrlMotionType.motor) {
|
||||
format = String.format(this.c.getResources().getString(R.string.control_motor_index), Integer.valueOf(sliderConfig.getServoID()));
|
||||
turnSpeed = (b.getMotorSpeed() * 360) / 60;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder(format);
|
||||
sb.append(": ");
|
||||
Context context = this.c;
|
||||
sb.append(i < 0 ? context.getResources().getString(R.string.control_disclockwise) : context.getResources().getString(R.string.control_clockwise));
|
||||
sb.append(turnSpeed);
|
||||
sb.append("°/s");
|
||||
a((String) null, sb.toString(), (String) null);
|
||||
a(sliderConfig, b, i);
|
||||
}
|
||||
|
||||
public String a(Key key) {
|
||||
return this.h.a(key);
|
||||
}
|
||||
|
||||
public void a(String str) {
|
||||
WidgetConfig a = MoveConfigManager.a(this.c.getApplicationContext()).a(str);
|
||||
if (a == null) {
|
||||
Log.i("ControllerPresenter", "JoyStick Config has be deleted, delete the keymap. deleted config:" + a);
|
||||
this.h.a(str);
|
||||
}
|
||||
}
|
||||
|
||||
public void a(KeyMap keyMap) {
|
||||
ALog.a("ControllerPresenter").d("addTmpKeyMap keyMap:" + keyMap);
|
||||
if (keyMap == null) {
|
||||
return;
|
||||
}
|
||||
Iterator<KeyMap> it = this.i.iterator();
|
||||
while (it.hasNext()) {
|
||||
KeyMap next = it.next();
|
||||
if (keyMap.b().equals(next.b())) {
|
||||
ALog.a("ControllerPresenter").d("remove tmp keyMap key same to add. remove keymap:" + keyMap);
|
||||
it.remove();
|
||||
} else if (keyMap.a().equals(next.a())) {
|
||||
ALog.a("ControllerPresenter").d("remove tmp keyMap actionId same to add. remove keymap:" + keyMap);
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
this.i.add(keyMap);
|
||||
}
|
||||
|
||||
public void a(float f, AccumulatorConfig accumulatorConfig) {
|
||||
int a = AccumulatorGear.a(f / 100.0f, Math.abs(accumulatorConfig.getLaunchAngle() - accumulatorConfig.getStartAngle()));
|
||||
if (a > 0) {
|
||||
a(accumulatorConfig, a);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.ubt.jimu.controller.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
import com.ubt.jimu.base.data.CtrlMotionType;
|
||||
import com.ubt.jimu.base.data.Engine;
|
||||
import com.ubt.jimu.base.entities.RobotLite;
|
||||
import com.ubt.jimu.controller.data.action.MotorData;
|
||||
import com.ubt.jimu.controller.data.action.TurnData;
|
||||
import com.ubt.jimu.controller.data.command.Gear;
|
||||
import com.ubt.jimu.controller.data.command.MotorCommand;
|
||||
import com.ubt.jimu.controller.data.command.MoveCommand;
|
||||
import com.ubt.jimu.controller.data.command.TurnCommand;
|
||||
import com.ubt.jimu.controller.data.config.JockstickConfig;
|
||||
import com.ubt.jimu.controller.manager.CommandManager;
|
||||
import com.ubt.jimu.controller.manager.MoveConfigManager;
|
||||
import com.ubt.jimu.controller.view.JockstickSettingView;
|
||||
import com.ubt.jimu.utils.LogUtils;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.functions.Consumer;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class JockstickSettingPresenter extends SuperControllerPresenter<JockstickSettingView> {
|
||||
public JockstickSettingPresenter(Context context, RobotLite robotLite) {
|
||||
super(context, robotLite);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.presenter.SuperControllerPresenter
|
||||
void b(List<? extends Engine> list) {
|
||||
}
|
||||
|
||||
public void k() {
|
||||
if (c(this.d)) {
|
||||
return;
|
||||
}
|
||||
((JockstickSettingView) b()).b(false);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void a(MoveCommand moveCommand, boolean z) {
|
||||
CommandManager.a(this.c.getApplicationContext()).a(moveCommand, z);
|
||||
}
|
||||
|
||||
public void a(CtrlMotionType ctrlMotionType, final int i, Gear gear, int i2) {
|
||||
if (!c(this.d) || super.e()) {
|
||||
return;
|
||||
}
|
||||
if (ctrlMotionType == CtrlMotionType.servo) {
|
||||
HashMap hashMap = new HashMap(1);
|
||||
hashMap.put(Integer.valueOf(i), new TurnData(i2, gear.getTurnSpeed()));
|
||||
a(new TurnCommand(hashMap), gear == Gear.EMPTY || i2 == 0);
|
||||
Observable.timer(400L, TimeUnit.MILLISECONDS).subscribe(new Consumer<Long>() { // from class: com.ubt.jimu.controller.presenter.JockstickSettingPresenter.1
|
||||
@Override // io.reactivex.functions.Consumer
|
||||
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
||||
public void accept(Long l) throws Exception {
|
||||
LogUtils.c("!!!!!!!!!!!!!!!!!!");
|
||||
HashMap hashMap2 = new HashMap(1);
|
||||
hashMap2.put(Integer.valueOf(i), new TurnData(0, 0));
|
||||
JockstickSettingPresenter.this.a((MoveCommand) new TurnCommand(hashMap2), true);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (ctrlMotionType == CtrlMotionType.motor) {
|
||||
HashMap hashMap2 = new HashMap(1);
|
||||
hashMap2.put(Integer.valueOf(i), new MotorData(i2, gear.getTurnSpeed(), 400));
|
||||
a(new MotorCommand(hashMap2), gear == Gear.EMPTY || i2 == 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void a(JockstickConfig jockstickConfig) {
|
||||
MoveConfigManager a = MoveConfigManager.a(this.c.getApplicationContext());
|
||||
a.b(jockstickConfig);
|
||||
a.a(true);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user