Initial commit
This commit is contained in:
177
sources/com/ubt/jimu/connect/ConnectActivity.java
Normal file
177
sources/com/ubt/jimu/connect/ConnectActivity.java
Normal file
@@ -0,0 +1,177 @@
|
||||
package com.ubt.jimu.connect;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import com.ubt.jimu.BaseActivity;
|
||||
import com.ubt.jimu.JimuApplication;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.base.entities.RobotLite;
|
||||
import com.ubt.jimu.connect.presenter.ConnectPresenterImpl;
|
||||
import com.ubt.jimu.connect.view.ConnectFragment;
|
||||
import com.ubt.jimu.connect.view.DisconnectFragment;
|
||||
import com.ubt.jimu.unity.bluetooth.UnityActivity;
|
||||
import com.ubtrobot.jimu.robotapi.JimuManager;
|
||||
import com.ubtrobot.log.ALog;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ConnectActivity extends BaseActivity {
|
||||
private JimuManager a;
|
||||
private boolean h;
|
||||
private int b = 0;
|
||||
private boolean c = false;
|
||||
private String d = null;
|
||||
private String e = null;
|
||||
private boolean f = true;
|
||||
private String g = null;
|
||||
private boolean i = true;
|
||||
private int j = -10;
|
||||
|
||||
private void D0() {
|
||||
this.a.c();
|
||||
}
|
||||
|
||||
public static void a(Context context, RobotLite robotLite) {
|
||||
b(context, -10, false, robotLite);
|
||||
}
|
||||
|
||||
public static void b(Context context, int i, boolean z, RobotLite robotLite) {
|
||||
Intent a = a(context, i, z, robotLite);
|
||||
a.putExtra("KEY_PAGE_NUM", 0);
|
||||
context.startActivity(a);
|
||||
}
|
||||
|
||||
public static void c(Context context, int i, boolean z, RobotLite robotLite) {
|
||||
Intent a = a(context, i, z, robotLite);
|
||||
a.putExtra("KEY_PAGE_NUM", 1);
|
||||
context.startActivity(a);
|
||||
}
|
||||
|
||||
@Override // android.app.Activity, android.view.Window.Callback
|
||||
public boolean dispatchGenericMotionEvent(MotionEvent motionEvent) {
|
||||
if ((motionEvent.getSource() & 16777232) == 16777232 && motionEvent.getAction() == 2) {
|
||||
return true;
|
||||
}
|
||||
return super.dispatchGenericMotionEvent(motionEvent);
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.app.AppCompatActivity, androidx.core.app.ComponentActivity, android.app.Activity, android.view.Window.Callback
|
||||
public boolean dispatchKeyEvent(KeyEvent keyEvent) {
|
||||
if ((keyEvent.getSource() & 1025) == 1025) {
|
||||
return true;
|
||||
}
|
||||
return super.dispatchKeyEvent(keyEvent);
|
||||
}
|
||||
|
||||
public void l(int i) {
|
||||
ALog.a(this.TAG).d("ActivityFinish");
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra("KEY_MODEL_ID", this.d);
|
||||
setResult(i, intent);
|
||||
if (!this.c) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
UnityActivity.start(this, 7, this.d, this.e, this.g, this.i, this.h ? 1 : 0);
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override // androidx.fragment.app.FragmentActivity, android.app.Activity
|
||||
public void onBackPressed() {
|
||||
Log.i(this.TAG, "onBackPressed");
|
||||
l(0);
|
||||
}
|
||||
|
||||
@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) {
|
||||
Bundle bundle2;
|
||||
super.onCreate(bundle);
|
||||
setContentView(R.layout.activity_connect);
|
||||
this.a = JimuApplication.l().f();
|
||||
FragmentTransaction a = getSupportFragmentManager().a();
|
||||
Intent intent = getIntent();
|
||||
if (intent != null) {
|
||||
this.g = intent.getStringExtra("KEY_PIC_PATH");
|
||||
this.d = intent.getStringExtra("KEY_MODEL_ID");
|
||||
this.e = intent.getStringExtra("KEY_MODEL_NAME");
|
||||
this.f = intent.getBooleanExtra("KEY_IS_AUTO_CONNECT", true);
|
||||
this.c = intent.getBooleanExtra("KEY_IS_FROM_UNITY", false);
|
||||
this.h = intent.getBooleanExtra("KEY_IS_DIY_MODEL", false);
|
||||
this.i = intent.getBooleanExtra("KEY_IS_DIY_CAN_EDIT", true);
|
||||
this.j = intent.getIntExtra("KEY_MODEL_CODE", -10);
|
||||
this.b = intent.getIntExtra("KEY_PAGE_NUM", 0);
|
||||
bundle2 = new Bundle();
|
||||
bundle2.putString("KEY_PIC_PATH", this.g);
|
||||
bundle2.putString("KEY_MODEL_ID", this.d);
|
||||
bundle2.putBoolean("KEY_IS_AUTO_CONNECT", this.f);
|
||||
bundle2.putBoolean("KEY_IS_FROM_UNITY", this.c);
|
||||
bundle2.putBoolean("KEY_IS_DIY_MODEL", this.h);
|
||||
bundle2.putString("KEY_MODEL_NAME", this.e);
|
||||
bundle2.putInt("KEY_MODEL_CODE", this.j);
|
||||
} else {
|
||||
bundle2 = null;
|
||||
}
|
||||
if (this.j == 1) {
|
||||
D0();
|
||||
}
|
||||
if (this.b == 0) {
|
||||
if (this.a.g()) {
|
||||
Log.i(this.TAG, "goto connect page, but bluetooth is connected, disconnect first");
|
||||
D0();
|
||||
}
|
||||
ALog.a(this.TAG).d("new ConnectFragment");
|
||||
ConnectFragment connectFragment = new ConnectFragment();
|
||||
if (bundle2 != null) {
|
||||
connectFragment.setArguments(bundle2);
|
||||
}
|
||||
ConnectPresenterImpl connectPresenterImpl = new ConnectPresenterImpl(this, connectFragment);
|
||||
connectPresenterImpl.b(this.d);
|
||||
if (!this.f) {
|
||||
connectPresenterImpl.b(false);
|
||||
}
|
||||
a.a(R.id.rl_connect, connectFragment);
|
||||
} else {
|
||||
DisconnectFragment disconnectFragment = new DisconnectFragment();
|
||||
if (bundle2 != null) {
|
||||
disconnectFragment.setArguments(bundle2);
|
||||
}
|
||||
a.a(R.id.rl_connect, disconnectFragment);
|
||||
}
|
||||
ALog.a(this.TAG).d("ConnectFragment transaction commit");
|
||||
a.a();
|
||||
}
|
||||
|
||||
public static void a(int i, Activity activity, RobotLite robotLite) {
|
||||
Intent a = a(activity, -10, false, robotLite);
|
||||
a.putExtra("KEY_PAGE_NUM", 0);
|
||||
activity.startActivityForResult(a, i);
|
||||
}
|
||||
|
||||
public static void b(Context context, RobotLite robotLite) {
|
||||
c(context, -10, false, robotLite);
|
||||
}
|
||||
|
||||
private static Intent a(Context context, int i, boolean z, RobotLite robotLite) {
|
||||
Intent intent = new Intent(context, (Class<?>) ConnectActivity.class);
|
||||
intent.putExtra("KEY_PIC_PATH", robotLite.getPicPath());
|
||||
intent.putExtra("KEY_MODEL_ID", robotLite.getModelId());
|
||||
intent.putExtra("KEY_MODEL_NAME", robotLite.getModelName());
|
||||
intent.putExtra("KEY_IS_FROM_UNITY", z);
|
||||
intent.putExtra("KEY_IS_DIY_MODEL", !robotLite.isOfficial());
|
||||
intent.putExtra("KEY_IS_DIY_CAN_EDIT", robotLite.isDiyCanEdit());
|
||||
intent.putExtra("KEY_MODEL_CODE", i);
|
||||
intent.putExtra("KEY_IS_AUTO_CONNECT", true);
|
||||
return intent;
|
||||
}
|
||||
|
||||
public static void b(int i, Activity activity, RobotLite robotLite) {
|
||||
Intent a = a(activity, -10, false, robotLite);
|
||||
a.putExtra("KEY_PAGE_NUM", 1);
|
||||
activity.startActivityForResult(a, i);
|
||||
}
|
||||
}
|
35
sources/com/ubt/jimu/connect/JimuStatusMonitor.java
Normal file
35
sources/com/ubt/jimu/connect/JimuStatusMonitor.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package com.ubt.jimu.connect;
|
||||
|
||||
import com.ubt.jimu.base.cache.Cache;
|
||||
import com.ubt.jimu.base.cache.SharePreferenceHelper;
|
||||
import com.ubt.jimu.unity.bluetooth.ConnectionStatus;
|
||||
import com.ubtrobot.jimu.bluetooth.ConnectionState;
|
||||
import com.ubtrobot.jimu.robotapi.BatteryInfo;
|
||||
import com.ubtrobot.jimu.robotapi.IPowerStateListener;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class JimuStatusMonitor implements IPowerStateListener {
|
||||
private SharePreferenceHelper a = Cache.getInstance().getSettings();
|
||||
|
||||
@Override // com.ubtrobot.jimu.robotapi.IPowerStateListener
|
||||
public void onConnectionStateChange(String str, ConnectionState connectionState) {
|
||||
if (connectionState == null) {
|
||||
return;
|
||||
}
|
||||
if (ConnectionState.STATE_CONNECTED == connectionState) {
|
||||
this.a.put(SharePreferenceHelper.SP_KEY_CONNECTION_STATUS, Integer.valueOf(ConnectionStatus.CONNECTED.getStatus()));
|
||||
Cache.getInstance().setConnected(false);
|
||||
} else if (ConnectionState.STATE_DISCONNECTED == connectionState) {
|
||||
this.a.put(SharePreferenceHelper.SP_KEY_CONNECTION_STATUS, Integer.valueOf(ConnectionStatus.DIS_CONNECT.getStatus()));
|
||||
Cache.getInstance().setConnected(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.jimu.robotapi.IPowerStateListener
|
||||
public void onPowerStateChanged(BatteryInfo batteryInfo) {
|
||||
if (batteryInfo == null) {
|
||||
return;
|
||||
}
|
||||
this.a.put(SharePreferenceHelper.SP_KEY_CONNECTION_STATUS, Integer.valueOf((batteryInfo.d() ? ConnectionStatus.CHARGING : batteryInfo.a() < 20.0f ? ConnectionStatus.LOW_BATTERY : ConnectionStatus.CONNECTED).getStatus()));
|
||||
}
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
package com.ubt.jimu.connect.contract;
|
||||
|
||||
import com.ubt.jimu.connect.model.Component;
|
||||
import com.ubtech.presenter.BasePresenter;
|
||||
import com.ubtrobot.jimu.Firmware;
|
||||
import com.ubtrobot.jimu.connection.ResultCallback;
|
||||
import com.ubtrobot.jimu.robotapi.BoardInfo;
|
||||
import com.ubtrobot.jimu.robotapi.ServoAngleReadInfo;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface ComponentListContract$Presenter extends BasePresenter {
|
||||
List<Firmware> a(BoardInfo boardInfo);
|
||||
|
||||
void a(ResultCallback resultCallback);
|
||||
|
||||
void a(BoardInfo boardInfo, String str, boolean z);
|
||||
|
||||
void a(String str, boolean z);
|
||||
|
||||
void a(List<ServoAngleReadInfo> list);
|
||||
|
||||
boolean a(String str, BoardInfo boardInfo, ArrayList<Component> arrayList);
|
||||
|
||||
void b(String str, boolean z);
|
||||
|
||||
boolean b(BoardInfo boardInfo);
|
||||
|
||||
boolean b(List<Component> list);
|
||||
|
||||
boolean c(BoardInfo boardInfo);
|
||||
|
||||
boolean d();
|
||||
|
||||
boolean d(BoardInfo boardInfo);
|
||||
|
||||
void e(BoardInfo boardInfo);
|
||||
|
||||
void f();
|
||||
|
||||
boolean f(BoardInfo boardInfo);
|
||||
|
||||
BoardInfo t();
|
||||
}
|
@@ -0,0 +1,43 @@
|
||||
package com.ubt.jimu.connect.contract;
|
||||
|
||||
import com.ubt.jimu.connect.model.Component;
|
||||
import com.ubtech.view.BaseView;
|
||||
import com.ubtrobot.jimu.Firmware;
|
||||
import com.ubtrobot.jimu.robotapi.BoardInfo;
|
||||
import com.ubtrobot.jimu.robotapi.ServoAngleReadInfo;
|
||||
import com.ubtrobot.jimu.robotapi.UpdateManager;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface ComponentListContract$View extends BaseView<ComponentListContract$Presenter> {
|
||||
void a(int i);
|
||||
|
||||
void a(int i, int i2, int i3);
|
||||
|
||||
void a(long j, int i);
|
||||
|
||||
void a(BoardInfo boardInfo);
|
||||
|
||||
void a(UpdateManager.UpdateException updateException, List<Firmware> list);
|
||||
|
||||
void a(ArrayList<Component> arrayList, BoardInfo boardInfo);
|
||||
|
||||
void a(List<ServoAngleReadInfo> list);
|
||||
|
||||
void b(int i);
|
||||
|
||||
void b(BoardInfo boardInfo);
|
||||
|
||||
void c(BoardInfo boardInfo);
|
||||
|
||||
void d(BoardInfo boardInfo);
|
||||
|
||||
void k();
|
||||
|
||||
void l();
|
||||
|
||||
void n();
|
||||
|
||||
void p();
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
package com.ubt.jimu.connect.contract;
|
||||
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.content.Context;
|
||||
import com.ubtech.presenter.BasePresenter;
|
||||
import com.ubtrobot.jimu.robotapi.BoardInfo;
|
||||
import com.ubtrobot.jimu.robotapi.ServoAngleReadInfo;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface ConnectContract$Presenter extends BasePresenter {
|
||||
void a();
|
||||
|
||||
void a(int i);
|
||||
|
||||
void a(BluetoothDevice bluetoothDevice);
|
||||
|
||||
void a(Context context, BoardInfo boardInfo, String str, boolean z);
|
||||
|
||||
void a(List<ServoAngleReadInfo> list);
|
||||
|
||||
void a(boolean z);
|
||||
|
||||
void b(String str);
|
||||
|
||||
void b(boolean z);
|
||||
|
||||
void c(String str, String str2);
|
||||
|
||||
boolean d();
|
||||
|
||||
boolean g();
|
||||
|
||||
void k();
|
||||
|
||||
BluetoothDevice l();
|
||||
|
||||
int m();
|
||||
|
||||
void p();
|
||||
|
||||
void q();
|
||||
|
||||
void r();
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
package com.ubt.jimu.connect.contract;
|
||||
|
||||
import com.ubtech.view.BaseView;
|
||||
import com.ubtrobot.jimu.bluetooth.base.discover.ScanResult;
|
||||
import com.ubtrobot.jimu.robotapi.ServoAngleReadInfo;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface ConnectContract$View extends BaseView<ConnectContract$Presenter> {
|
||||
void G();
|
||||
|
||||
void J();
|
||||
|
||||
void O();
|
||||
|
||||
void R();
|
||||
|
||||
void U();
|
||||
|
||||
void Y();
|
||||
|
||||
void a(ConnectContract$Presenter connectContract$Presenter);
|
||||
|
||||
void a(ScanResult scanResult);
|
||||
|
||||
void a(String str, boolean z);
|
||||
|
||||
void a(List<ServoAngleReadInfo> list);
|
||||
|
||||
void b0();
|
||||
|
||||
void c(int i);
|
||||
|
||||
void i();
|
||||
|
||||
void z();
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
package com.ubt.jimu.connect.model;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class BluetoothSpeakerComponent extends Component {
|
||||
private String e;
|
||||
|
||||
public BluetoothSpeakerComponent(int i, ErrorType errorType) {
|
||||
super(8, i, errorType);
|
||||
}
|
||||
|
||||
public void b(String str) {
|
||||
this.e = str;
|
||||
}
|
||||
|
||||
public String f() {
|
||||
return this.e;
|
||||
}
|
||||
}
|
102
sources/com/ubt/jimu/connect/model/Component.java
Normal file
102
sources/com/ubt/jimu/connect/model/Component.java
Normal file
@@ -0,0 +1,102 @@
|
||||
package com.ubt.jimu.connect.model;
|
||||
|
||||
import com.ubt.jimu.JimuApplication;
|
||||
import com.ubt.jimu.R;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Component {
|
||||
private int a;
|
||||
private int b;
|
||||
private ErrorType c;
|
||||
private String d;
|
||||
|
||||
public Component() {
|
||||
}
|
||||
|
||||
public void a(int i) {
|
||||
this.b = i;
|
||||
}
|
||||
|
||||
public ErrorType b() {
|
||||
return this.c;
|
||||
}
|
||||
|
||||
public int c() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
public int d() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
public String e() {
|
||||
return this.d;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "errorType:" + this.c + " type:" + this.b + " id:" + this.a + " ";
|
||||
}
|
||||
|
||||
public Component(int i, int i2, ErrorType errorType) {
|
||||
this.b = i;
|
||||
this.a = i2;
|
||||
this.c = errorType;
|
||||
}
|
||||
|
||||
public void a(ErrorType errorType) {
|
||||
this.c = errorType;
|
||||
}
|
||||
|
||||
public void a(String str) {
|
||||
this.d = str;
|
||||
}
|
||||
|
||||
public String a() {
|
||||
int i = this.b;
|
||||
int i2 = R.string.main_board;
|
||||
if (i == 14) {
|
||||
i2 = R.string.unicorn_led;
|
||||
} else if (i == 101) {
|
||||
i2 = R.string.firebot_light;
|
||||
} else if (i == 128) {
|
||||
i2 = R.string.servo;
|
||||
} else if (i != 112 && i != 113) {
|
||||
switch (i) {
|
||||
case 1:
|
||||
i2 = R.string.infrared;
|
||||
break;
|
||||
case 2:
|
||||
i2 = R.string.touch;
|
||||
break;
|
||||
case 3:
|
||||
i2 = R.string.gyro;
|
||||
break;
|
||||
case 4:
|
||||
i2 = R.string.led;
|
||||
break;
|
||||
case 5:
|
||||
i2 = R.string.gravity;
|
||||
break;
|
||||
case 6:
|
||||
i2 = R.string.ultrasound;
|
||||
break;
|
||||
default:
|
||||
switch (i) {
|
||||
case 8:
|
||||
i2 = R.string.speaker;
|
||||
break;
|
||||
case 9:
|
||||
i2 = R.string.color;
|
||||
break;
|
||||
case 10:
|
||||
i2 = R.string.motor;
|
||||
break;
|
||||
default:
|
||||
i2 = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return i2 == -1 ? "" : JimuApplication.l().getApplicationContext().getString(i2);
|
||||
}
|
||||
}
|
12
sources/com/ubt/jimu/connect/model/ErrorType.java
Normal file
12
sources/com/ubt/jimu/connect/model/ErrorType.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package com.ubt.jimu.connect.model;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public enum ErrorType {
|
||||
NONE,
|
||||
PROMPT,
|
||||
ID_DUPLICATION,
|
||||
LACK,
|
||||
EXTRA,
|
||||
TOO_MANY,
|
||||
NEED_UPDATE
|
||||
}
|
26
sources/com/ubt/jimu/connect/model/FilePathUtils.java
Normal file
26
sources/com/ubt/jimu/connect/model/FilePathUtils.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package com.ubt.jimu.connect.model;
|
||||
|
||||
import android.os.Environment;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class FilePathUtils {
|
||||
public static String a(String str) {
|
||||
return (Environment.getExternalStorageDirectory().getPath() + "/Android/data/com.ubt.jimu/files") + "/default/" + str;
|
||||
}
|
||||
|
||||
public static String b(String str, String str2) {
|
||||
return a(str, str2) + "/" + str + ".xml";
|
||||
}
|
||||
|
||||
public static String c(String str, String str2) {
|
||||
return ((Environment.getExternalStorageDirectory().getPath() + "/Android/data/com.ubt.jimu/files") + "/users/" + str2 + "/") + "/default/" + str;
|
||||
}
|
||||
|
||||
public static String a(String str, String str2) {
|
||||
return ((Environment.getExternalStorageDirectory().getPath() + "/Android/data/com.ubt.jimu/files") + "/users/" + str2 + "/") + "/playerdata/" + str;
|
||||
}
|
||||
|
||||
public static String b(String str) {
|
||||
return (Environment.getExternalStorageDirectory().getPath() + "/Android/data/com.ubt.jimu/files") + "/zip/" + str;
|
||||
}
|
||||
}
|
16
sources/com/ubt/jimu/connect/model/IUpdateModel.java
Normal file
16
sources/com/ubt/jimu/connect/model/IUpdateModel.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.ubt.jimu.connect.model;
|
||||
|
||||
import com.ubtrobot.jimu.Firmware;
|
||||
import com.ubtrobot.jimu.robotapi.BoardInfo;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface IUpdateModel {
|
||||
List<Firmware> a(BoardInfo boardInfo);
|
||||
|
||||
boolean b(BoardInfo boardInfo);
|
||||
|
||||
boolean c(BoardInfo boardInfo);
|
||||
|
||||
boolean d(BoardInfo boardInfo);
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
package com.ubt.jimu.connect.model;
|
||||
|
||||
import com.ubtrobot.jimu.robotapi.BoardInfo;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface MatchResultCallback {
|
||||
void a(int i, BoardInfo boardInfo);
|
||||
}
|
608
sources/com/ubt/jimu/connect/model/ModelMatchModel.java
Normal file
608
sources/com/ubt/jimu/connect/model/ModelMatchModel.java
Normal file
@@ -0,0 +1,608 @@
|
||||
package com.ubt.jimu.connect.model;
|
||||
|
||||
import android.util.Log;
|
||||
import com.ubt.jimu.JimuApplication;
|
||||
import com.ubt.jimu.base.cache.Cache;
|
||||
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.User;
|
||||
import com.ubt.jimu.transport3.UnityFileOperator;
|
||||
import com.ubtech.utils.XLog;
|
||||
import com.ubtrobot.jimu.connection.RequestException;
|
||||
import com.ubtrobot.jimu.robotapi.BluetoothSpeakerInfo;
|
||||
import com.ubtrobot.jimu.robotapi.BoardInfo;
|
||||
import com.ubtrobot.jimu.robotapi.JimuException;
|
||||
import com.ubtrobot.jimu.robotapi.JimuManager;
|
||||
import com.ubtrobot.jimu.robotapi.PeripheralType;
|
||||
import com.ubtrobot.log.ALog;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ModelMatchModel {
|
||||
private ArrayList<Component> b = new ArrayList<>();
|
||||
private JimuManager a = JimuApplication.l().f();
|
||||
|
||||
private String c() {
|
||||
User user = Cache.getInstance().getUser();
|
||||
if (user == null) {
|
||||
return "local";
|
||||
}
|
||||
return user.getUserId() + "";
|
||||
}
|
||||
|
||||
public ArrayList<Component> a() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
public BoardInfo b() throws JimuException {
|
||||
BoardInfo l;
|
||||
try {
|
||||
try {
|
||||
if (!this.a.h()) {
|
||||
this.a.c();
|
||||
throw new JimuException(-1, "ERROR_CODE_NOT_JIMU_DEVICE");
|
||||
}
|
||||
this.a.n();
|
||||
try {
|
||||
Thread.sleep(2000L);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
try {
|
||||
l = this.a.l();
|
||||
} catch (JimuException e2) {
|
||||
XLog.b("ModelMatchModel", "Read mother board info fail! Retry one time");
|
||||
try {
|
||||
if (e2.getCode() == 238) {
|
||||
this.a.b();
|
||||
}
|
||||
Thread.sleep(1000L);
|
||||
} catch (InterruptedException e3) {
|
||||
e3.printStackTrace();
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
try {
|
||||
l = this.a.l();
|
||||
} catch (JimuException unused) {
|
||||
XLog.c("ModelMatchModel", "read board fail! goto connect fail page");
|
||||
throw new JimuException(-2, "MATCH_RESULT_ERROR_READ_CODE_FAIL");
|
||||
}
|
||||
}
|
||||
if (l != null) {
|
||||
return l;
|
||||
}
|
||||
XLog.b("ModelMatchModel", "Read mother board info fail! ");
|
||||
throw new JimuException(-2, "MATCH_RESULT_ERROR_READ_CODE_FAIL");
|
||||
} catch (JimuException e4) {
|
||||
XLog.c("ModelMatchModel", "read board fail! goto connect fail page");
|
||||
throw new JimuException(-2, e4.getMessage());
|
||||
}
|
||||
} catch (RequestException e5) {
|
||||
XLog.c("ModelMatchModel", "read board fail! goto connect fail page");
|
||||
throw new JimuException(-2, e5.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void a(String str, boolean z, MatchResultCallback matchResultCallback) {
|
||||
BoardInfo l;
|
||||
int i;
|
||||
XLog.c("ModelMatchModel", "start match model");
|
||||
try {
|
||||
try {
|
||||
if (!this.a.h()) {
|
||||
this.a.c();
|
||||
matchResultCallback.a(-1, null);
|
||||
return;
|
||||
}
|
||||
this.a.n();
|
||||
try {
|
||||
Thread.sleep(2000L);
|
||||
} catch (InterruptedException unused) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
try {
|
||||
l = this.a.l();
|
||||
} catch (JimuException e) {
|
||||
XLog.b("ModelMatchModel", "Read mother board info fail! Retry one time");
|
||||
try {
|
||||
if (e.getCode() == 238) {
|
||||
this.a.b();
|
||||
}
|
||||
Thread.sleep(1000L);
|
||||
} catch (InterruptedException e2) {
|
||||
e2.printStackTrace();
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
try {
|
||||
l = this.a.l();
|
||||
} catch (JimuException unused2) {
|
||||
XLog.c("ModelMatchModel", "read board fail! goto connect fail page");
|
||||
matchResultCallback.a(-2, null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (l == null) {
|
||||
XLog.b("ModelMatchModel", "Read mother board info fail! ");
|
||||
matchResultCallback.a(-2, null);
|
||||
return;
|
||||
}
|
||||
if (l.l()) {
|
||||
XLog.c("ModelMatchModel", "peripheral ID duplication");
|
||||
i = -4;
|
||||
} else {
|
||||
i = 0;
|
||||
}
|
||||
this.b = a(l, str, z);
|
||||
Iterator<Component> it = this.b.iterator();
|
||||
while (it.hasNext()) {
|
||||
Component next = it.next();
|
||||
if (next.b() != ErrorType.NONE) {
|
||||
XLog.c("ModelMatchModel", "Has some component not match. component:" + next);
|
||||
i = -3;
|
||||
}
|
||||
}
|
||||
matchResultCallback.a(i, l);
|
||||
} catch (JimuException unused3) {
|
||||
XLog.c("ModelMatchModel", "read board fail! goto connect fail page");
|
||||
matchResultCallback.a(-2, null);
|
||||
}
|
||||
} catch (RequestException unused4) {
|
||||
XLog.c("ModelMatchModel", "read board fail! goto connect fail page");
|
||||
matchResultCallback.a(-2, null);
|
||||
}
|
||||
}
|
||||
|
||||
private List<Integer> c(List<Integer> list, List<Integer> list2) {
|
||||
if (list == null) {
|
||||
return new ArrayList();
|
||||
}
|
||||
ArrayList arrayList = new ArrayList(list);
|
||||
if (list2 == null) {
|
||||
return arrayList;
|
||||
}
|
||||
arrayList.removeAll(list2);
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
private List<Integer> b(List<Integer> list, List<Integer> list2) {
|
||||
if (list2 == null) {
|
||||
return new ArrayList();
|
||||
}
|
||||
ArrayList arrayList = new ArrayList(list2);
|
||||
if (list == null) {
|
||||
return arrayList;
|
||||
}
|
||||
arrayList.removeAll(list);
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
public void b(BoardInfo boardInfo, String str, boolean z) {
|
||||
String c = c();
|
||||
if (a(z, str)) {
|
||||
a(str, c, boardInfo, z);
|
||||
a(str, c, boardInfo);
|
||||
} else {
|
||||
b(str, c, boardInfo, z);
|
||||
}
|
||||
}
|
||||
|
||||
private static void b(String str, String str2, BoardInfo boardInfo, boolean z) {
|
||||
String c;
|
||||
PeripheralConnections a = PeripheralConnections.a(str, str2, z);
|
||||
if (a == null) {
|
||||
return;
|
||||
}
|
||||
a.a(boardInfo);
|
||||
if (z) {
|
||||
c = FilePathUtils.a(str, str2);
|
||||
} else {
|
||||
c = FilePathUtils.c(str, str2);
|
||||
}
|
||||
a.b(c);
|
||||
a(str, true, PeripheralConnections.d(c), 2);
|
||||
}
|
||||
|
||||
public ArrayList<Component> a(BoardInfo boardInfo, String str, boolean z) {
|
||||
String a;
|
||||
ArrayList<Component> arrayList = new ArrayList<>();
|
||||
if (boardInfo == null) {
|
||||
XLog.b("ModelMatchModel", "Board info is null");
|
||||
return arrayList;
|
||||
}
|
||||
if (a(z, str)) {
|
||||
return a(boardInfo);
|
||||
}
|
||||
if (z) {
|
||||
a = FilePathUtils.a(str, c());
|
||||
} else {
|
||||
a = FilePathUtils.a(str);
|
||||
String c = FilePathUtils.c(str, c());
|
||||
File file = new File(a);
|
||||
File file2 = new File(c);
|
||||
if (!file.exists() || (file2.exists() && file2.lastModified() > file.lastModified())) {
|
||||
a = c;
|
||||
}
|
||||
}
|
||||
XLog.c("ModelMatchModel", "Model file folder path:" + a);
|
||||
XLog.c("ModelMatchModel", "robotName:" + str + " isDiyModel:" + z);
|
||||
ArrayList<Component> a2 = a(boardInfo, a, str, z);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("componentList:");
|
||||
sb.append(a(a2));
|
||||
XLog.c("ModelMatchModel", sb.toString());
|
||||
a(a2, boardInfo);
|
||||
Iterator<Component> it = a2.iterator();
|
||||
while (it.hasNext()) {
|
||||
Component next = it.next();
|
||||
if (next.d() == 8 && next.b() != ErrorType.LACK) {
|
||||
if (next.b() == ErrorType.NONE) {
|
||||
next.a(ErrorType.PROMPT);
|
||||
}
|
||||
try {
|
||||
BluetoothSpeakerInfo a3 = this.a.a(next.c());
|
||||
if (a3 == null) {
|
||||
Log.w("ModelMatchModel", "Not read any speaker info, Please check has speaker connected");
|
||||
} else {
|
||||
((BluetoothSpeakerComponent) next).b(a3.a());
|
||||
}
|
||||
} catch (JimuException e) {
|
||||
XLog.a("ModelMatchModel", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return a2;
|
||||
}
|
||||
|
||||
public ArrayList<Component> a(BoardInfo boardInfo) {
|
||||
ArrayList<Component> arrayList = new ArrayList<>();
|
||||
arrayList.add(a(boardInfo.e(), 1, ErrorType.NONE, boardInfo.d()));
|
||||
List<Integer> i = boardInfo.i();
|
||||
HashMap<Integer, BoardInfo.SensorBoardInfo> h = boardInfo.h();
|
||||
a(arrayList, PeripheralType.SERVO, i, boardInfo.j());
|
||||
for (Map.Entry<Integer, BoardInfo.SensorBoardInfo> entry : h.entrySet()) {
|
||||
BoardInfo.SensorBoardInfo value = entry.getValue();
|
||||
if (value != null) {
|
||||
a(arrayList, entry.getKey().intValue(), value.b(), value.c());
|
||||
}
|
||||
}
|
||||
a(arrayList, boardInfo);
|
||||
Iterator<Component> it = arrayList.iterator();
|
||||
while (it.hasNext()) {
|
||||
Component next = it.next();
|
||||
if (next.d() == 8 && next.b() != ErrorType.LACK) {
|
||||
try {
|
||||
((BluetoothSpeakerComponent) next).b(this.a.a(next.c()).a());
|
||||
} catch (JimuException e) {
|
||||
XLog.a("ModelMatchModel", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
private void a(ArrayList<Component> arrayList, int i, List<Integer> list, String str) {
|
||||
Iterator<Integer> it = list.iterator();
|
||||
while (it.hasNext()) {
|
||||
arrayList.add(a(i, it.next().intValue(), ErrorType.NONE, str));
|
||||
}
|
||||
}
|
||||
|
||||
private String a(ArrayList<Component> arrayList) {
|
||||
String str = "";
|
||||
for (int i = 0; i < arrayList.size(); i++) {
|
||||
str = (str + arrayList.get(i)) + "\n";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
private void a(ArrayList<Component> arrayList, BoardInfo boardInfo) {
|
||||
if (boardInfo.a().size() != 0) {
|
||||
for (Integer num : boardInfo.a()) {
|
||||
Iterator<Component> it = arrayList.iterator();
|
||||
while (it.hasNext()) {
|
||||
Component next = it.next();
|
||||
if (next.d() == 128 && next.c() == num.intValue()) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
arrayList.add(a(PeripheralType.SERVO, num.intValue(), ErrorType.ID_DUPLICATION));
|
||||
}
|
||||
}
|
||||
for (Map.Entry<Integer, BoardInfo.SensorBoardInfo> entry : boardInfo.h().entrySet()) {
|
||||
if (entry.getValue().a().size() != 0) {
|
||||
for (Integer num2 : entry.getValue().a()) {
|
||||
Iterator<Component> it2 = arrayList.iterator();
|
||||
while (it2.hasNext()) {
|
||||
Component next2 = it2.next();
|
||||
if (next2.d() == entry.getKey().intValue() && next2.c() == num2.intValue()) {
|
||||
it2.remove();
|
||||
}
|
||||
}
|
||||
if (entry.getKey().intValue() == 8) {
|
||||
arrayList.add(a(entry.getKey().intValue(), num2.intValue(), ErrorType.TOO_MANY));
|
||||
} else {
|
||||
arrayList.add(a(entry.getKey().intValue(), num2.intValue(), ErrorType.ID_DUPLICATION));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ArrayList<Component> a(BoardInfo boardInfo, String str, String str2, boolean z) {
|
||||
int i;
|
||||
HashMap<Integer, ArrayList<Integer>> b;
|
||||
PeripheralConnections peripheralConnections;
|
||||
String str3;
|
||||
int i2;
|
||||
ArrayList<Component> arrayList = new ArrayList<>();
|
||||
String str4 = "ModelMatchModel";
|
||||
if (boardInfo == null) {
|
||||
XLog.b("ModelMatchModel", "Board is null, not compare to model file.");
|
||||
return arrayList;
|
||||
}
|
||||
String str5 = str + "/" + str2 + ".xml";
|
||||
if (!z) {
|
||||
str5 = FilePathUtils.a(str2) + "/" + str2 + ".xml";
|
||||
}
|
||||
XLog.a("ModelMatchModel", "xmlPath:" + str5);
|
||||
ModelMatchXmlFileManager modelMatchXmlFileManager = new ModelMatchXmlFileManager();
|
||||
modelMatchXmlFileManager.a(str5);
|
||||
List<Integer> b2 = modelMatchXmlFileManager.b();
|
||||
List<Integer> a = modelMatchXmlFileManager.a();
|
||||
List<Integer> i3 = boardInfo.i();
|
||||
HashMap<Integer, BoardInfo.SensorBoardInfo> h = boardInfo.h();
|
||||
arrayList.add(a(boardInfo.e(), 1, ErrorType.NONE, boardInfo.d()));
|
||||
Iterator<Integer> it = a(b2, i3).iterator();
|
||||
while (true) {
|
||||
boolean hasNext = it.hasNext();
|
||||
i = PeripheralType.SERVO;
|
||||
if (!hasNext) {
|
||||
break;
|
||||
}
|
||||
arrayList.add(a(PeripheralType.SERVO, it.next().intValue(), ErrorType.NONE, boardInfo.j()));
|
||||
}
|
||||
for (Integer num : c(b2, i3)) {
|
||||
if (boardInfo.a().contains(num)) {
|
||||
Component a2 = a(PeripheralType.SERVO, num.intValue(), ErrorType.ID_DUPLICATION);
|
||||
a2.a(boardInfo.j());
|
||||
arrayList.add(a2);
|
||||
} else {
|
||||
arrayList.add(a(PeripheralType.SERVO, num.intValue(), ErrorType.LACK));
|
||||
}
|
||||
}
|
||||
Iterator<Integer> it2 = b(b2, i3).iterator();
|
||||
while (it2.hasNext()) {
|
||||
Component a3 = a(PeripheralType.SERVO, it2.next().intValue(), ErrorType.EXTRA);
|
||||
a3.a(boardInfo.j());
|
||||
arrayList.add(a3);
|
||||
}
|
||||
int i4 = 10;
|
||||
BoardInfo.SensorBoardInfo sensorBoardInfo = h.get(10);
|
||||
List<Integer> b3 = sensorBoardInfo != null ? sensorBoardInfo.b() : null;
|
||||
Iterator<Integer> it3 = a(a, b3).iterator();
|
||||
while (it3.hasNext()) {
|
||||
arrayList.add(a(10, it3.next().intValue(), ErrorType.NONE, sensorBoardInfo.c()));
|
||||
}
|
||||
Iterator<Integer> it4 = c(a, b3).iterator();
|
||||
while (it4.hasNext()) {
|
||||
arrayList.add(a(10, it4.next().intValue(), ErrorType.LACK));
|
||||
}
|
||||
List<Integer> b4 = b(a, b3);
|
||||
if (b4 != null && b4.size() != 0) {
|
||||
Iterator<Integer> it5 = b4.iterator();
|
||||
while (it5.hasNext()) {
|
||||
Component a4 = a(10, it5.next().intValue(), ErrorType.EXTRA);
|
||||
if (sensorBoardInfo != null) {
|
||||
a4.a(sensorBoardInfo.c());
|
||||
}
|
||||
arrayList.add(a4);
|
||||
}
|
||||
}
|
||||
PeripheralConnections a5 = PeripheralConnections.a(str2, c(), z);
|
||||
if (a5 == null) {
|
||||
XLog.b("ModelMatchModel", "Get peripheral connections fail by read connections file!");
|
||||
b = new HashMap<>();
|
||||
} else {
|
||||
b = a5.b();
|
||||
}
|
||||
HashMap<Integer, ArrayList<Integer>> hashMap = b;
|
||||
Field[] declaredFields = PeripheralType.class.getDeclaredFields();
|
||||
int length = declaredFields.length;
|
||||
int i5 = 0;
|
||||
while (i5 < length) {
|
||||
try {
|
||||
i2 = declaredFields[i5].getInt(PeripheralType.class);
|
||||
} catch (IllegalAccessException e) {
|
||||
e = e;
|
||||
peripheralConnections = a5;
|
||||
}
|
||||
if (i2 != -1 && i2 != i4 && i2 != 112 && i2 != 113) {
|
||||
ArrayList<Integer> arrayList2 = hashMap.get(Integer.valueOf(i2));
|
||||
if (i2 == i && arrayList2 != null) {
|
||||
Iterator<Integer> it6 = arrayList2.iterator();
|
||||
while (it6.hasNext()) {
|
||||
int intValue = it6.next().intValue();
|
||||
ServoMode servoMode = ServoMode.SERVO_MODE_ANGLE;
|
||||
if (a5 != null) {
|
||||
a5.a(Integer.valueOf(intValue));
|
||||
}
|
||||
Iterator<Component> it7 = arrayList.iterator();
|
||||
while (true) {
|
||||
if (it7.hasNext()) {
|
||||
Component next = it7.next();
|
||||
if (i == next.d() && intValue == next.c()) {
|
||||
ALog.a(str4).d("ServoId:" + intValue + " Mode:" + servoMode);
|
||||
((ServoComponent) next).a(servoMode);
|
||||
break;
|
||||
}
|
||||
i = PeripheralType.SERVO;
|
||||
}
|
||||
}
|
||||
i = PeripheralType.SERVO;
|
||||
}
|
||||
} else {
|
||||
BoardInfo.SensorBoardInfo sensorBoardInfo2 = h.get(Integer.valueOf(i2));
|
||||
if (sensorBoardInfo2 != null) {
|
||||
List<Integer> b5 = sensorBoardInfo2.b();
|
||||
if (i2 == 8 && b5.size() > 1) {
|
||||
Component a6 = a(i2, 1, ErrorType.TOO_MANY);
|
||||
a6.a(sensorBoardInfo2.c());
|
||||
arrayList.add(a6);
|
||||
} else {
|
||||
Iterator<Integer> it8 = a(arrayList2, b5).iterator();
|
||||
while (it8.hasNext()) {
|
||||
int intValue2 = it8.next().intValue();
|
||||
peripheralConnections = a5;
|
||||
if (i2 == 8) {
|
||||
try {
|
||||
str3 = str4;
|
||||
if (b5.size() == 1) {
|
||||
try {
|
||||
arrayList.add(a(i2, intValue2, ErrorType.PROMPT, sensorBoardInfo2.c()));
|
||||
a5 = peripheralConnections;
|
||||
str4 = str3;
|
||||
} catch (IllegalAccessException e2) {
|
||||
e = e2;
|
||||
e.printStackTrace();
|
||||
i5++;
|
||||
a5 = peripheralConnections;
|
||||
str4 = str3;
|
||||
i4 = 10;
|
||||
i = PeripheralType.SERVO;
|
||||
}
|
||||
}
|
||||
} catch (IllegalAccessException e3) {
|
||||
e = e3;
|
||||
str3 = str4;
|
||||
e.printStackTrace();
|
||||
i5++;
|
||||
a5 = peripheralConnections;
|
||||
str4 = str3;
|
||||
i4 = 10;
|
||||
i = PeripheralType.SERVO;
|
||||
}
|
||||
} else {
|
||||
str3 = str4;
|
||||
}
|
||||
arrayList.add(a(i2, intValue2, ErrorType.NONE, sensorBoardInfo2.c()));
|
||||
a5 = peripheralConnections;
|
||||
str4 = str3;
|
||||
}
|
||||
peripheralConnections = a5;
|
||||
str3 = str4;
|
||||
Iterator<Integer> it9 = c(arrayList2, b5).iterator();
|
||||
while (it9.hasNext()) {
|
||||
arrayList.add(a(i2, it9.next().intValue(), ErrorType.LACK));
|
||||
}
|
||||
Iterator<Integer> it10 = b(arrayList2, b5).iterator();
|
||||
while (it10.hasNext()) {
|
||||
Component a7 = a(i2, it10.next().intValue(), ErrorType.EXTRA);
|
||||
a7.a(sensorBoardInfo2.c());
|
||||
arrayList.add(a7);
|
||||
}
|
||||
i5++;
|
||||
a5 = peripheralConnections;
|
||||
str4 = str3;
|
||||
i4 = 10;
|
||||
i = PeripheralType.SERVO;
|
||||
}
|
||||
} else if (arrayList2 != null) {
|
||||
Iterator<Integer> it11 = arrayList2.iterator();
|
||||
while (it11.hasNext()) {
|
||||
arrayList.add(a(i2, it11.next().intValue(), ErrorType.LACK));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
peripheralConnections = a5;
|
||||
str3 = str4;
|
||||
i5++;
|
||||
a5 = peripheralConnections;
|
||||
str4 = str3;
|
||||
i4 = 10;
|
||||
i = PeripheralType.SERVO;
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
private Component a(int i, int i2, ErrorType errorType, String str) {
|
||||
if (i == 8) {
|
||||
BluetoothSpeakerComponent bluetoothSpeakerComponent = new BluetoothSpeakerComponent(i2, errorType);
|
||||
bluetoothSpeakerComponent.a(str);
|
||||
return bluetoothSpeakerComponent;
|
||||
}
|
||||
if (i == 128) {
|
||||
ServoComponent servoComponent = new ServoComponent(i2, errorType);
|
||||
servoComponent.a(str);
|
||||
return servoComponent;
|
||||
}
|
||||
Component component = new Component(i, i2, errorType);
|
||||
component.a(str);
|
||||
return component;
|
||||
}
|
||||
|
||||
private Component a(int i, int i2, ErrorType errorType) {
|
||||
if (i == 8) {
|
||||
return new BluetoothSpeakerComponent(i2, errorType);
|
||||
}
|
||||
if (i == 128) {
|
||||
return new ServoComponent(i2, errorType);
|
||||
}
|
||||
return new Component(i, i2, errorType);
|
||||
}
|
||||
|
||||
private List<Integer> a(List<Integer> list, List<Integer> list2) {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
if (list != null && list2 != null) {
|
||||
arrayList.addAll(list);
|
||||
arrayList.retainAll(list2);
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
public static boolean a(boolean z, String str) {
|
||||
if (z) {
|
||||
return a(str);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean a(String str) {
|
||||
return !new File(FilePathUtils.b(str, Cache.getInstance().getUserId())).exists();
|
||||
}
|
||||
|
||||
private static void a(String str, String str2, BoardInfo boardInfo) {
|
||||
String str3 = FilePathUtils.a(str, str2) + "/" + str + ".xml";
|
||||
new ModelMatchXmlFileManager().a(boardInfo, str3);
|
||||
a(str, true, str3, 1);
|
||||
}
|
||||
|
||||
private static void a(String str, boolean z, String str2, int i) {
|
||||
DiyDBModel queryForUUid = DiyHelper.getInstance().queryForUUid(str);
|
||||
if (queryForUUid == null) {
|
||||
Log.w("ModelMatchModel", "Query null for diy model " + str + " from database");
|
||||
return;
|
||||
}
|
||||
new UnityFileOperator(queryForUUid.getModelId().intValue(), str, z ? 1 : 0, str2, i).operateFile();
|
||||
}
|
||||
|
||||
private static void a(String str, String str2, BoardInfo boardInfo, boolean z) {
|
||||
String c;
|
||||
PeripheralConnections b = PeripheralConnections.b(boardInfo);
|
||||
if (z) {
|
||||
c = FilePathUtils.a(str, str2);
|
||||
} else {
|
||||
c = FilePathUtils.c(str, str2);
|
||||
}
|
||||
b.b(c);
|
||||
a(str, true, PeripheralConnections.d(c), 1);
|
||||
}
|
||||
}
|
238
sources/com/ubt/jimu/connect/model/ModelMatchXmlFileManager.java
Normal file
238
sources/com/ubt/jimu/connect/model/ModelMatchXmlFileManager.java
Normal file
@@ -0,0 +1,238 @@
|
||||
package com.ubt.jimu.connect.model;
|
||||
|
||||
import android.util.Xml;
|
||||
import com.ubt.jimu.base.util.PathHelper;
|
||||
import com.ubt.jimu.controller.data.widget.JockstickDataConverter;
|
||||
import com.ubtrobot.jimu.robotapi.BoardInfo;
|
||||
import com.unity3d.ads.metadata.MediationMetaData;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import org.xmlpull.v1.XmlSerializer;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ModelMatchXmlFileManager {
|
||||
private List<Integer> a = new ArrayList();
|
||||
private List<Integer> b = new ArrayList();
|
||||
|
||||
public List<Integer> a() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
public List<Integer> b() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
/* JADX WARN: Removed duplicated region for block: B:69:0x00fb A[EXC_TOP_SPLITTER, SYNTHETIC] */
|
||||
/* JADX WARN: Type inference failed for: r8v13, types: [java.io.InputStream] */
|
||||
/* JADX WARN: Type inference failed for: r8v14 */
|
||||
/* JADX WARN: Type inference failed for: r8v17 */
|
||||
/* JADX WARN: Type inference failed for: r8v18 */
|
||||
/* JADX WARN: Type inference failed for: r8v19 */
|
||||
/* JADX WARN: Type inference failed for: r8v2 */
|
||||
/* JADX WARN: Type inference failed for: r8v20 */
|
||||
/* JADX WARN: Type inference failed for: r8v21 */
|
||||
/* JADX WARN: Type inference failed for: r8v22 */
|
||||
/* JADX WARN: Type inference failed for: r8v3, types: [java.io.IOException] */
|
||||
/* JADX WARN: Type inference failed for: r8v4 */
|
||||
/* JADX WARN: Type inference failed for: r8v7 */
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
public void a(java.lang.String r8) {
|
||||
/*
|
||||
Method dump skipped, instructions count: 260
|
||||
To view this dump change 'Code comments level' option to 'DEBUG'
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.ubt.jimu.connect.model.ModelMatchXmlFileManager.a(java.lang.String):void");
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
/* JADX WARN: Type inference failed for: r10v22, types: [java.lang.String] */
|
||||
public void a(BoardInfo boardInfo, String str) {
|
||||
Throwable th;
|
||||
FileOutputStream fileOutputStream;
|
||||
if (boardInfo == null) {
|
||||
return;
|
||||
}
|
||||
File file = new File(str);
|
||||
String str2 = PathHelper.OLD_CONTROLLER_PREFIX + System.currentTimeMillis();
|
||||
String property = System.getProperty("line.separator");
|
||||
List<Integer> i = boardInfo.i();
|
||||
BoardInfo.SensorBoardInfo sensorBoardInfo = boardInfo.h().get(10);
|
||||
FileOutputStream fileOutputStream2 = null;
|
||||
r10 = null;
|
||||
FileOutputStream fileOutputStream3 = null;
|
||||
fileOutputStream2 = null;
|
||||
fileOutputStream2 = null;
|
||||
fileOutputStream2 = null;
|
||||
fileOutputStream2 = null;
|
||||
List<Integer> b = sensorBoardInfo != null ? sensorBoardInfo.b() : null;
|
||||
try {
|
||||
try {
|
||||
try {
|
||||
FileOutputStream fileOutputStream4 = new FileOutputStream(file);
|
||||
try {
|
||||
XmlSerializer newSerializer = Xml.newSerializer();
|
||||
newSerializer.setOutput(fileOutputStream4, "UTF-8");
|
||||
int i2 = 1;
|
||||
newSerializer.startDocument("UTF-8", true);
|
||||
newSerializer.text(property);
|
||||
newSerializer.startTag(null, "Root");
|
||||
newSerializer.text(property);
|
||||
newSerializer.startTag(null, "RobotID");
|
||||
newSerializer.text(str2);
|
||||
newSerializer.endTag(null, "RobotID");
|
||||
newSerializer.text(property);
|
||||
newSerializer.startTag(null, "DataType");
|
||||
newSerializer.text("playerdata");
|
||||
newSerializer.endTag(null, "DataType");
|
||||
newSerializer.text(property);
|
||||
newSerializer.startTag(null, "Level");
|
||||
newSerializer.text("level");
|
||||
newSerializer.endTag(null, "Level");
|
||||
newSerializer.text(property);
|
||||
if (i != null) {
|
||||
Iterator<Integer> it = i.iterator();
|
||||
while (it.hasNext()) {
|
||||
int intValue = it.next().intValue();
|
||||
Iterator<Integer> it2 = it;
|
||||
newSerializer.startTag(null, "GO");
|
||||
fileOutputStream = fileOutputStream4;
|
||||
try {
|
||||
newSerializer.attribute(null, JockstickDataConverter.ID, String.valueOf(i2));
|
||||
newSerializer.attribute(null, "type", "seivo");
|
||||
newSerializer.attribute(null, MediationMetaData.KEY_NAME, "seivo_" + intValue);
|
||||
newSerializer.attribute(null, "djid", String.valueOf(intValue));
|
||||
newSerializer.attribute(null, "motorID", "0");
|
||||
newSerializer.attribute(null, "goPos", "(0,0,0)");
|
||||
newSerializer.attribute(null, "goAngle", "(0,0,0)");
|
||||
newSerializer.attribute(null, "goScale", "(1,1,1)");
|
||||
newSerializer.attribute(null, "goColor", "(0,0,0,1)");
|
||||
newSerializer.attribute(null, "isDP", "1");
|
||||
newSerializer.endTag(null, "GO");
|
||||
newSerializer.text(property);
|
||||
i2++;
|
||||
it = it2;
|
||||
fileOutputStream4 = fileOutputStream;
|
||||
fileOutputStream3 = null;
|
||||
} catch (FileNotFoundException e) {
|
||||
e = e;
|
||||
fileOutputStream2 = fileOutputStream;
|
||||
e.printStackTrace();
|
||||
if (fileOutputStream2 != null) {
|
||||
fileOutputStream2.close();
|
||||
fileOutputStream2 = fileOutputStream2;
|
||||
}
|
||||
} catch (IOException e2) {
|
||||
e = e2;
|
||||
fileOutputStream2 = fileOutputStream;
|
||||
e.printStackTrace();
|
||||
if (fileOutputStream2 != null) {
|
||||
fileOutputStream2.close();
|
||||
fileOutputStream2 = fileOutputStream2;
|
||||
}
|
||||
} catch (IllegalArgumentException e3) {
|
||||
e = e3;
|
||||
fileOutputStream2 = fileOutputStream;
|
||||
e.printStackTrace();
|
||||
if (fileOutputStream2 != null) {
|
||||
fileOutputStream2.close();
|
||||
fileOutputStream2 = fileOutputStream2;
|
||||
}
|
||||
} catch (IllegalStateException e4) {
|
||||
e = e4;
|
||||
fileOutputStream2 = fileOutputStream;
|
||||
e.printStackTrace();
|
||||
if (fileOutputStream2 != null) {
|
||||
fileOutputStream2.close();
|
||||
fileOutputStream2 = fileOutputStream2;
|
||||
}
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
th = th;
|
||||
if (fileOutputStream != null) {
|
||||
try {
|
||||
fileOutputStream.close();
|
||||
throw th;
|
||||
} catch (Exception e5) {
|
||||
e5.printStackTrace();
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
}
|
||||
fileOutputStream = fileOutputStream4;
|
||||
if (b != null) {
|
||||
Iterator<Integer> it3 = b.iterator();
|
||||
fileOutputStream3 = fileOutputStream3;
|
||||
while (it3.hasNext()) {
|
||||
int intValue2 = it3.next().intValue();
|
||||
newSerializer.startTag(null, "GO");
|
||||
newSerializer.attribute(null, JockstickDataConverter.ID, String.valueOf(i2));
|
||||
newSerializer.attribute(null, "type", "motor");
|
||||
newSerializer.attribute(null, MediationMetaData.KEY_NAME, "motor_" + intValue2);
|
||||
newSerializer.attribute(null, "djid", "0");
|
||||
newSerializer.attribute(null, "motorID", String.valueOf(intValue2));
|
||||
newSerializer.attribute(null, "goPos", "(0,0,0)");
|
||||
newSerializer.attribute(null, "goAngle", "(0,0,0)");
|
||||
newSerializer.attribute(null, "goScale", "(1,1,1)");
|
||||
newSerializer.attribute(null, "goColor", "(0,0,0,1)");
|
||||
newSerializer.attribute(null, "isDP", "1");
|
||||
newSerializer.endTag(null, "GO");
|
||||
newSerializer.text(property);
|
||||
i2++;
|
||||
fileOutputStream3 = "1";
|
||||
}
|
||||
}
|
||||
newSerializer.endTag(null, "Root");
|
||||
newSerializer.text(property);
|
||||
newSerializer.endDocument();
|
||||
newSerializer.flush();
|
||||
fileOutputStream.close();
|
||||
fileOutputStream2 = fileOutputStream3;
|
||||
} catch (FileNotFoundException e6) {
|
||||
e = e6;
|
||||
fileOutputStream = fileOutputStream4;
|
||||
} catch (IOException e7) {
|
||||
e = e7;
|
||||
fileOutputStream = fileOutputStream4;
|
||||
} catch (IllegalArgumentException e8) {
|
||||
e = e8;
|
||||
fileOutputStream = fileOutputStream4;
|
||||
} catch (IllegalStateException e9) {
|
||||
e = e9;
|
||||
fileOutputStream = fileOutputStream4;
|
||||
} catch (Throwable th3) {
|
||||
th = th3;
|
||||
fileOutputStream = fileOutputStream4;
|
||||
}
|
||||
} catch (FileNotFoundException e10) {
|
||||
e = e10;
|
||||
} catch (IOException e11) {
|
||||
e = e11;
|
||||
} catch (IllegalArgumentException e12) {
|
||||
e = e12;
|
||||
} catch (IllegalStateException e13) {
|
||||
e = e13;
|
||||
} catch (Throwable th4) {
|
||||
th = th4;
|
||||
fileOutputStream = null;
|
||||
}
|
||||
} catch (Throwable th5) {
|
||||
th = th5;
|
||||
fileOutputStream = fileOutputStream2;
|
||||
}
|
||||
} catch (Exception e14) {
|
||||
e14.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
498
sources/com/ubt/jimu/connect/model/PeripheralConnections.java
Normal file
498
sources/com/ubt/jimu/connect/model/PeripheralConnections.java
Normal file
@@ -0,0 +1,498 @@
|
||||
package com.ubt.jimu.connect.model;
|
||||
|
||||
import android.os.Environment;
|
||||
import android.util.Log;
|
||||
import com.ubt.jimu.base.data.ServoMode;
|
||||
import com.ubt.jimu.connect.model.TopologyPartData;
|
||||
import com.ubt.jimu.utils.SystemUtils;
|
||||
import com.ubtech.utils.XLog;
|
||||
import com.ubtrobot.jimu.robotapi.BoardInfo;
|
||||
import com.ubtrobot.jimu.robotapi.PeripheralType;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class PeripheralConnections {
|
||||
private List<TopologyPartData> a = new ArrayList();
|
||||
private HashMap<Integer, List<Integer>> b;
|
||||
private HashMap<Integer, ServoMode> c;
|
||||
private HashMap<String, String> d;
|
||||
private long e;
|
||||
private HashMap<Integer, ArrayList<Integer>> f;
|
||||
|
||||
/* renamed from: com.ubt.jimu.connect.model.PeripheralConnections$1, reason: invalid class name */
|
||||
static /* synthetic */ class AnonymousClass1 {
|
||||
static final /* synthetic */ int[] a = new int[TopologyPartData.TopologyPartType.values().length];
|
||||
|
||||
static {
|
||||
try {
|
||||
a[TopologyPartData.TopologyPartType.Servo.ordinal()] = 1;
|
||||
} catch (NoSuchFieldError unused) {
|
||||
}
|
||||
try {
|
||||
a[TopologyPartData.TopologyPartType.Motor.ordinal()] = 2;
|
||||
} catch (NoSuchFieldError unused2) {
|
||||
}
|
||||
try {
|
||||
a[TopologyPartData.TopologyPartType.Gyro.ordinal()] = 3;
|
||||
} catch (NoSuchFieldError unused3) {
|
||||
}
|
||||
try {
|
||||
a[TopologyPartData.TopologyPartType.Light.ordinal()] = 4;
|
||||
} catch (NoSuchFieldError unused4) {
|
||||
}
|
||||
try {
|
||||
a[TopologyPartData.TopologyPartType.Touch.ordinal()] = 5;
|
||||
} catch (NoSuchFieldError unused5) {
|
||||
}
|
||||
try {
|
||||
a[TopologyPartData.TopologyPartType.Color.ordinal()] = 6;
|
||||
} catch (NoSuchFieldError unused6) {
|
||||
}
|
||||
try {
|
||||
a[TopologyPartData.TopologyPartType.Gravity.ordinal()] = 7;
|
||||
} catch (NoSuchFieldError unused7) {
|
||||
}
|
||||
try {
|
||||
a[TopologyPartData.TopologyPartType.Speaker.ordinal()] = 8;
|
||||
} catch (NoSuchFieldError unused8) {
|
||||
}
|
||||
try {
|
||||
a[TopologyPartData.TopologyPartType.Infrared.ordinal()] = 9;
|
||||
} catch (NoSuchFieldError unused9) {
|
||||
}
|
||||
try {
|
||||
a[TopologyPartData.TopologyPartType.Compass.ordinal()] = 10;
|
||||
} catch (NoSuchFieldError unused10) {
|
||||
}
|
||||
try {
|
||||
a[TopologyPartData.TopologyPartType.EnLight.ordinal()] = 11;
|
||||
} catch (NoSuchFieldError unused11) {
|
||||
}
|
||||
try {
|
||||
a[TopologyPartData.TopologyPartType.Atmosphere.ordinal()] = 12;
|
||||
} catch (NoSuchFieldError unused12) {
|
||||
}
|
||||
try {
|
||||
a[TopologyPartData.TopologyPartType.Ultrasonic.ordinal()] = 13;
|
||||
} catch (NoSuchFieldError unused13) {
|
||||
}
|
||||
try {
|
||||
a[TopologyPartData.TopologyPartType.DigitalTube.ordinal()] = 14;
|
||||
} catch (NoSuchFieldError unused14) {
|
||||
}
|
||||
try {
|
||||
a[TopologyPartData.TopologyPartType.Temperature.ordinal()] = 15;
|
||||
} catch (NoSuchFieldError unused15) {
|
||||
}
|
||||
try {
|
||||
a[TopologyPartData.TopologyPartType.MainBoard.ordinal()] = 16;
|
||||
} catch (NoSuchFieldError unused16) {
|
||||
}
|
||||
try {
|
||||
a[TopologyPartData.TopologyPartType.MainBoard_new_low.ordinal()] = 17;
|
||||
} catch (NoSuchFieldError unused17) {
|
||||
}
|
||||
try {
|
||||
a[TopologyPartData.TopologyPartType.RgbLight.ordinal()] = 18;
|
||||
} catch (NoSuchFieldError unused18) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public PeripheralConnections() {
|
||||
TopologyPartData.TopologyPartType topologyPartType = TopologyPartData.TopologyPartType.MainBoard;
|
||||
this.b = new HashMap<>();
|
||||
this.c = new HashMap<>();
|
||||
this.d = new HashMap<>();
|
||||
this.f = new HashMap<>();
|
||||
}
|
||||
|
||||
public static String d(String str) {
|
||||
return str + "/servos/servos.txt";
|
||||
}
|
||||
|
||||
public long a() {
|
||||
return this.e;
|
||||
}
|
||||
|
||||
public HashMap<Integer, ArrayList<Integer>> b() {
|
||||
return this.f;
|
||||
}
|
||||
|
||||
public HashMap<Integer, ServoMode> c() {
|
||||
return this.c;
|
||||
}
|
||||
|
||||
public static PeripheralConnections b(BoardInfo boardInfo) {
|
||||
PeripheralConnections peripheralConnections = new PeripheralConnections();
|
||||
peripheralConnections.c(boardInfo);
|
||||
return peripheralConnections;
|
||||
}
|
||||
|
||||
private static PeripheralConnections c(String str) {
|
||||
if (!new File(str + "/servos/servos.txt").exists()) {
|
||||
return null;
|
||||
}
|
||||
PeripheralConnections peripheralConnections = new PeripheralConnections();
|
||||
peripheralConnections.a(str);
|
||||
return peripheralConnections;
|
||||
}
|
||||
|
||||
public List<Integer> a(int i) {
|
||||
HashMap<Integer, ArrayList<Integer>> hashMap = this.f;
|
||||
if (hashMap == null || hashMap.size() <= 0) {
|
||||
return null;
|
||||
}
|
||||
return this.f.get(Integer.valueOf(i));
|
||||
}
|
||||
|
||||
private HashMap<Integer, ArrayList<Integer>> a(List<TopologyPartData> list) {
|
||||
HashMap<Integer, ArrayList<Integer>> hashMap = new HashMap<>();
|
||||
for (TopologyPartData topologyPartData : list) {
|
||||
int a = a(topologyPartData.b);
|
||||
if (a != -1) {
|
||||
ArrayList<Integer> arrayList = hashMap.get(Integer.valueOf(a));
|
||||
if (arrayList == null) {
|
||||
arrayList = new ArrayList<>();
|
||||
}
|
||||
arrayList.add(Integer.valueOf(topologyPartData.a));
|
||||
hashMap.put(Integer.valueOf(a), arrayList);
|
||||
}
|
||||
}
|
||||
return hashMap;
|
||||
}
|
||||
|
||||
private int b(TopologyPartData.TopologyPartType topologyPartType) {
|
||||
switch (AnonymousClass1.a[topologyPartType.ordinal()]) {
|
||||
case 1:
|
||||
return PeripheralType.SERVO;
|
||||
case 2:
|
||||
return 10;
|
||||
case 3:
|
||||
return 3;
|
||||
case 4:
|
||||
return 4;
|
||||
case 5:
|
||||
return 2;
|
||||
case 6:
|
||||
return 9;
|
||||
case 7:
|
||||
return 5;
|
||||
case 8:
|
||||
return 8;
|
||||
case 9:
|
||||
return 1;
|
||||
case 10:
|
||||
return 96;
|
||||
case 11:
|
||||
return 12;
|
||||
case 12:
|
||||
return 97;
|
||||
case 13:
|
||||
return 6;
|
||||
case 14:
|
||||
return 7;
|
||||
case 15:
|
||||
return 11;
|
||||
case 16:
|
||||
return 112;
|
||||
case 17:
|
||||
return 113;
|
||||
case 18:
|
||||
return 14;
|
||||
default:
|
||||
Log.e("PeripheralConnections", "Invalid peripheral type. TopologyPartType:" + topologyPartType);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
private TopologyPartData.TopologyPartType b(int i) {
|
||||
if (i == 14) {
|
||||
return TopologyPartData.TopologyPartType.RgbLight;
|
||||
}
|
||||
if (i == 128) {
|
||||
return TopologyPartData.TopologyPartType.Servo;
|
||||
}
|
||||
if (i == 96) {
|
||||
return TopologyPartData.TopologyPartType.Compass;
|
||||
}
|
||||
if (i == 97) {
|
||||
return TopologyPartData.TopologyPartType.Atmosphere;
|
||||
}
|
||||
if (i == 112) {
|
||||
return TopologyPartData.TopologyPartType.MainBoard;
|
||||
}
|
||||
if (i != 113) {
|
||||
switch (i) {
|
||||
case 1:
|
||||
return TopologyPartData.TopologyPartType.Infrared;
|
||||
case 2:
|
||||
return TopologyPartData.TopologyPartType.Touch;
|
||||
case 3:
|
||||
return TopologyPartData.TopologyPartType.Gyro;
|
||||
case 4:
|
||||
return TopologyPartData.TopologyPartType.Light;
|
||||
case 5:
|
||||
return TopologyPartData.TopologyPartType.Gravity;
|
||||
case 6:
|
||||
return TopologyPartData.TopologyPartType.Ultrasonic;
|
||||
case 7:
|
||||
return TopologyPartData.TopologyPartType.DigitalTube;
|
||||
case 8:
|
||||
return TopologyPartData.TopologyPartType.Speaker;
|
||||
case 9:
|
||||
return TopologyPartData.TopologyPartType.Color;
|
||||
case 10:
|
||||
return TopologyPartData.TopologyPartType.Motor;
|
||||
case 11:
|
||||
return TopologyPartData.TopologyPartType.Temperature;
|
||||
case 12:
|
||||
return TopologyPartData.TopologyPartType.EnLight;
|
||||
default:
|
||||
return TopologyPartData.TopologyPartType.None;
|
||||
}
|
||||
}
|
||||
return TopologyPartData.TopologyPartType.MainBoard_new_low;
|
||||
}
|
||||
|
||||
private void c(BoardInfo boardInfo) {
|
||||
if (boardInfo == null) {
|
||||
return;
|
||||
}
|
||||
this.a.add(new TopologyPartData(b(boardInfo.e()), 0, false));
|
||||
for (Integer num : boardInfo.i()) {
|
||||
this.c.put(num, ServoMode.SERVO_MODE_ANGLE);
|
||||
this.a.add(new TopologyPartData(TopologyPartData.TopologyPartType.Servo, num.intValue(), false));
|
||||
}
|
||||
for (Map.Entry<Integer, BoardInfo.SensorBoardInfo> entry : boardInfo.h().entrySet()) {
|
||||
boolean z = entry.getKey().intValue() != 10;
|
||||
TopologyPartData.TopologyPartType b = b(entry.getKey().intValue());
|
||||
Iterator<Integer> it = entry.getValue().b().iterator();
|
||||
while (it.hasNext()) {
|
||||
this.a.add(new TopologyPartData(b, it.next().intValue(), z));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int a(TopologyPartData.TopologyPartType topologyPartType) {
|
||||
switch (AnonymousClass1.a[topologyPartType.ordinal()]) {
|
||||
case 1:
|
||||
return PeripheralType.SERVO;
|
||||
case 2:
|
||||
return 10;
|
||||
case 3:
|
||||
return 3;
|
||||
case 4:
|
||||
return 4;
|
||||
case 5:
|
||||
return 2;
|
||||
case 6:
|
||||
return 9;
|
||||
case 7:
|
||||
return 5;
|
||||
case 8:
|
||||
return 8;
|
||||
case 9:
|
||||
return 1;
|
||||
case 10:
|
||||
return 96;
|
||||
case 11:
|
||||
return 12;
|
||||
case 12:
|
||||
return 97;
|
||||
case 13:
|
||||
return 6;
|
||||
case 14:
|
||||
return 7;
|
||||
case 15:
|
||||
return 11;
|
||||
case 16:
|
||||
return 112;
|
||||
case 17:
|
||||
return 113;
|
||||
case 18:
|
||||
return 14;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public static PeripheralConnections a(String str, String str2, boolean z) {
|
||||
String str3 = Environment.getExternalStorageDirectory().getPath() + "/Android/data/com.ubt.jimu/files";
|
||||
String str4 = str3 + "/default/" + str;
|
||||
String str5 = str3 + "/users/" + str2 + "/";
|
||||
if (!z) {
|
||||
String str6 = str5 + "/default/" + str;
|
||||
PeripheralConnections c = c(str6);
|
||||
PeripheralConnections c2 = c(str4);
|
||||
if (c == null || (c2 != null && c2.a() > c.a())) {
|
||||
c = c2;
|
||||
}
|
||||
if (c == c2) {
|
||||
XLog.c("PeripheralConnections", "Connection folder:" + str4);
|
||||
return c;
|
||||
}
|
||||
XLog.c("PeripheralConnections", "Connection folder:" + str6);
|
||||
return c;
|
||||
}
|
||||
String str7 = str5 + "/playerdata/" + str;
|
||||
PeripheralConnections c3 = c(str7);
|
||||
XLog.c("PeripheralConnections", "Connection folder:" + str7);
|
||||
return c3;
|
||||
}
|
||||
|
||||
public void a(BoardInfo boardInfo) {
|
||||
BoardInfo.SensorBoardInfo sensorBoardInfo;
|
||||
HashMap<Integer, BoardInfo.SensorBoardInfo> h = boardInfo.h();
|
||||
for (Map.Entry<Integer, BoardInfo.SensorBoardInfo> entry : h.entrySet()) {
|
||||
if (entry.getKey().intValue() != 10) {
|
||||
TopologyPartData.TopologyPartType b = b(entry.getKey().intValue());
|
||||
Iterator<Integer> it = entry.getValue().b().iterator();
|
||||
while (it.hasNext()) {
|
||||
int intValue = it.next().intValue();
|
||||
if (!a(b, intValue)) {
|
||||
this.a.add(new TopologyPartData(b, intValue, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Iterator<TopologyPartData> it2 = this.a.iterator();
|
||||
while (it2.hasNext()) {
|
||||
TopologyPartData next = it2.next();
|
||||
int b2 = b(next.b);
|
||||
if (b2 != 128 && b2 != 10 && b2 != 112 && b2 != 113 && (sensorBoardInfo = h.get(Integer.valueOf(b2))) != null && !sensorBoardInfo.b().contains(Integer.valueOf(next.a)) && next.c) {
|
||||
it2.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void b(String str) {
|
||||
String str2 = str + "/servos";
|
||||
File file = new File(str2);
|
||||
if (!file.exists()) {
|
||||
file.mkdirs();
|
||||
}
|
||||
File file2 = new File(str2 + "/servos.txt");
|
||||
if (!file2.exists()) {
|
||||
try {
|
||||
file2.createNewFile();
|
||||
} catch (IOException e) {
|
||||
XLog.a("PeripheralConnections", "Create file fail!", e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
String property = System.getProperty("line.separator");
|
||||
try {
|
||||
FileWriter fileWriter = new FileWriter(file2);
|
||||
try {
|
||||
BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
|
||||
try {
|
||||
for (Map.Entry<Integer, List<Integer>> entry : this.b.entrySet()) {
|
||||
bufferedWriter.write(entry.getKey() + " " + b(entry.getValue()) + property);
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
StringBuilder sb2 = new StringBuilder();
|
||||
for (Map.Entry<Integer, ServoMode> entry2 : this.c.entrySet()) {
|
||||
if (entry2.getValue() == ServoMode.SERVO_MODE_ANGLE) {
|
||||
if (sb.length() > 0) {
|
||||
sb.append(",");
|
||||
}
|
||||
sb.append(entry2.getKey());
|
||||
} else {
|
||||
if (sb2.length() > 0) {
|
||||
sb2.append(",");
|
||||
}
|
||||
sb2.append(entry2.getKey());
|
||||
}
|
||||
}
|
||||
if (sb.length() > 0) {
|
||||
bufferedWriter.write("angleServos:" + sb.toString() + property);
|
||||
}
|
||||
if (sb2.length() > 0) {
|
||||
bufferedWriter.write("turnServos:" + sb2.toString() + property);
|
||||
}
|
||||
int size = this.a.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
bufferedWriter.write("partData:" + this.a.get(i).toString() + property);
|
||||
}
|
||||
if (this.d.size() > 0) {
|
||||
StringBuilder sb3 = new StringBuilder();
|
||||
for (Map.Entry<String, String> entry3 : this.d.entrySet()) {
|
||||
if (sb3.length() > 0) {
|
||||
sb3.append("|");
|
||||
}
|
||||
sb3.append(entry3.getKey());
|
||||
sb3.append(",");
|
||||
sb3.append(entry3.getValue());
|
||||
}
|
||||
bufferedWriter.write("portConnection:" + sb3.toString() + property);
|
||||
}
|
||||
bufferedWriter.flush();
|
||||
this.e = SystemUtils.a();
|
||||
bufferedWriter.close();
|
||||
fileWriter.close();
|
||||
} finally {
|
||||
}
|
||||
} finally {
|
||||
}
|
||||
} catch (Exception e2) {
|
||||
XLog.a("PeripheralConnections", "Save file fail!", e2);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean a(TopologyPartData.TopologyPartType topologyPartType, int i) {
|
||||
for (TopologyPartData topologyPartData : this.a) {
|
||||
if (topologyPartData.b == topologyPartType && topologyPartData.a == i) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
/* JADX WARN: Removed duplicated region for block: B:84:0x0166 A[EXC_TOP_SPLITTER, SYNTHETIC] */
|
||||
/* JADX WARN: Type inference failed for: r2v0, types: [long] */
|
||||
/* JADX WARN: Type inference failed for: r2v1 */
|
||||
/* JADX WARN: Type inference failed for: r2v3, types: [java.io.BufferedReader] */
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
public void a(java.lang.String r13) {
|
||||
/*
|
||||
Method dump skipped, instructions count: 362
|
||||
To view this dump change 'Code comments level' option to 'DEBUG'
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.ubt.jimu.connect.model.PeripheralConnections.a(java.lang.String):void");
|
||||
}
|
||||
|
||||
private <T> String b(List<T> list) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
Iterator<T> it = list.iterator();
|
||||
while (it.hasNext()) {
|
||||
stringBuffer.append(it.next());
|
||||
stringBuffer.append(",");
|
||||
}
|
||||
stringBuffer.deleteCharAt(stringBuffer.length() - 1);
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
public ServoMode a(Integer num) {
|
||||
if (this.c.containsKey(num)) {
|
||||
return this.c.get(num);
|
||||
}
|
||||
return ServoMode.SERVO_MODE_ANGLE;
|
||||
}
|
||||
|
||||
public void a(Integer num, ServoMode servoMode) {
|
||||
this.c.put(num, servoMode);
|
||||
}
|
||||
}
|
75
sources/com/ubt/jimu/connect/model/ReadAllServoModel.java
Normal file
75
sources/com/ubt/jimu/connect/model/ReadAllServoModel.java
Normal file
@@ -0,0 +1,75 @@
|
||||
package com.ubt.jimu.connect.model;
|
||||
|
||||
import com.ubt.jimu.base.cache.Cache;
|
||||
import com.ubt.jimu.base.data.ServoMode;
|
||||
import com.ubt.jimu.base.entities.User;
|
||||
import com.ubtech.utils.XLog;
|
||||
import com.ubtrobot.jimu.robotapi.JimuManager;
|
||||
import com.ubtrobot.jimu.robotapi.ServoAngleReadInfo;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ReadAllServoModel {
|
||||
private JimuManager a;
|
||||
|
||||
public ReadAllServoModel(JimuManager jimuManager) {
|
||||
this.a = jimuManager;
|
||||
}
|
||||
|
||||
public List<ServoAngleReadInfo> a(String str, boolean z) {
|
||||
ServoAngleReadInfo servoAngleReadInfo;
|
||||
PeripheralConnections a = PeripheralConnections.a(str, a(), z);
|
||||
if (a == null) {
|
||||
return null;
|
||||
}
|
||||
ArrayList arrayList = new ArrayList();
|
||||
for (Map.Entry<Integer, ServoMode> entry : a.c().entrySet()) {
|
||||
if (entry != null && entry.getValue() == ServoMode.SERVO_MODE_ANGLE) {
|
||||
try {
|
||||
servoAngleReadInfo = this.a.b(entry.getKey().intValue(), true);
|
||||
} catch (Exception e) {
|
||||
XLog.a("ReadAllServoModel", "Read servo " + entry.getKey() + " angle fail!", e);
|
||||
servoAngleReadInfo = null;
|
||||
}
|
||||
if (servoAngleReadInfo != null) {
|
||||
if (servoAngleReadInfo.a() < 2.0f) {
|
||||
servoAngleReadInfo.b(5.0f);
|
||||
arrayList.add(servoAngleReadInfo);
|
||||
} else if (servoAngleReadInfo.a() > 238.0f) {
|
||||
servoAngleReadInfo.b(235.0f);
|
||||
arrayList.add(servoAngleReadInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
public void a(List<ServoAngleReadInfo> list) {
|
||||
if (list == null || list.size() == 0) {
|
||||
return;
|
||||
}
|
||||
int[] iArr = new int[list.size()];
|
||||
float[] fArr = new float[list.size()];
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
ServoAngleReadInfo servoAngleReadInfo = list.get(i);
|
||||
iArr[i] = servoAngleReadInfo.b();
|
||||
fArr[i] = servoAngleReadInfo.c();
|
||||
}
|
||||
try {
|
||||
this.a.a(iArr, fArr, 400, 100);
|
||||
} catch (Exception e) {
|
||||
XLog.a("ReadAllServoModel", "setServoAngle fail", e);
|
||||
}
|
||||
}
|
||||
|
||||
private String a() {
|
||||
User user = Cache.getInstance().getUser();
|
||||
if (user == null) {
|
||||
return "local";
|
||||
}
|
||||
return user.getUserId() + "";
|
||||
}
|
||||
}
|
22
sources/com/ubt/jimu/connect/model/ServoComponent.java
Normal file
22
sources/com/ubt/jimu/connect/model/ServoComponent.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package com.ubt.jimu.connect.model;
|
||||
|
||||
import com.ubt.jimu.base.data.ServoMode;
|
||||
import com.ubtrobot.jimu.robotapi.PeripheralType;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ServoComponent extends Component {
|
||||
private ServoMode e;
|
||||
|
||||
public ServoComponent(int i, ErrorType errorType) {
|
||||
super(PeripheralType.SERVO, i, errorType);
|
||||
this.e = ServoMode.SERVO_MODE_ANGLE;
|
||||
}
|
||||
|
||||
public void a(ServoMode servoMode) {
|
||||
this.e = servoMode;
|
||||
}
|
||||
|
||||
public ServoMode f() {
|
||||
return this.e;
|
||||
}
|
||||
}
|
152
sources/com/ubt/jimu/connect/model/TopologyPartData.java
Normal file
152
sources/com/ubt/jimu/connect/model/TopologyPartData.java
Normal file
@@ -0,0 +1,152 @@
|
||||
package com.ubt.jimu.connect.model;
|
||||
|
||||
import com.ubtech.utils.XLog;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class TopologyPartData {
|
||||
public int a;
|
||||
public TopologyPartType b;
|
||||
public boolean c;
|
||||
public int d;
|
||||
public int e;
|
||||
|
||||
public enum TopologyPartType {
|
||||
None(0),
|
||||
Infrared(1),
|
||||
Touch(2),
|
||||
Gyro(3),
|
||||
Light(4),
|
||||
Gravity(5),
|
||||
Ultrasonic(6),
|
||||
DigitalTube(7),
|
||||
Speaker(8),
|
||||
EnLight(9),
|
||||
Atmosphere(10),
|
||||
Compass(11),
|
||||
Temperature(12),
|
||||
Color(13),
|
||||
RgbLight(14),
|
||||
Motor(15),
|
||||
MainBoard(16),
|
||||
MainBoard_new_low(17),
|
||||
Servo(18),
|
||||
Line(19),
|
||||
Line_Angle(20);
|
||||
|
||||
private int value;
|
||||
|
||||
TopologyPartType(int i) {
|
||||
this.value = i;
|
||||
}
|
||||
|
||||
public static TopologyPartType getEnumType(int i) {
|
||||
for (TopologyPartType topologyPartType : values()) {
|
||||
if (topologyPartType.getTypeVal() == i) {
|
||||
return topologyPartType;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getTypeVal() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
|
||||
public TopologyPartData(TopologyPartType topologyPartType, int i, boolean z) {
|
||||
this.a = i;
|
||||
this.b = topologyPartType;
|
||||
this.c = z;
|
||||
this.d = 0;
|
||||
this.e = 0;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(this.a);
|
||||
sb.append(' ');
|
||||
sb.append(this.b.toString());
|
||||
sb.append(' ');
|
||||
if (this.c) {
|
||||
sb.append("True");
|
||||
} else {
|
||||
sb.append("False");
|
||||
}
|
||||
sb.append(' ');
|
||||
sb.append("0,0");
|
||||
sb.append(' ');
|
||||
sb.append("0,0,0");
|
||||
sb.append(' ');
|
||||
sb.append(this.d);
|
||||
sb.append(' ');
|
||||
sb.append(this.e);
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public TopologyPartData() {
|
||||
this.a = 0;
|
||||
this.b = TopologyPartType.Servo;
|
||||
this.c = false;
|
||||
this.d = 0;
|
||||
this.e = 0;
|
||||
}
|
||||
|
||||
public TopologyPartData(String str) {
|
||||
try {
|
||||
String[] split = str.split(" ");
|
||||
int length = split.length;
|
||||
for (int i = 0; i < length; i++) {
|
||||
switch (i) {
|
||||
case 0:
|
||||
try {
|
||||
this.a = Integer.valueOf(split[i]).intValue();
|
||||
break;
|
||||
} catch (NumberFormatException unused) {
|
||||
this.a = 0;
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
try {
|
||||
try {
|
||||
int intValue = Integer.valueOf(split[i]).intValue();
|
||||
this.b = TopologyPartType.getEnumType(intValue >= 8 ? intValue + 1 : intValue);
|
||||
break;
|
||||
} catch (Exception e) {
|
||||
XLog.a("TopologyPartData", "get type" + split[i] + " - TopologyPartData error", e);
|
||||
break;
|
||||
}
|
||||
} catch (NumberFormatException unused2) {
|
||||
this.b = (TopologyPartType) Enum.valueOf(TopologyPartType.class, split[i]);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
try {
|
||||
this.c = Boolean.valueOf(split[i]).booleanValue();
|
||||
break;
|
||||
} catch (Exception unused3) {
|
||||
XLog.b("TopologyPartData", "get ");
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
try {
|
||||
this.d = Integer.valueOf(split[i]).intValue();
|
||||
break;
|
||||
} catch (Exception e2) {
|
||||
XLog.a("TopologyPartData", "Get device width fail", e2);
|
||||
break;
|
||||
}
|
||||
case 6:
|
||||
try {
|
||||
this.e = Integer.valueOf(split[i]).intValue();
|
||||
break;
|
||||
} catch (Exception e3) {
|
||||
XLog.a("TopologyPartData", "Get device width fail", e3);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e4) {
|
||||
XLog.a("TopologyPartData", "", e4);
|
||||
}
|
||||
}
|
||||
}
|
347
sources/com/ubt/jimu/connect/model/UpdateModelImp.java
Normal file
347
sources/com/ubt/jimu/connect/model/UpdateModelImp.java
Normal file
@@ -0,0 +1,347 @@
|
||||
package com.ubt.jimu.connect.model;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import com.ubt.jimu.JimuApplication;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.base.db.robot.FirmwareVersionDbHandler;
|
||||
import com.ubt.jimu.base.entities.FirmwareVersion;
|
||||
import com.ubtech.utils.FileHelper;
|
||||
import com.ubtrobot.jimu.Firmware;
|
||||
import com.ubtrobot.jimu.robotapi.BoardInfo;
|
||||
import com.ubtrobot.jimu.robotapi.PeripheralType;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class UpdateModelImp implements IUpdateModel {
|
||||
public static final Long b;
|
||||
public static final Long c;
|
||||
public static final Long d;
|
||||
public static final Long e;
|
||||
public static final Long f;
|
||||
public static final Long g;
|
||||
public static final Long h;
|
||||
public static final Long i;
|
||||
public static final Long j;
|
||||
public static final Long k;
|
||||
public static final Long l;
|
||||
public static final Long m;
|
||||
private boolean a;
|
||||
|
||||
private static class Holder {
|
||||
private static final UpdateModelImp a = new UpdateModelImp();
|
||||
}
|
||||
|
||||
static {
|
||||
Long.valueOf(-1L);
|
||||
b = 3L;
|
||||
c = 4L;
|
||||
d = 5L;
|
||||
e = 101L;
|
||||
f = 102L;
|
||||
g = 103L;
|
||||
h = 104L;
|
||||
i = 105L;
|
||||
j = 106L;
|
||||
k = 107L;
|
||||
l = 108L;
|
||||
m = 109L;
|
||||
}
|
||||
|
||||
public static int a(long j2) {
|
||||
if (b.longValue() == j2) {
|
||||
return 112;
|
||||
}
|
||||
if (d.longValue() == j2) {
|
||||
return 113;
|
||||
}
|
||||
if (c.longValue() == j2) {
|
||||
return PeripheralType.SERVO;
|
||||
}
|
||||
if (e.longValue() == j2) {
|
||||
return 1;
|
||||
}
|
||||
if (f.longValue() == j2) {
|
||||
return 2;
|
||||
}
|
||||
if (g.longValue() == j2) {
|
||||
return 3;
|
||||
}
|
||||
if (h.longValue() == j2) {
|
||||
return 4;
|
||||
}
|
||||
if (i.longValue() == j2) {
|
||||
return 5;
|
||||
}
|
||||
if (j.longValue() == j2) {
|
||||
return 6;
|
||||
}
|
||||
if (k.longValue() == j2) {
|
||||
return 7;
|
||||
}
|
||||
if (l.longValue() == j2) {
|
||||
return 8;
|
||||
}
|
||||
return m.longValue() == j2 ? 9 : -1;
|
||||
}
|
||||
|
||||
public static UpdateModelImp b() {
|
||||
return Holder.a;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.model.IUpdateModel
|
||||
public boolean c(BoardInfo boardInfo) {
|
||||
List<Firmware> a = a(boardInfo);
|
||||
return (a == null || a.size() == 0) ? false : true;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.model.IUpdateModel
|
||||
public boolean d(BoardInfo boardInfo) {
|
||||
Iterator<Firmware> it = a(boardInfo).iterator();
|
||||
while (it.hasNext()) {
|
||||
if (it.next().e()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private UpdateModelImp() {
|
||||
this.a = false;
|
||||
}
|
||||
|
||||
private List<Firmware> b(BoardInfo boardInfo, HashMap<Integer, FirmwareVersion> hashMap) {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
HashMap<Integer, BoardInfo.SensorBoardInfo> h2 = boardInfo.h();
|
||||
if (h2 != null && h2.size() != 0) {
|
||||
for (Integer num : h2.keySet()) {
|
||||
BoardInfo.SensorBoardInfo sensorBoardInfo = h2.get(num);
|
||||
List<Integer> b2 = sensorBoardInfo.b();
|
||||
List<Integer> d2 = sensorBoardInfo.d();
|
||||
if ((b2 != null && b2.size() != 0) || (d2 != null && d2.size() != 0)) {
|
||||
FirmwareVersion firmwareVersion = hashMap.get(num);
|
||||
if (firmwareVersion != null) {
|
||||
if (!firmwareVersion.getVersionName().equals(sensorBoardInfo.c())) {
|
||||
ArrayList arrayList2 = new ArrayList();
|
||||
if (b2 != null && b2.size() > 0) {
|
||||
arrayList2.addAll(b2);
|
||||
}
|
||||
if (d2 != null && d2.size() > 0) {
|
||||
arrayList2.addAll(d2);
|
||||
}
|
||||
Iterator it = arrayList2.iterator();
|
||||
while (it.hasNext()) {
|
||||
arrayList.add(a(firmwareVersion, ((Integer) it.next()).intValue()));
|
||||
}
|
||||
} else if (d2 != null && d2.size() > 0) {
|
||||
Iterator<Integer> it2 = d2.iterator();
|
||||
while (it2.hasNext()) {
|
||||
arrayList.add(a(firmwareVersion, it2.next().intValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
private List<Firmware> c(BoardInfo boardInfo, HashMap<Integer, FirmwareVersion> hashMap) {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
List<Integer> k2 = boardInfo.k();
|
||||
String j2 = boardInfo.j();
|
||||
FirmwareVersion firmwareVersion = hashMap.get(Integer.valueOf(PeripheralType.SERVO));
|
||||
if (firmwareVersion != null) {
|
||||
if (!TextUtils.isEmpty(j2) && !j2.equals(firmwareVersion.getVersionName())) {
|
||||
ArrayList arrayList2 = new ArrayList();
|
||||
if (boardInfo.i() != null && boardInfo.i().size() > 0) {
|
||||
arrayList2.addAll(boardInfo.i());
|
||||
}
|
||||
if (k2 != null && k2.size() > 0) {
|
||||
arrayList2.addAll(boardInfo.a());
|
||||
}
|
||||
Iterator it = arrayList2.iterator();
|
||||
while (it.hasNext()) {
|
||||
arrayList.add(a(firmwareVersion, ((Integer) it.next()).intValue()));
|
||||
}
|
||||
} else if (k2 != null && k2.size() > 0) {
|
||||
Iterator<Integer> it2 = boardInfo.a().iterator();
|
||||
while (it2.hasNext()) {
|
||||
arrayList.add(a(firmwareVersion, it2.next().intValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
public static Firmware a(FirmwareVersion firmwareVersion, int i2) {
|
||||
return new Firmware(a(firmwareVersion.getVersionType().longValue()), firmwareVersion.getVersionName(), FirmwareVersion.getPath(JimuApplication.l(), firmwareVersion), firmwareVersion.getVersionCRCCode(), i2, firmwareVersion.IsForced());
|
||||
}
|
||||
|
||||
public static String a(Context context, long j2) {
|
||||
if (j2 == 112 || j2 == 113) {
|
||||
return context.getString(R.string.main_board);
|
||||
}
|
||||
if (j2 == 128) {
|
||||
return context.getString(R.string.servo);
|
||||
}
|
||||
if (j2 == 10) {
|
||||
return context.getString(R.string.motor);
|
||||
}
|
||||
if (j2 == 1) {
|
||||
return context.getString(R.string.infrared);
|
||||
}
|
||||
if (j2 == 2) {
|
||||
return context.getString(R.string.touch);
|
||||
}
|
||||
if (j2 == 3) {
|
||||
return context.getString(R.string.gyro);
|
||||
}
|
||||
if (j2 == 4) {
|
||||
return context.getString(R.string.led);
|
||||
}
|
||||
if (j2 == 5) {
|
||||
return context.getString(R.string.gravity);
|
||||
}
|
||||
if (j2 == 6) {
|
||||
return context.getString(R.string.ultrasound);
|
||||
}
|
||||
if (j2 == 7) {
|
||||
return context.getString(R.string.digitaltube);
|
||||
}
|
||||
if (j2 == 8) {
|
||||
return context.getString(R.string.speaker);
|
||||
}
|
||||
if (j2 == 9) {
|
||||
return context.getString(R.string.color);
|
||||
}
|
||||
if (j2 == 14) {
|
||||
return context.getString(R.string.unicorn_led);
|
||||
}
|
||||
int i2 = (j2 > 11L ? 1 : (j2 == 11L ? 0 : -1));
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.model.IUpdateModel
|
||||
public boolean b(BoardInfo boardInfo) {
|
||||
return boardInfo == null || boardInfo.c() != 0 || boardInfo.b() >= 7.4f;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.model.IUpdateModel
|
||||
public List<Firmware> a(BoardInfo boardInfo) {
|
||||
if (boardInfo == null) {
|
||||
return null;
|
||||
}
|
||||
ArrayList arrayList = new ArrayList();
|
||||
List<FirmwareVersion> a = a();
|
||||
HashMap<Integer, FirmwareVersion> hashMap = new HashMap<>();
|
||||
for (FirmwareVersion firmwareVersion : a) {
|
||||
hashMap.put(Integer.valueOf(a(firmwareVersion.getVersionType().longValue())), firmwareVersion);
|
||||
}
|
||||
Firmware a2 = a(boardInfo, hashMap);
|
||||
if (a2 != null) {
|
||||
arrayList.add(a2);
|
||||
}
|
||||
List<Firmware> c2 = c(boardInfo, hashMap);
|
||||
if (c2 != null && c2.size() > 0) {
|
||||
arrayList.addAll(c2);
|
||||
}
|
||||
List<Firmware> b2 = b(boardInfo, hashMap);
|
||||
if (b2 != null && b2.size() > 0) {
|
||||
arrayList.addAll(b2);
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
public List<Firmware> a(List<Firmware> list) {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
if (list != null && list.size() != 0) {
|
||||
Firmware firmware = null;
|
||||
ArrayList arrayList2 = new ArrayList();
|
||||
LinkedHashMap linkedHashMap = new LinkedHashMap();
|
||||
for (Firmware firmware2 : list) {
|
||||
if (firmware2.c() == 112 || firmware2.c() == 113) {
|
||||
firmware = firmware2;
|
||||
} else if (firmware2.c() == 128) {
|
||||
arrayList2.add(firmware2);
|
||||
} else {
|
||||
List list2 = (List) linkedHashMap.get(Integer.valueOf(firmware2.c()));
|
||||
if (list2 == null) {
|
||||
list2 = new ArrayList();
|
||||
linkedHashMap.put(Integer.valueOf(firmware2.c()), list2);
|
||||
}
|
||||
list2.add(firmware2);
|
||||
}
|
||||
}
|
||||
if (firmware != null) {
|
||||
arrayList.add(firmware);
|
||||
}
|
||||
if (arrayList2.size() > 0) {
|
||||
Firmware firmware3 = (Firmware) arrayList2.get(0);
|
||||
if (arrayList2.size() > 1) {
|
||||
firmware3.a(0);
|
||||
}
|
||||
arrayList.add(firmware3);
|
||||
}
|
||||
if (linkedHashMap.size() > 0) {
|
||||
Iterator it = linkedHashMap.keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
List list3 = (List) linkedHashMap.get((Integer) it.next());
|
||||
if (list3 != null && list3.size() > 0) {
|
||||
Firmware firmware4 = (Firmware) list3.get(0);
|
||||
if (list3.size() > 1) {
|
||||
firmware4.a(0);
|
||||
}
|
||||
arrayList.add(firmware4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
private Firmware a(BoardInfo boardInfo, HashMap<Integer, FirmwareVersion> hashMap) {
|
||||
if (boardInfo == null) {
|
||||
return null;
|
||||
}
|
||||
String d2 = boardInfo.d();
|
||||
int e2 = boardInfo.e();
|
||||
int i2 = 0;
|
||||
if (112 == e2) {
|
||||
i2 = 112;
|
||||
} else if (113 == e2) {
|
||||
i2 = 113;
|
||||
}
|
||||
FirmwareVersion firmwareVersion = hashMap.get(i2);
|
||||
if (firmwareVersion == null) {
|
||||
return null;
|
||||
}
|
||||
if (!TextUtils.isEmpty(d2) && !d2.equals(firmwareVersion.getVersionName())) {
|
||||
return a(firmwareVersion, 0);
|
||||
}
|
||||
if (this.a) {
|
||||
return a(firmwareVersion, 0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<FirmwareVersion> a() {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
List<FirmwareVersion> selectAll = FirmwareVersionDbHandler.getInstance().selectAll();
|
||||
if (selectAll != null && selectAll.size() != 0) {
|
||||
for (FirmwareVersion firmwareVersion : selectAll) {
|
||||
String path = FirmwareVersion.getPath(JimuApplication.l(), firmwareVersion);
|
||||
if (new File(path).exists() && FileHelper.a(firmwareVersion.getVersionCRCCode(), path)) {
|
||||
firmwareVersion.setVersionPath(path);
|
||||
arrayList.add(firmwareVersion);
|
||||
}
|
||||
}
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
}
|
@@ -0,0 +1,657 @@
|
||||
package com.ubt.jimu.connect.presenter;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.ubt.jimu.JimuApplication;
|
||||
import com.ubt.jimu.base.cache.Cache;
|
||||
import com.ubt.jimu.base.download.Downloader;
|
||||
import com.ubt.jimu.base.entities.FirmwareVersion;
|
||||
import com.ubt.jimu.connect.contract.ComponentListContract$Presenter;
|
||||
import com.ubt.jimu.connect.contract.ComponentListContract$View;
|
||||
import com.ubt.jimu.connect.model.Component;
|
||||
import com.ubt.jimu.connect.model.ErrorType;
|
||||
import com.ubt.jimu.connect.model.MatchResultCallback;
|
||||
import com.ubt.jimu.connect.model.ModelMatchModel;
|
||||
import com.ubt.jimu.connect.model.ReadAllServoModel;
|
||||
import com.ubt.jimu.connect.model.UpdateModelImp;
|
||||
import com.ubt.jimu.utils.RxSchedulers;
|
||||
import com.ubt.jimu.world.repository.VersionRepository;
|
||||
import com.ubtech.utils.FileHelper;
|
||||
import com.ubtech.utils.XLog;
|
||||
import com.ubtrobot.jimu.Firmware;
|
||||
import com.ubtrobot.jimu.connection.ResultCallback;
|
||||
import com.ubtrobot.jimu.robotapi.BoardInfo;
|
||||
import com.ubtrobot.jimu.robotapi.JimuException;
|
||||
import com.ubtrobot.jimu.robotapi.JimuManager;
|
||||
import com.ubtrobot.jimu.robotapi.ServoAngleReadInfo;
|
||||
import com.ubtrobot.jimu.robotapi.UpdateManager;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ComponentListPresenterImpl implements ComponentListContract$Presenter, UpdateManager.UpdateProgressListener {
|
||||
private ComponentListContract$View a;
|
||||
private ExecutorService b = Executors.newSingleThreadExecutor();
|
||||
private JimuManager c = JimuApplication.l().f();
|
||||
private BoardInfo d;
|
||||
|
||||
/* renamed from: com.ubt.jimu.connect.presenter.ComponentListPresenterImpl$8, reason: invalid class name */
|
||||
static /* synthetic */ class AnonymousClass8 {
|
||||
static final /* synthetic */ int[] a = new int[ErrorType.values().length];
|
||||
|
||||
static {
|
||||
try {
|
||||
a[ErrorType.LACK.ordinal()] = 1;
|
||||
} catch (NoSuchFieldError unused) {
|
||||
}
|
||||
try {
|
||||
a[ErrorType.EXTRA.ordinal()] = 2;
|
||||
} catch (NoSuchFieldError unused2) {
|
||||
}
|
||||
try {
|
||||
a[ErrorType.ID_DUPLICATION.ordinal()] = 3;
|
||||
} catch (NoSuchFieldError unused3) {
|
||||
}
|
||||
try {
|
||||
a[ErrorType.TOO_MANY.ordinal()] = 4;
|
||||
} catch (NoSuchFieldError unused4) {
|
||||
}
|
||||
try {
|
||||
a[ErrorType.NONE.ordinal()] = 5;
|
||||
} catch (NoSuchFieldError unused5) {
|
||||
}
|
||||
try {
|
||||
a[ErrorType.PROMPT.ordinal()] = 6;
|
||||
} catch (NoSuchFieldError unused6) {
|
||||
}
|
||||
try {
|
||||
a[ErrorType.NEED_UPDATE.ordinal()] = 7;
|
||||
} catch (NoSuchFieldError unused7) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum PeripheralTypeProority {
|
||||
RGB_LED,
|
||||
LED,
|
||||
SPEAKER,
|
||||
INFRARED,
|
||||
ULTRASOUND,
|
||||
TOUCH,
|
||||
GYRO,
|
||||
DEFAULT_SENSOR,
|
||||
SERVO,
|
||||
MOTOR
|
||||
}
|
||||
|
||||
public ComponentListPresenterImpl(ComponentListContract$View componentListContract$View) {
|
||||
this.a = componentListContract$View;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ComponentListContract$Presenter
|
||||
public void e(final BoardInfo boardInfo) {
|
||||
if (boardInfo == null) {
|
||||
XLog.d("ComponentListPresenterImpl", "Board is null, not update view", new Object[0]);
|
||||
return;
|
||||
}
|
||||
this.d = boardInfo;
|
||||
final ModelMatchModel modelMatchModel = new ModelMatchModel();
|
||||
this.b.execute(new Runnable() { // from class: com.ubt.jimu.connect.presenter.ComponentListPresenterImpl.4
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
ArrayList<Component> a = modelMatchModel.a(boardInfo);
|
||||
ComponentListPresenterImpl.this.d(a);
|
||||
ComponentListPresenterImpl.this.a.a(a, boardInfo);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* JADX WARN: Code restructure failed: missing block: B:17:0x0061, code lost:
|
||||
|
||||
if (r6.c.a(r6.d, r7, r6) == false) goto L28;
|
||||
*/
|
||||
/* JADX WARN: Code restructure failed: missing block: B:18:0x0063, code lost:
|
||||
|
||||
r7 = r6.a;
|
||||
*/
|
||||
/* JADX WARN: Code restructure failed: missing block: B:19:0x0065, code lost:
|
||||
|
||||
if (r7 == null) goto L28;
|
||||
*/
|
||||
/* JADX WARN: Code restructure failed: missing block: B:20:0x0067, code lost:
|
||||
|
||||
r7.c(r6.d);
|
||||
r6.c.b(true);
|
||||
*/
|
||||
@Override // com.ubt.jimu.connect.contract.ComponentListContract$Presenter
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
public boolean f(com.ubtrobot.jimu.robotapi.BoardInfo r7) {
|
||||
/*
|
||||
r6 = this;
|
||||
com.ubt.jimu.connect.model.UpdateModelImp r7 = com.ubt.jimu.connect.model.UpdateModelImp.b()
|
||||
com.ubtrobot.jimu.robotapi.BoardInfo r0 = r6.d
|
||||
java.util.List r7 = r7.a(r0)
|
||||
com.ubt.jimu.connect.model.UpdateModelImp r0 = com.ubt.jimu.connect.model.UpdateModelImp.b()
|
||||
java.util.List r7 = r0.a(r7)
|
||||
r0 = 0
|
||||
if (r7 == 0) goto L83
|
||||
int r1 = r7.size()
|
||||
if (r1 != 0) goto L1c
|
||||
goto L83
|
||||
L1c:
|
||||
java.util.Iterator r1 = r7.iterator()
|
||||
L20:
|
||||
boolean r2 = r1.hasNext()
|
||||
r3 = 1
|
||||
if (r2 == 0) goto L56
|
||||
java.lang.Object r2 = r1.next()
|
||||
com.ubtrobot.jimu.Firmware r2 = (com.ubtrobot.jimu.Firmware) r2
|
||||
java.lang.String r4 = r2.b()
|
||||
boolean r4 = android.text.TextUtils.isEmpty(r4)
|
||||
if (r4 != 0) goto L57
|
||||
java.io.File r4 = new java.io.File
|
||||
java.lang.String r5 = r2.b()
|
||||
r4.<init>(r5)
|
||||
boolean r4 = r4.exists()
|
||||
if (r4 != 0) goto L47
|
||||
goto L57
|
||||
L47:
|
||||
java.lang.String r4 = r2.a()
|
||||
java.lang.String r2 = r2.b()
|
||||
boolean r2 = com.ubtech.utils.FileHelper.a(r4, r2)
|
||||
if (r2 != 0) goto L20
|
||||
goto L57
|
||||
L56:
|
||||
r0 = 1
|
||||
L57:
|
||||
if (r0 == 0) goto L72
|
||||
com.ubtrobot.jimu.robotapi.JimuManager r1 = r6.c
|
||||
com.ubtrobot.jimu.robotapi.BoardInfo r2 = r6.d
|
||||
boolean r7 = r1.a(r2, r7, r6)
|
||||
if (r7 == 0) goto L82
|
||||
com.ubt.jimu.connect.contract.ComponentListContract$View r7 = r6.a
|
||||
if (r7 == 0) goto L82
|
||||
com.ubtrobot.jimu.robotapi.BoardInfo r1 = r6.d
|
||||
r7.c(r1)
|
||||
com.ubtrobot.jimu.robotapi.JimuManager r7 = r6.c
|
||||
r7.b(r3)
|
||||
goto L82
|
||||
L72:
|
||||
com.ubt.jimu.connect.contract.ComponentListContract$View r1 = r6.a
|
||||
if (r1 == 0) goto L82
|
||||
com.ubtrobot.jimu.robotapi.UpdateManager$UpdateException r2 = new com.ubtrobot.jimu.robotapi.UpdateManager$UpdateException
|
||||
r3 = -101(0xffffffffffffff9b, float:NaN)
|
||||
java.lang.String r4 = "固件不存在或者文件已损坏,升级失败!"
|
||||
r2.<init>(r3, r4)
|
||||
r1.a(r2, r7)
|
||||
L82:
|
||||
return r0
|
||||
L83:
|
||||
com.ubt.jimu.connect.contract.ComponentListContract$View r7 = r6.a
|
||||
if (r7 == 0) goto L8a
|
||||
r7.l()
|
||||
L8a:
|
||||
return r0
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.ubt.jimu.connect.presenter.ComponentListPresenterImpl.f(com.ubtrobot.jimu.robotapi.BoardInfo):boolean");
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.jimu.robotapi.UpdateManager.UpdateProgressListener
|
||||
public void g(BoardInfo boardInfo) {
|
||||
this.c.b(false);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("onUpdateSuccess: mView is null?");
|
||||
sb.append(this.a == null);
|
||||
XLog.a("MainActivity", sb.toString());
|
||||
this.d = boardInfo;
|
||||
Cache.getInstance().setBoardInfo(this.d);
|
||||
ComponentListContract$View componentListContract$View = this.a;
|
||||
if (componentListContract$View != null) {
|
||||
componentListContract$View.l();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ComponentListContract$Presenter
|
||||
public BoardInfo t() {
|
||||
return this.d;
|
||||
}
|
||||
|
||||
public /* synthetic */ void c(String str, boolean z) {
|
||||
List<ServoAngleReadInfo> a = new ReadAllServoModel(this.c).a(str, z);
|
||||
if (a == null || a.size() == 0) {
|
||||
this.a.n();
|
||||
d(str, z);
|
||||
} else {
|
||||
ComponentListContract$View componentListContract$View = this.a;
|
||||
if (componentListContract$View == null) {
|
||||
return;
|
||||
}
|
||||
componentListContract$View.a(a);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ComponentListContract$Presenter
|
||||
public boolean d() {
|
||||
return this.c.g();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ComponentListContract$Presenter
|
||||
public boolean b(BoardInfo boardInfo) {
|
||||
return UpdateModelImp.b().b(boardInfo);
|
||||
}
|
||||
|
||||
public void d(String str, boolean z) {
|
||||
BoardInfo boardInfo = this.d;
|
||||
if (boardInfo == null) {
|
||||
return;
|
||||
}
|
||||
new ModelMatchModel().b(boardInfo, str, z);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ComponentListContract$Presenter
|
||||
public void b(final String str, final boolean z) {
|
||||
this.b.execute(new Runnable() { // from class: com.ubt.jimu.connect.presenter.b
|
||||
@Override // java.lang.Runnable
|
||||
public final void run() {
|
||||
ComponentListPresenterImpl.this.c(str, z);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ComponentListContract$Presenter
|
||||
public boolean b(List<Component> list) {
|
||||
Iterator<Component> it = list.iterator();
|
||||
while (it.hasNext()) {
|
||||
if (a(it.next())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ComponentListContract$Presenter
|
||||
public void a(final String str, final boolean z) {
|
||||
this.b.execute(new Runnable() { // from class: com.ubt.jimu.connect.presenter.ComponentListPresenterImpl.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
final ModelMatchModel modelMatchModel = new ModelMatchModel();
|
||||
modelMatchModel.a(str, z, new MatchResultCallback() { // from class: com.ubt.jimu.connect.presenter.ComponentListPresenterImpl.1.1
|
||||
@Override // com.ubt.jimu.connect.model.MatchResultCallback
|
||||
public void a(int i, BoardInfo boardInfo) {
|
||||
ComponentListPresenterImpl.this.d = boardInfo;
|
||||
if (i == -4 || i == -3) {
|
||||
if (boardInfo != null) {
|
||||
Cache.getInstance().setBoardInfo(boardInfo);
|
||||
}
|
||||
} else if (i == -2) {
|
||||
XLog.b("ComponentListPresenterImpl", "Connection timeout!");
|
||||
ComponentListPresenterImpl.this.a.k();
|
||||
return;
|
||||
} else if (i == -1) {
|
||||
XLog.b("ComponentListPresenterImpl", "Connected Device is not Jimu Robot");
|
||||
ComponentListPresenterImpl.this.a.p();
|
||||
} else if (i == 0 && boardInfo != null) {
|
||||
Cache.getInstance().setBoardInfo(boardInfo);
|
||||
}
|
||||
if (boardInfo == null) {
|
||||
return;
|
||||
}
|
||||
ArrayList<Component> a = modelMatchModel.a();
|
||||
ComponentListPresenterImpl.this.d(a);
|
||||
ComponentListPresenterImpl.this.a.a(a, boardInfo);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ComponentListContract$Presenter
|
||||
public boolean d(BoardInfo boardInfo) {
|
||||
boolean z;
|
||||
ComponentListContract$View componentListContract$View;
|
||||
List<Firmware> a = UpdateModelImp.b().a(UpdateModelImp.b().a(boardInfo));
|
||||
if (a != null && a.size() != 0) {
|
||||
for (Firmware firmware : a) {
|
||||
if (TextUtils.isEmpty(firmware.b()) || !new File(firmware.b()).exists() || !FileHelper.a(firmware.a(), firmware.b())) {
|
||||
z = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
z = false;
|
||||
if (z) {
|
||||
a(boardInfo, a);
|
||||
return false;
|
||||
}
|
||||
if (this.c.a(boardInfo, a, this) && (componentListContract$View = this.a) != null) {
|
||||
componentListContract$View.c(boardInfo);
|
||||
this.c.b(true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
this.a.l();
|
||||
return false;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public int b(Component component, Component component2) {
|
||||
if (!a(component) || a(component2)) {
|
||||
return (a(component) || !a(component2)) ? 0 : 1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ComponentListContract$Presenter
|
||||
public void a(final ResultCallback resultCallback) {
|
||||
this.b.execute(new Runnable() { // from class: com.ubt.jimu.connect.presenter.ComponentListPresenterImpl.2
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
try {
|
||||
if (ComponentListPresenterImpl.this.c.a(2, 1) == 0) {
|
||||
resultCallback.onSuccess();
|
||||
} else {
|
||||
resultCallback.a(-1, "Modify motor id fail!");
|
||||
}
|
||||
} catch (JimuException e) {
|
||||
resultCallback.a(e.getCode(), e.getMessage());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean a(String str) {
|
||||
return "dujiaoshou".equals(str);
|
||||
}
|
||||
|
||||
private int b(int i) {
|
||||
if (i == 1) {
|
||||
return PeripheralTypeProority.INFRARED.ordinal();
|
||||
}
|
||||
if (i == 2) {
|
||||
return PeripheralTypeProority.TOUCH.ordinal();
|
||||
}
|
||||
if (i == 3) {
|
||||
return PeripheralTypeProority.GYRO.ordinal();
|
||||
}
|
||||
if (i == 4) {
|
||||
return PeripheralTypeProority.LED.ordinal();
|
||||
}
|
||||
if (i == 6) {
|
||||
return PeripheralTypeProority.ULTRASOUND.ordinal();
|
||||
}
|
||||
if (i == 8) {
|
||||
return PeripheralTypeProority.SPEAKER.ordinal();
|
||||
}
|
||||
if (i == 10) {
|
||||
return PeripheralTypeProority.MOTOR.ordinal();
|
||||
}
|
||||
if (i == 14) {
|
||||
return PeripheralTypeProority.RGB_LED.ordinal();
|
||||
}
|
||||
if (i != 128) {
|
||||
return PeripheralTypeProority.DEFAULT_SENSOR.ordinal();
|
||||
}
|
||||
return PeripheralTypeProority.SERVO.ordinal();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ComponentListContract$Presenter
|
||||
public boolean a(String str, BoardInfo boardInfo, ArrayList<Component> arrayList) {
|
||||
BoardInfo.SensorBoardInfo sensorBoardInfo;
|
||||
List<Integer> b;
|
||||
if (!a(str) || boardInfo.h() == null || (sensorBoardInfo = boardInfo.h().get(10)) == null || (b = sensorBoardInfo.b()) == null || b.size() != 1 || b.get(0).intValue() != 2) {
|
||||
return false;
|
||||
}
|
||||
Iterator<Component> it = arrayList.iterator();
|
||||
while (it.hasNext()) {
|
||||
Component next = it.next();
|
||||
int i = AnonymousClass8.a[next.b().ordinal()];
|
||||
if (i == 1 || i == 2) {
|
||||
if (next.d() == 128) {
|
||||
return false;
|
||||
}
|
||||
} else if (i == 3 || i == 4) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public /* synthetic */ void c(List list) {
|
||||
int[] iArr = new int[list.size()];
|
||||
float[] fArr = new float[list.size()];
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
ServoAngleReadInfo servoAngleReadInfo = (ServoAngleReadInfo) list.get(i);
|
||||
iArr[i] = servoAngleReadInfo.b();
|
||||
fArr[i] = servoAngleReadInfo.c();
|
||||
}
|
||||
try {
|
||||
this.c.a(iArr, fArr, 400, 100);
|
||||
} catch (Exception e) {
|
||||
XLog.a("ComponentListPresenterImpl", "setServoAngle fail", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ComponentListContract$Presenter
|
||||
public void f() {
|
||||
this.c.a();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ComponentListContract$Presenter
|
||||
public boolean c(BoardInfo boardInfo) {
|
||||
return UpdateModelImp.b().c(boardInfo);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ComponentListContract$Presenter
|
||||
public void a(final BoardInfo boardInfo, final String str, final boolean z) {
|
||||
if (boardInfo == null) {
|
||||
XLog.d("ComponentListPresenterImpl", "Board is null, not update view", new Object[0]);
|
||||
return;
|
||||
}
|
||||
this.d = boardInfo;
|
||||
final ModelMatchModel modelMatchModel = new ModelMatchModel();
|
||||
this.b.execute(new Runnable() { // from class: com.ubt.jimu.connect.presenter.ComponentListPresenterImpl.3
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
ArrayList<Component> a = modelMatchModel.a(boardInfo, str, z);
|
||||
ComponentListPresenterImpl.this.a(a, boardInfo);
|
||||
ComponentListPresenterImpl.this.d(a);
|
||||
ComponentListPresenterImpl.this.a.a(a, boardInfo);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public int c(Component component, Component component2) {
|
||||
if (component.d() == component2.d()) {
|
||||
if (component.c() > component2.c()) {
|
||||
return 1;
|
||||
}
|
||||
if (component.c() < component2.c()) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void d(List<Component> list) {
|
||||
Collections.sort(list, new Comparator<Component>() { // from class: com.ubt.jimu.connect.presenter.ComponentListPresenterImpl.7
|
||||
@Override // java.util.Comparator
|
||||
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
||||
public int compare(Component component, Component component2) {
|
||||
int a = ComponentListPresenterImpl.this.a(component, component2);
|
||||
if (a != 0) {
|
||||
return a;
|
||||
}
|
||||
int b = ComponentListPresenterImpl.this.b(component, component2);
|
||||
if (b != 0) {
|
||||
return b;
|
||||
}
|
||||
int d = ComponentListPresenterImpl.this.d(component, component2);
|
||||
return d == 0 ? ComponentListPresenterImpl.this.c(component, component2) : d;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public int d(Component component, Component component2) {
|
||||
int b = b(component.d());
|
||||
int b2 = b(component2.d());
|
||||
if (b < b2) {
|
||||
return -1;
|
||||
}
|
||||
return b > b2 ? 1 : 0;
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.jimu.robotapi.UpdateManager.UpdateProgressListener
|
||||
public void a(int i, int i2) {
|
||||
ComponentListContract$View componentListContract$View = this.a;
|
||||
if (componentListContract$View != null) {
|
||||
componentListContract$View.a(i, i2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.jimu.robotapi.UpdateManager.UpdateProgressListener
|
||||
public void a(int i, Object obj) {
|
||||
XLog.a("MainActivity", "onBlocklyComplete:" + i);
|
||||
if ((113 == i || 112 == i || 128 == i) && obj != null && (obj instanceof BoardInfo)) {
|
||||
this.d = (BoardInfo) obj;
|
||||
Cache.getInstance().setBoardInfo(this.d);
|
||||
}
|
||||
ComponentListContract$View componentListContract$View = this.a;
|
||||
if (componentListContract$View != null) {
|
||||
componentListContract$View.b(i);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.jimu.robotapi.UpdateManager.UpdateProgressListener
|
||||
public void a(UpdateManager.UpdateException updateException) {
|
||||
this.c.b(false);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("onUpdateFailed: ");
|
||||
sb.append(updateException == null ? "" : updateException.getMessage());
|
||||
sb.append(" mView is null?");
|
||||
sb.append(this.a == null);
|
||||
XLog.a("MainActivity", sb.toString());
|
||||
if (this.a != null) {
|
||||
UpdateModelImp b = UpdateModelImp.b();
|
||||
this.a.a(updateException, b.a(b.a(this.d)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.jimu.robotapi.UpdateManager.UpdateProgressListener
|
||||
public void a(int i) {
|
||||
this.c.b(false);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("onCancelUpdate: mView is null?");
|
||||
sb.append(this.a == null);
|
||||
XLog.a("MainActivity", sb.toString());
|
||||
ComponentListContract$View componentListContract$View = this.a;
|
||||
if (componentListContract$View != null) {
|
||||
componentListContract$View.a(i);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ComponentListContract$Presenter
|
||||
public void a(final List<ServoAngleReadInfo> list) {
|
||||
if (list == null || list.size() == 0) {
|
||||
return;
|
||||
}
|
||||
this.b.execute(new Runnable() { // from class: com.ubt.jimu.connect.presenter.a
|
||||
@Override // java.lang.Runnable
|
||||
public final void run() {
|
||||
ComponentListPresenterImpl.this.c(list);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void a(final BoardInfo boardInfo, final List<Firmware> list) {
|
||||
VersionRepository.b(JimuApplication.l(), new Downloader.IDownloadJimuRobotListener() { // from class: com.ubt.jimu.connect.presenter.ComponentListPresenterImpl.6
|
||||
@Override // com.ubt.jimu.base.download.Downloader.IDownloadJimuRobotListener
|
||||
public void onFailed() {
|
||||
ComponentListPresenterImpl.this.a.b(boardInfo);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.download.Downloader.IDownloadJimuRobotListener
|
||||
public void onPrepareStart() {
|
||||
if (ComponentListPresenterImpl.this.a != null) {
|
||||
ComponentListPresenterImpl.this.a.a(boardInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.download.Downloader.IDownloadJimuRobotListener
|
||||
public void onProgress(int i, int i2, int i3) {
|
||||
if (ComponentListPresenterImpl.this.a != null) {
|
||||
ComponentListPresenterImpl.this.a.a(i, i2, i3);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.download.Downloader.IDownloadJimuRobotListener
|
||||
public void onSuccess() {
|
||||
if (ComponentListPresenterImpl.this.a != null) {
|
||||
ComponentListPresenterImpl.this.a.d(boardInfo);
|
||||
}
|
||||
}
|
||||
}).compose(RxSchedulers.a()).subscribe(new Observer<List<FirmwareVersion>>() { // from class: com.ubt.jimu.connect.presenter.ComponentListPresenterImpl.5
|
||||
@Override // io.reactivex.Observer
|
||||
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
||||
public void onNext(List<FirmwareVersion> list2) {
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onComplete() {
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onError(Throwable th) {
|
||||
if (ComponentListPresenterImpl.this.a != null) {
|
||||
ComponentListPresenterImpl.this.a.b(boardInfo);
|
||||
ComponentListPresenterImpl.this.a.a(new UpdateManager.UpdateException(UpdateManager.UpdateException.ERR_CODE_NO_FIRMWARE, ""), list);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onSubscribe(Disposable disposable) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean a(Component component) {
|
||||
return (component.d() == 10 || component.d() == 128) ? (component.b() == ErrorType.NONE || component.b() == ErrorType.PROMPT || component.b() == ErrorType.NEED_UPDATE) ? false : true : component.b() == ErrorType.ID_DUPLICATION || component.b() == ErrorType.TOO_MANY;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ComponentListContract$Presenter
|
||||
public List<Firmware> a(BoardInfo boardInfo) {
|
||||
return UpdateModelImp.b().a(boardInfo);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void a(List<Component> list, BoardInfo boardInfo) {
|
||||
List<Firmware> a = UpdateModelImp.b().a(boardInfo);
|
||||
for (Component component : list) {
|
||||
Iterator<Firmware> it = a.iterator();
|
||||
while (it.hasNext()) {
|
||||
if (component.d() == it.next().c() && component.b() == ErrorType.NONE) {
|
||||
component.a(ErrorType.NEED_UPDATE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public int a(Component component, Component component2) {
|
||||
if (component.b() == ErrorType.NONE || component2.b() != ErrorType.NONE) {
|
||||
return (component.b() != ErrorType.NONE || component2.b() == ErrorType.NONE) ? 0 : 1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
596
sources/com/ubt/jimu/connect/presenter/ConnectPresenterImpl.java
Normal file
596
sources/com/ubt/jimu/connect/presenter/ConnectPresenterImpl.java
Normal file
@@ -0,0 +1,596 @@
|
||||
package com.ubt.jimu.connect.presenter;
|
||||
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.location.LocationManager;
|
||||
import android.os.Build;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import com.afunx.ble.blelitelib.utils.BleUtils;
|
||||
import com.tencent.bugly.BuglyStrategy;
|
||||
import com.ubt.jimu.JimuApplication;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.base.cache.Cache;
|
||||
import com.ubt.jimu.base.cache.SharePreferenceHelper;
|
||||
import com.ubt.jimu.base.entities.ActiveStat;
|
||||
import com.ubt.jimu.base.entities.ApiResult;
|
||||
import com.ubt.jimu.base.entities.User;
|
||||
import com.ubt.jimu.base.http.ApiClient;
|
||||
import com.ubt.jimu.base.http.ApiConstants;
|
||||
import com.ubt.jimu.base.http.service.PackageRobotService;
|
||||
import com.ubt.jimu.connect.contract.ConnectContract$Presenter;
|
||||
import com.ubt.jimu.connect.contract.ConnectContract$View;
|
||||
import com.ubt.jimu.connect.model.MatchResultCallback;
|
||||
import com.ubt.jimu.connect.model.ModelMatchModel;
|
||||
import com.ubt.jimu.connect.model.ReadAllServoModel;
|
||||
import com.ubt.jimu.connect.model.UpdateModelImp;
|
||||
import com.ubt.jimu.unity.bluetooth.UnityActivity;
|
||||
import com.ubt.jimu.utils.RxSchedulers;
|
||||
import com.ubtech.permission.JimuPermissionRequest;
|
||||
import com.ubtech.permission.PermissionRequestListener;
|
||||
import com.ubtech.utils.XLog;
|
||||
import com.ubtech.view.dialog.SimpleDialog;
|
||||
import com.ubtrobot.jimu.bluetooth.Cancellable;
|
||||
import com.ubtrobot.jimu.bluetooth.ConnectCallback;
|
||||
import com.ubtrobot.jimu.bluetooth.base.discover.ScanResult;
|
||||
import com.ubtrobot.jimu.bluetooth.base.discover.ScannedHubEmitter;
|
||||
import com.ubtrobot.jimu.connection.RequestException;
|
||||
import com.ubtrobot.jimu.robotapi.BoardInfo;
|
||||
import com.ubtrobot.jimu.robotapi.JimuException;
|
||||
import com.ubtrobot.jimu.robotapi.JimuManager;
|
||||
import com.ubtrobot.jimu.robotapi.JimuScanner;
|
||||
import com.ubtrobot.jimu.robotapi.ServoAngleReadInfo;
|
||||
import com.ubtrobot.log.ALog;
|
||||
import com.ubtrobot.ubtlib.analytics.JimuAnalytics;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ConnectPresenterImpl implements ConnectContract$Presenter {
|
||||
private ConnectContract$View a;
|
||||
private JimuScanner b;
|
||||
private Cancellable c;
|
||||
private JimuManager d;
|
||||
private Context e;
|
||||
private SharePreferenceHelper f;
|
||||
private volatile boolean g;
|
||||
private String i;
|
||||
private int j;
|
||||
private volatile int h = -1;
|
||||
private boolean k = false;
|
||||
private BluetoothDevice l = null;
|
||||
private ExecutorService m = Executors.newSingleThreadExecutor();
|
||||
private ScannedHubEmitter n = new ScannedHubEmitter() { // from class: com.ubt.jimu.connect.presenter.ConnectPresenterImpl.8
|
||||
@Override // com.ubtrobot.jimu.bluetooth.base.discover.ScannedHubEmitter
|
||||
public void a(ScanResult scanResult) {
|
||||
if (ConnectPresenterImpl.this.h != 0) {
|
||||
Log.w("ConnectPresenterImpl", "searched a robot not in scan state");
|
||||
} else {
|
||||
ConnectPresenterImpl.this.a.a(scanResult);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.jimu.bluetooth.base.discover.ScannedHubEmitter
|
||||
public void a(int i, String str) {
|
||||
ALog.a("ConnectPresenterImpl").d("scaned onFail:" + i + " " + str);
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.jimu.bluetooth.base.discover.ScannedHubEmitter
|
||||
public void a() {
|
||||
ALog.a("ConnectPresenterImpl").d("Scan timeout");
|
||||
}
|
||||
};
|
||||
|
||||
public ConnectPresenterImpl(Context context, ConnectContract$View connectContract$View) {
|
||||
this.g = true;
|
||||
this.a = connectContract$View;
|
||||
this.a.a(this);
|
||||
this.e = context;
|
||||
this.b = new JimuScanner(context);
|
||||
this.d = JimuApplication.l().f();
|
||||
this.f = new SharePreferenceHelper();
|
||||
this.g = this.f.getBoolean(SharePreferenceHelper.SP_KEY_AUTO_CONNECT, true).booleanValue();
|
||||
ALog.a("ConnectPresenterImpl").d("mIsAutoConnect:" + this.g);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$Presenter
|
||||
public void k() {
|
||||
if (c()) {
|
||||
p();
|
||||
} else {
|
||||
new SimpleDialog.Builder(this.e).b(R.string.app_need_bluetooth_function).a(R.string.deny, true).a(new DialogInterface.OnClickListener(this) { // from class: com.ubt.jimu.connect.presenter.ConnectPresenterImpl.10
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
dialogInterface.dismiss();
|
||||
}
|
||||
}).d(R.string.allow).b(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.connect.presenter.ConnectPresenterImpl.9
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
ConnectPresenterImpl.this.a.R();
|
||||
dialogInterface.dismiss();
|
||||
}
|
||||
}).a().show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$Presenter
|
||||
public BluetoothDevice l() {
|
||||
return this.l;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$Presenter
|
||||
public int m() {
|
||||
return this.h;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$Presenter
|
||||
public void p() {
|
||||
JimuPermissionRequest.b(this.e, new PermissionRequestListener() { // from class: com.ubt.jimu.connect.presenter.ConnectPresenterImpl.7
|
||||
@Override // com.ubtech.permission.PermissionRequestListener
|
||||
public void onDenied() {
|
||||
Log.w("ConnectPresenterImpl", "User denied the location permission request");
|
||||
}
|
||||
|
||||
@Override // com.ubtech.permission.PermissionRequestListener
|
||||
public void onGranted() {
|
||||
if (ConnectPresenterImpl.this.e()) {
|
||||
ConnectPresenterImpl.this.a.z();
|
||||
} else {
|
||||
ConnectPresenterImpl.this.b();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$Presenter
|
||||
public void q() {
|
||||
Cancellable cancellable = this.c;
|
||||
if (cancellable != null) {
|
||||
cancellable.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$Presenter
|
||||
public void r() {
|
||||
a(false, (String) null, (String) null);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public boolean e() {
|
||||
return Build.VERSION.SDK_INT >= 29 && !a(this.e);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void f() {
|
||||
this.m.execute(new Runnable() { // from class: com.ubt.jimu.connect.presenter.ConnectPresenterImpl.2
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
final ModelMatchModel modelMatchModel = new ModelMatchModel();
|
||||
modelMatchModel.a(ConnectPresenterImpl.this.i, ConnectPresenterImpl.this.k, new MatchResultCallback() { // from class: com.ubt.jimu.connect.presenter.ConnectPresenterImpl.2.1
|
||||
@Override // com.ubt.jimu.connect.model.MatchResultCallback
|
||||
public void a(int i, BoardInfo boardInfo) {
|
||||
if (i == -4 || i == -3) {
|
||||
Cache.getInstance().setBoardInfo(boardInfo);
|
||||
ConnectPresenterImpl.this.a.a(ConnectPresenterImpl.this.i, ConnectPresenterImpl.this.k);
|
||||
return;
|
||||
}
|
||||
if (i == -2 || i == -1) {
|
||||
if (ConnectPresenterImpl.this.h != 2) {
|
||||
ALog.a("ConnectPresenterImpl").d("match fail!but not on STATE_CONNECTED, so not show fail view");
|
||||
return;
|
||||
}
|
||||
ConnectPresenterImpl.this.a();
|
||||
ALog.a("ConnectPresenterImpl").e("Device is not jimu or read code fail! Disconnect and update page to connect fail!", new Object[0]);
|
||||
ConnectPresenterImpl.this.a.b0();
|
||||
ConnectPresenterImpl.this.r();
|
||||
return;
|
||||
}
|
||||
if (i != 0) {
|
||||
Log.e("ConnectPresenterImpl", "Invalid match result!");
|
||||
return;
|
||||
}
|
||||
Cache.getInstance().setBoardInfo(boardInfo);
|
||||
if (ModelMatchModel.a(ConnectPresenterImpl.this.k, ConnectPresenterImpl.this.i)) {
|
||||
ConnectPresenterImpl.this.a.a(ConnectPresenterImpl.this.i, ConnectPresenterImpl.this.k);
|
||||
return;
|
||||
}
|
||||
UpdateModelImp b = UpdateModelImp.b();
|
||||
if (!b.c(boardInfo)) {
|
||||
ConnectPresenterImpl.this.a(modelMatchModel, boardInfo);
|
||||
} else if (b.d(boardInfo) || b.b(boardInfo)) {
|
||||
ConnectPresenterImpl.this.a.a(ConnectPresenterImpl.this.i, ConnectPresenterImpl.this.k);
|
||||
} else {
|
||||
ConnectPresenterImpl.this.a(modelMatchModel, boardInfo);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void h() {
|
||||
this.m.execute(new Runnable() { // from class: com.ubt.jimu.connect.presenter.ConnectPresenterImpl.4
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
ModelMatchModel modelMatchModel = new ModelMatchModel();
|
||||
try {
|
||||
if (!ConnectPresenterImpl.this.d.h()) {
|
||||
ConnectPresenterImpl.this.d.c();
|
||||
Log.e("ConnectPresenterImpl", "connect device is not JIMU");
|
||||
ConnectPresenterImpl.this.a.b0();
|
||||
return;
|
||||
}
|
||||
ConnectPresenterImpl.this.d.n();
|
||||
try {
|
||||
Thread.sleep(2000L);
|
||||
} catch (InterruptedException unused) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
BoardInfo b = modelMatchModel.b();
|
||||
Cache.getInstance().setBoardInfo(b);
|
||||
if (b.l()) {
|
||||
ConnectPresenterImpl.this.a();
|
||||
ConnectPresenterImpl.this.a.O();
|
||||
return;
|
||||
}
|
||||
int b2 = ConnectPresenterImpl.this.b(b);
|
||||
if (b2 == 0) {
|
||||
ConnectPresenterImpl.this.a();
|
||||
ConnectPresenterImpl.this.a.G();
|
||||
return;
|
||||
}
|
||||
if (b2 > 1) {
|
||||
ConnectPresenterImpl.this.a();
|
||||
ConnectPresenterImpl.this.a.O();
|
||||
return;
|
||||
}
|
||||
for (Map.Entry<Integer, BoardInfo.SensorBoardInfo> entry : b.h().entrySet()) {
|
||||
if (entry.getValue().b() != null && entry.getValue().b().size() != 0 && (entry.getKey().intValue() == 14 || entry.getKey().intValue() == 8)) {
|
||||
ConnectPresenterImpl.this.a();
|
||||
ConnectPresenterImpl.this.a.Y();
|
||||
return;
|
||||
}
|
||||
}
|
||||
ConnectPresenterImpl.this.a.c(-1);
|
||||
} catch (JimuException e) {
|
||||
Log.e("ConnectPresenterImpl", "Read board info fail!", e);
|
||||
ConnectPresenterImpl.this.a.b0();
|
||||
} catch (RequestException e2) {
|
||||
Log.e("ConnectPresenterImpl", "Read board info fail!", e2);
|
||||
ConnectPresenterImpl.this.a.b0();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$Presenter
|
||||
public void b(String str) {
|
||||
ALog.a("ConnectPresenterImpl").d("setModelId:" + str);
|
||||
this.i = str;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$Presenter
|
||||
public void c(String str, String str2) {
|
||||
SharePreferenceHelper sharePreferenceHelper = new SharePreferenceHelper();
|
||||
if (str != null) {
|
||||
ALog.a("ConnectPresenterImpl").d("save connect success model. model:" + str2 + " mac:" + str);
|
||||
sharePreferenceHelper.put(str2, str);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$Presenter
|
||||
public boolean d() {
|
||||
return this.d.g();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$Presenter
|
||||
public boolean g() {
|
||||
return this.g;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$Presenter
|
||||
public void b(boolean z) {
|
||||
this.g = z;
|
||||
ALog.a("ConnectPresenterImpl").d("mIsAutoConnect:" + this.g);
|
||||
}
|
||||
|
||||
private boolean c() {
|
||||
return BleUtils.isBluetoothEnabled();
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public int b(BoardInfo boardInfo) {
|
||||
int size = boardInfo.i() != null ? 0 + boardInfo.i().size() : 0;
|
||||
for (Map.Entry<Integer, BoardInfo.SensorBoardInfo> entry : boardInfo.h().entrySet()) {
|
||||
if (entry.getValue().b() != null) {
|
||||
size += entry.getValue().b().size();
|
||||
}
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$Presenter
|
||||
public void a(boolean z) {
|
||||
this.k = z;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$Presenter
|
||||
public void a(int i) {
|
||||
this.j = i;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$Presenter
|
||||
public void a(final BluetoothDevice bluetoothDevice) {
|
||||
ALog.a("ConnectPresenterImpl").d("mBluetoothState:" + this.h);
|
||||
this.h = 1;
|
||||
q();
|
||||
if (!c()) {
|
||||
this.h = 3;
|
||||
this.l = null;
|
||||
this.a.b0();
|
||||
r();
|
||||
return;
|
||||
}
|
||||
this.a.i();
|
||||
this.d.a(bluetoothDevice.getAddress(), new ConnectCallback() { // from class: com.ubt.jimu.connect.presenter.ConnectPresenterImpl.1
|
||||
@Override // com.ubtrobot.jimu.bluetooth.ConnectCallback
|
||||
public void a(int i, String str) {
|
||||
ALog.a("ConnectPresenterImpl").d("connect fail! fail msg:" + i + " " + str);
|
||||
if (ConnectPresenterImpl.this.h != 1) {
|
||||
ALog.a("ConnectPresenterImpl").d("connect fail!but not on STATE_CONNECTING, so not show fail view");
|
||||
return;
|
||||
}
|
||||
ConnectPresenterImpl.this.h = 3;
|
||||
ConnectPresenterImpl.this.l = null;
|
||||
ConnectPresenterImpl.this.a.b0();
|
||||
ConnectPresenterImpl.this.r();
|
||||
}
|
||||
|
||||
@Override // com.ubtrobot.jimu.bluetooth.ConnectCallback
|
||||
public void onSuccess() {
|
||||
ALog.a("ConnectPresenterImpl").d("connect successful!");
|
||||
if (ConnectPresenterImpl.this.h != 1) {
|
||||
ALog.a("ConnectPresenterImpl").d("connect successful, but not on STATE_CONNECTING, so not show successful view, and disconnect");
|
||||
ConnectPresenterImpl.this.a();
|
||||
return;
|
||||
}
|
||||
ConnectPresenterImpl.this.h = 2;
|
||||
ConnectPresenterImpl.this.l = bluetoothDevice;
|
||||
Cache.getInstance().setLastConnectedDevice(bluetoothDevice);
|
||||
ConnectPresenterImpl.this.a.J();
|
||||
if (ConnectPresenterImpl.this.j != 1) {
|
||||
ConnectPresenterImpl.this.f();
|
||||
} else {
|
||||
ALog.a("ConnectPresenterImpl").d("Modify Id");
|
||||
ConnectPresenterImpl.this.h();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void b() {
|
||||
ALog.a("ConnectPresenterImpl").d("start scan");
|
||||
this.h = 0;
|
||||
this.d.c();
|
||||
q();
|
||||
this.a.U();
|
||||
this.c = this.b.a(this.n, BuglyStrategy.a.MAX_USERDATA_VALUE_LENGTH);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void a(ModelMatchModel modelMatchModel, BoardInfo boardInfo) {
|
||||
modelMatchModel.b(boardInfo, this.i, this.k);
|
||||
BluetoothDevice bluetoothDevice = this.l;
|
||||
if (bluetoothDevice != null && bluetoothDevice.getAddress() != null) {
|
||||
c(this.l.getAddress(), this.i);
|
||||
}
|
||||
a(this.e, boardInfo, this.i, this.k);
|
||||
List<ServoAngleReadInfo> a = new ReadAllServoModel(this.d).a(this.i, this.k);
|
||||
if (a != null && a.size() != 0) {
|
||||
this.a.a(a);
|
||||
} else {
|
||||
this.a.c(-1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$Presenter
|
||||
public void a(final List<ServoAngleReadInfo> list) {
|
||||
this.m.execute(new Runnable() { // from class: com.ubt.jimu.connect.presenter.ConnectPresenterImpl.3
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
new ReadAllServoModel(ConnectPresenterImpl.this.d).a(list);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$Presenter
|
||||
public void a() {
|
||||
ALog.a("ConnectPresenterImpl").d("disconnect");
|
||||
this.h = 3;
|
||||
this.d.c();
|
||||
this.l = null;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$Presenter
|
||||
public void a(final Context context, final BoardInfo boardInfo, final String str, final boolean z) {
|
||||
this.m.execute(new Runnable() { // from class: com.ubt.jimu.connect.presenter.ConnectPresenterImpl.5
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
String address;
|
||||
JimuManager f = JimuApplication.l().f();
|
||||
f.c(str);
|
||||
ConnectPresenterImpl.this.a(boardInfo);
|
||||
try {
|
||||
String j = f.j();
|
||||
String m = f.m();
|
||||
ConnectPresenterImpl.this.a(context, j, m);
|
||||
ConnectPresenterImpl.this.a(true, j, boardInfo.d());
|
||||
int i = z ? 2 : 1;
|
||||
BluetoothDevice l = ConnectPresenterImpl.this.l();
|
||||
if (l == null) {
|
||||
Log.e("ConnectPresenterImpl", "Connected device is null");
|
||||
address = "";
|
||||
} else {
|
||||
address = l.getAddress();
|
||||
}
|
||||
ConnectPresenterImpl.this.a(str, i, m, j, address);
|
||||
} catch (JimuException e) {
|
||||
XLog.a("ConnectPresenterImpl", "Read McuId or SN fail!", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void a(Context context, String str, final String str2) {
|
||||
XLog.a("ConnectPresenterImpl", "recordActivationRobot mcuId:%s sn:%s", str, str2);
|
||||
PackageRobotService packageRobotService = (PackageRobotService) ApiClient.getService(PackageRobotService.class);
|
||||
Map<String, String> basicParams = ApiConstants.getBasicParams();
|
||||
basicParams.put("activeAreaCode", "");
|
||||
basicParams.put("equipmentUid", str);
|
||||
basicParams.put("activeArea", "");
|
||||
User user = Cache.getInstance().getUser();
|
||||
basicParams.put("userId", user != null ? String.valueOf(user.getUserId()) : "");
|
||||
basicParams.put("serialNumber", str2);
|
||||
packageRobotService.activeRobot(basicParams).compose(RxSchedulers.a()).subscribe(new Observer<ApiResult<ActiveStat>>(this) { // from class: com.ubt.jimu.connect.presenter.ConnectPresenterImpl.6
|
||||
private int a;
|
||||
private int b;
|
||||
private String c;
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
||||
public void onNext(ApiResult<ActiveStat> apiResult) {
|
||||
List<ActiveStat> models = apiResult.getModels();
|
||||
if (models == null || models.size() <= 0) {
|
||||
this.c = str2;
|
||||
} else {
|
||||
this.c = models.get(0).serialNumber;
|
||||
}
|
||||
if ("2001".equals(apiResult.getInfo())) {
|
||||
this.a = 2001;
|
||||
this.b = 0;
|
||||
} else if ("2002".equals(apiResult.getInfo())) {
|
||||
this.a = 2002;
|
||||
this.b = 0;
|
||||
} else if ("0000".equals(apiResult.getInfo())) {
|
||||
this.a = 0;
|
||||
this.b = 1;
|
||||
} else {
|
||||
this.a = 3000;
|
||||
this.b = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onComplete() {
|
||||
JSONObject jSONObject = new JSONObject();
|
||||
JSONObject jSONObject2 = new JSONObject();
|
||||
try {
|
||||
jSONObject.put("funcName", "RegisterRobotResult");
|
||||
jSONObject2.put("reason", this.a);
|
||||
jSONObject2.put("isSuccess", this.b);
|
||||
jSONObject2.put("sn", this.c);
|
||||
jSONObject.put("arg", jSONObject2);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
XLog.a("ConnectPresenterImpl", "active result %s", jSONObject);
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onError(Throwable th) {
|
||||
th.printStackTrace();
|
||||
this.a = 3000;
|
||||
this.b = 0;
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onSubscribe(Disposable disposable) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void a(boolean z, String str, String str2) {
|
||||
XLog.a("ConnectPresenterImpl", "recordConnectResult isConnectSuccess:%b mcuId:%s controlboxVersion:%s", Boolean.valueOf(z), str, str2);
|
||||
if (str == null) {
|
||||
str = "";
|
||||
}
|
||||
if (str2 == null) {
|
||||
str2 = "";
|
||||
}
|
||||
HashMap hashMap = new HashMap();
|
||||
if (z) {
|
||||
hashMap.put("resultCode", "1-1");
|
||||
} else {
|
||||
hashMap.put("resultCode", "1-2");
|
||||
}
|
||||
hashMap.put("controlboxId", str);
|
||||
hashMap.put("contorlboxVersion", str2);
|
||||
JimuAnalytics.b().a("app_bluetooth_connect", hashMap);
|
||||
}
|
||||
|
||||
public void a(String str, int i, String str2, String str3, String str4) {
|
||||
if (str3 == null) {
|
||||
str3 = "";
|
||||
}
|
||||
if (str2 == null) {
|
||||
str2 = "";
|
||||
}
|
||||
if (str4 == null) {
|
||||
str4 = "";
|
||||
}
|
||||
HashMap hashMap = new HashMap();
|
||||
hashMap.put("modelId", str);
|
||||
hashMap.put(UnityActivity.pModelType, String.valueOf(i));
|
||||
hashMap.put("serialNumber", str2);
|
||||
hashMap.put("mcuId", str3);
|
||||
hashMap.put("bluetoothMac", str4);
|
||||
JimuAnalytics.b().a("app_model_connect", hashMap);
|
||||
}
|
||||
|
||||
public static boolean a(Context context) {
|
||||
LocationManager locationManager = (LocationManager) context.getApplicationContext().getSystemService("location");
|
||||
if (locationManager != null) {
|
||||
if (Build.VERSION.SDK_INT >= 28) {
|
||||
return locationManager.isLocationEnabled();
|
||||
}
|
||||
try {
|
||||
return Settings.Secure.getInt(context.getContentResolver(), "location_mode") != 0;
|
||||
} catch (Settings.SettingNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void a(BoardInfo boardInfo) {
|
||||
BoardInfo.SensorBoardInfo sensorBoardInfo;
|
||||
List<Integer> b;
|
||||
try {
|
||||
this.d.a(true);
|
||||
} catch (JimuException e) {
|
||||
XLog.a("ConnectPresenterImpl", "enable self check fail", e);
|
||||
}
|
||||
HashMap<Integer, BoardInfo.SensorBoardInfo> h = boardInfo.h();
|
||||
if (h == null || h.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
for (Integer num : h.keySet()) {
|
||||
if (10 != num.intValue() && (sensorBoardInfo = h.get(num)) != null && (b = sensorBoardInfo.b()) != null && b.size() != 0) {
|
||||
try {
|
||||
this.d.a(num.intValue(), b, true);
|
||||
} catch (JimuException e2) {
|
||||
Log.e("ConnectPresenterImpl", "enableSensor fail!", e2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
package com.ubt.jimu.connect.view;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.widgets.NavigationBarView;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class BtSpeakerConnectHelpActivity extends Activity {
|
||||
private NavigationBarView a;
|
||||
private TextView b;
|
||||
private String c;
|
||||
|
||||
@Override // android.app.Activity
|
||||
protected void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
setContentView(R.layout.activity_speaker_connect_help);
|
||||
Intent intent = getIntent();
|
||||
if (intent != null) {
|
||||
this.c = intent.getStringExtra("KEY_BT_SPEAKER_NAME");
|
||||
}
|
||||
this.a = (NavigationBarView) findViewById(R.id.nbv_bar);
|
||||
this.a.setTitle(R.string.how_to_connect_bt_speaker);
|
||||
this.a.setLeftIvSrc(R.drawable.community_cancel);
|
||||
this.a.setListener(new NavigationBarView.OnActionClickListener() { // from class: com.ubt.jimu.connect.view.BtSpeakerConnectHelpActivity.1
|
||||
public void a(View view) {
|
||||
BtSpeakerConnectHelpActivity.this.finish();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.NavigationBarView.OnActionClickListener
|
||||
public void onClick(View view) {
|
||||
if (view.getId() == R.id.iv_left) {
|
||||
a(view);
|
||||
}
|
||||
}
|
||||
});
|
||||
this.b = (TextView) findViewById(R.id.tv_tap_to_connect);
|
||||
String string = getString(R.string.tap_to_connect);
|
||||
if (!TextUtils.isEmpty(this.c)) {
|
||||
string = string.replace("{0}", this.c);
|
||||
}
|
||||
this.b.setText(string);
|
||||
}
|
||||
}
|
59
sources/com/ubt/jimu/connect/view/CircleImageView.java
Normal file
59
sources/com/ubt/jimu/connect/view/CircleImageView.java
Normal file
@@ -0,0 +1,59 @@
|
||||
package com.ubt.jimu.connect.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffXfermode;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import androidx.appcompat.widget.AppCompatImageView;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class CircleImageView extends AppCompatImageView {
|
||||
private Paint c;
|
||||
|
||||
public CircleImageView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
private Bitmap a(Bitmap bitmap, int i) {
|
||||
Bitmap createBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(createBitmap);
|
||||
Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
|
||||
this.c.setAntiAlias(true);
|
||||
canvas.drawARGB(0, 0, 0, 0);
|
||||
this.c.setColor(-12434878);
|
||||
float width = bitmap.getWidth() / 2;
|
||||
canvas.drawCircle(width, width, width, this.c);
|
||||
this.c.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
|
||||
canvas.drawBitmap(bitmap, rect, rect, this.c);
|
||||
return createBitmap;
|
||||
}
|
||||
|
||||
@Override // android.widget.ImageView, android.view.View
|
||||
protected void onDraw(Canvas canvas) {
|
||||
Drawable drawable = getDrawable();
|
||||
if (drawable == null) {
|
||||
super.onDraw(canvas);
|
||||
return;
|
||||
}
|
||||
Bitmap a = a(((BitmapDrawable) drawable).getBitmap(), 14);
|
||||
Rect rect = new Rect(0, 0, a.getWidth(), a.getHeight());
|
||||
Rect rect2 = new Rect(0, 0, getWidth(), getHeight());
|
||||
this.c.reset();
|
||||
canvas.drawBitmap(a, rect, rect2, this.c);
|
||||
}
|
||||
|
||||
public CircleImageView(Context context, AttributeSet attributeSet) {
|
||||
this(context, attributeSet, 0);
|
||||
}
|
||||
|
||||
public CircleImageView(Context context, AttributeSet attributeSet, int i) {
|
||||
super(context, attributeSet, i);
|
||||
this.c = new Paint();
|
||||
}
|
||||
}
|
104
sources/com/ubt/jimu/connect/view/CircleProgressBar.java
Normal file
104
sources/com/ubt/jimu/connect/view/CircleProgressBar.java
Normal file
@@ -0,0 +1,104 @@
|
||||
package com.ubt.jimu.connect.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.RectF;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import com.ubt.jimu.R$styleable;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class CircleProgressBar extends View {
|
||||
private Paint a;
|
||||
private Paint b;
|
||||
private Paint c;
|
||||
private Paint d;
|
||||
private int e;
|
||||
private int f;
|
||||
private int g;
|
||||
private float h;
|
||||
private float i;
|
||||
private float j;
|
||||
private int k;
|
||||
private int l;
|
||||
private int m;
|
||||
private int n;
|
||||
|
||||
public CircleProgressBar(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
this.m = 100;
|
||||
a(context, attributeSet);
|
||||
a();
|
||||
}
|
||||
|
||||
private void a(Context context, AttributeSet attributeSet) {
|
||||
TypedArray obtainStyledAttributes = context.getTheme().obtainStyledAttributes(attributeSet, R$styleable.TasksCompletedView, 0, 0);
|
||||
this.h = obtainStyledAttributes.getDimension(1, 80.0f);
|
||||
this.j = obtainStyledAttributes.getDimension(4, 10.0f);
|
||||
this.e = obtainStyledAttributes.getColor(0, -1);
|
||||
this.f = obtainStyledAttributes.getColor(3, -1);
|
||||
this.g = obtainStyledAttributes.getColor(2, -1);
|
||||
this.i = this.h + (this.j / 2.0f);
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
protected void onDraw(Canvas canvas) {
|
||||
this.k = getWidth() / 2;
|
||||
this.l = getHeight() / 2;
|
||||
canvas.drawCircle(this.k, this.l, this.h, this.a);
|
||||
RectF rectF = new RectF();
|
||||
int i = this.k;
|
||||
float f = this.i;
|
||||
rectF.left = i - f;
|
||||
int i2 = this.l;
|
||||
rectF.top = i2 - f;
|
||||
rectF.right = (f * 2.0f) + (i - f);
|
||||
rectF.bottom = (f * 2.0f) + (i2 - f);
|
||||
canvas.drawArc(rectF, 0.0f, 360.0f, false, this.c);
|
||||
if (this.n > 0) {
|
||||
RectF rectF2 = new RectF();
|
||||
int i3 = this.k;
|
||||
float f2 = this.i;
|
||||
rectF2.left = i3 - f2;
|
||||
int i4 = this.l;
|
||||
rectF2.top = i4 - f2;
|
||||
rectF2.right = (f2 * 2.0f) + (i3 - f2);
|
||||
rectF2.bottom = (2.0f * f2) + (i4 - f2);
|
||||
canvas.drawArc(rectF2, -90.0f, (this.n / this.m) * (-1.0f) * 360.0f, false, this.b);
|
||||
}
|
||||
}
|
||||
|
||||
public void setProgress(int i) {
|
||||
if (i < 0) {
|
||||
i = 0;
|
||||
}
|
||||
this.n = i;
|
||||
postInvalidate();
|
||||
}
|
||||
|
||||
private void a() {
|
||||
this.a = new Paint();
|
||||
this.a.setAntiAlias(true);
|
||||
this.a.setColor(this.e);
|
||||
this.a.setStyle(Paint.Style.FILL);
|
||||
this.c = new Paint();
|
||||
this.c.setAntiAlias(true);
|
||||
this.c.setColor(this.g);
|
||||
this.c.setStyle(Paint.Style.STROKE);
|
||||
this.c.setStrokeWidth(this.j);
|
||||
this.b = new Paint();
|
||||
this.b.setAntiAlias(true);
|
||||
this.b.setColor(this.f);
|
||||
this.b.setStyle(Paint.Style.STROKE);
|
||||
this.b.setStrokeWidth(this.j);
|
||||
this.d = new Paint();
|
||||
this.d.setAntiAlias(true);
|
||||
this.d.setStyle(Paint.Style.FILL);
|
||||
this.d.setColor(this.f);
|
||||
this.d.setTextSize(this.h / 2.0f);
|
||||
Paint.FontMetrics fontMetrics = this.d.getFontMetrics();
|
||||
Math.ceil(fontMetrics.descent - fontMetrics.ascent);
|
||||
}
|
||||
}
|
222
sources/com/ubt/jimu/connect/view/ComponentInfoDialog.java
Normal file
222
sources/com/ubt/jimu/connect/view/ComponentInfoDialog.java
Normal file
@@ -0,0 +1,222 @@
|
||||
package com.ubt.jimu.connect.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.method.ScrollingMovementMethod;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubtech.utils.DisplayUtil;
|
||||
import com.ubtech.view.dialog.BaseDialog;
|
||||
import com.ubtech.view.widget.UButton;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ComponentInfoDialog extends BaseDialog implements View.OnClickListener {
|
||||
public CharSequence b;
|
||||
public String c;
|
||||
public String d;
|
||||
public boolean e;
|
||||
public int f;
|
||||
public int g;
|
||||
public int h;
|
||||
public DialogInterface.OnClickListener i;
|
||||
public DialogInterface.OnClickListener j;
|
||||
public View.OnClickListener k;
|
||||
private TextView l;
|
||||
private TextView m;
|
||||
private ImageView n;
|
||||
public UButton o;
|
||||
public UButton p;
|
||||
public UButton q;
|
||||
public UButton r;
|
||||
|
||||
public ComponentInfoDialog(Context context) {
|
||||
super(context);
|
||||
this.e = false;
|
||||
this.f = 0;
|
||||
this.g = -1;
|
||||
this.h = -1;
|
||||
}
|
||||
|
||||
public void a(View view, Builder builder) {
|
||||
this.l = (TextView) view.findViewById(R.id.tvDialogTitle);
|
||||
this.m = (TextView) view.findViewById(R.id.tvTips);
|
||||
this.n = (ImageView) view.findViewById(R.id.imgLogo);
|
||||
this.p = (UButton) view.findViewById(R.id.btn_gray_cancel);
|
||||
this.q = (UButton) view.findViewById(R.id.btn_blue_cancel);
|
||||
this.q.setOnClickListener(this);
|
||||
this.o = (UButton) view.findViewById(R.id.btn_ok);
|
||||
this.r = (UButton) view.findViewById(R.id.btn_gray_cancel);
|
||||
this.r.setOnClickListener(this);
|
||||
this.o.setOnClickListener(this);
|
||||
if (!TextUtils.isEmpty(this.b)) {
|
||||
this.m.setText(this.b);
|
||||
this.m.setMovementMethod(ScrollingMovementMethod.getInstance());
|
||||
}
|
||||
this.m.setOnClickListener(this);
|
||||
if (this.j == null) {
|
||||
this.o.setVisibility(8);
|
||||
}
|
||||
if (!TextUtils.isEmpty(this.d)) {
|
||||
this.o.setText(this.d);
|
||||
}
|
||||
if (TextUtils.isEmpty(builder.b)) {
|
||||
this.l.setVisibility(8);
|
||||
} else {
|
||||
this.l.setVisibility(0);
|
||||
this.l.setText(builder.b);
|
||||
}
|
||||
if (TextUtils.isEmpty(builder.g)) {
|
||||
int i = builder.f;
|
||||
if (i != 0) {
|
||||
this.n.setImageResource(i);
|
||||
this.n.setVisibility(0);
|
||||
} else {
|
||||
this.n.setVisibility(8);
|
||||
}
|
||||
} else {
|
||||
Glide.e(getContext()).a(builder.g).a(this.n);
|
||||
this.n.setVisibility(0);
|
||||
if (this.h > 0 && this.g > 0) {
|
||||
ViewGroup.LayoutParams layoutParams = this.n.getLayoutParams();
|
||||
layoutParams.height = this.h;
|
||||
layoutParams.width = this.g;
|
||||
this.n.setLayoutParams(layoutParams);
|
||||
}
|
||||
}
|
||||
int i2 = builder.j;
|
||||
if (17 != i2) {
|
||||
this.m.setGravity(i2);
|
||||
}
|
||||
if (this.e) {
|
||||
this.q.setVisibility(8);
|
||||
this.p.setVisibility(0);
|
||||
this.r = this.p;
|
||||
} else {
|
||||
this.q.setVisibility(0);
|
||||
this.p.setVisibility(8);
|
||||
this.r = this.q;
|
||||
}
|
||||
if (this.i == null) {
|
||||
this.p.setVisibility(8);
|
||||
this.q.setVisibility(8);
|
||||
}
|
||||
if (!TextUtils.isEmpty(this.c)) {
|
||||
this.r.setText(this.c);
|
||||
}
|
||||
this.m.setTextColor(this.f);
|
||||
}
|
||||
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view) {
|
||||
int id = view.getId();
|
||||
if (id == R.id.btn_gray_cancel || id == R.id.btn_blue_cancel) {
|
||||
DialogInterface.OnClickListener onClickListener = this.i;
|
||||
if (onClickListener != null) {
|
||||
onClickListener.onClick(this, 0);
|
||||
return;
|
||||
} else {
|
||||
dismiss();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (id == R.id.btn_ok) {
|
||||
DialogInterface.OnClickListener onClickListener2 = this.j;
|
||||
if (onClickListener2 != null) {
|
||||
onClickListener2.onClick(this, 0);
|
||||
return;
|
||||
} else {
|
||||
dismiss();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (id != R.id.tvTips) {
|
||||
dismiss();
|
||||
return;
|
||||
}
|
||||
View.OnClickListener onClickListener3 = this.k;
|
||||
if (onClickListener3 != null) {
|
||||
onClickListener3.onClick(this.m);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
protected Context a;
|
||||
protected String b;
|
||||
protected CharSequence c;
|
||||
protected String d;
|
||||
protected String e;
|
||||
protected String g;
|
||||
protected DialogInterface.OnClickListener k;
|
||||
protected DialogInterface.OnClickListener l;
|
||||
protected View.OnClickListener m;
|
||||
protected int o;
|
||||
protected int f = 0;
|
||||
protected boolean h = true;
|
||||
protected boolean i = true;
|
||||
protected int j = 17;
|
||||
protected boolean n = false;
|
||||
protected int p = -1;
|
||||
protected int q = -1;
|
||||
|
||||
public Builder(Context context) {
|
||||
this.o = 0;
|
||||
this.a = context;
|
||||
this.o = context.getResources().getColor(R.color.comm_bg_596F80);
|
||||
}
|
||||
|
||||
public ComponentInfoDialog a() {
|
||||
ComponentInfoDialog componentInfoDialog = new ComponentInfoDialog(this.a);
|
||||
componentInfoDialog.requestWindowFeature(1);
|
||||
componentInfoDialog.getWindow().setBackgroundDrawable(new ColorDrawable(0));
|
||||
componentInfoDialog.e = this.n;
|
||||
componentInfoDialog.b = this.c;
|
||||
componentInfoDialog.d = this.e;
|
||||
componentInfoDialog.c = this.d;
|
||||
componentInfoDialog.j = this.l;
|
||||
componentInfoDialog.i = this.k;
|
||||
componentInfoDialog.k = this.m;
|
||||
componentInfoDialog.f = this.o;
|
||||
componentInfoDialog.h = this.q;
|
||||
componentInfoDialog.g = this.p;
|
||||
View inflate = LayoutInflater.from(this.a).inflate(R.layout.layout_component_info_dialog, (ViewGroup) null, false);
|
||||
componentInfoDialog.a(inflate, this);
|
||||
componentInfoDialog.setContentView(inflate);
|
||||
componentInfoDialog.setCanceledOnTouchOutside(this.h);
|
||||
componentInfoDialog.setCancelable(this.i);
|
||||
Window window = componentInfoDialog.getWindow();
|
||||
WindowManager.LayoutParams attributes = window.getAttributes();
|
||||
window.setBackgroundDrawableResource(R.color.comm_transparent);
|
||||
int a = DisplayUtil.a(this.a, R.dimen.component_info_dialog_width);
|
||||
int a2 = DisplayUtil.a(this.a, R.dimen.component_info_dialog_height);
|
||||
attributes.width = a;
|
||||
attributes.height = a2;
|
||||
attributes.gravity = 17;
|
||||
window.setAttributes(attributes);
|
||||
return componentInfoDialog;
|
||||
}
|
||||
|
||||
public Builder a(String str) {
|
||||
this.b = str;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder a(CharSequence charSequence) {
|
||||
this.c = charSequence;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder a(boolean z) {
|
||||
this.h = z;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
1257
sources/com/ubt/jimu/connect/view/ComponentsListActivity.java
Normal file
1257
sources/com/ubt/jimu/connect/view/ComponentsListActivity.java
Normal file
File diff suppressed because it is too large
Load Diff
948
sources/com/ubt/jimu/connect/view/ConnectFragment.java
Normal file
948
sources/com/ubt/jimu/connect/view/ConnectFragment.java
Normal file
@@ -0,0 +1,948 @@
|
||||
package com.ubt.jimu.connect.view;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.TextUtils;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.OvershootInterpolator;
|
||||
import android.view.animation.TranslateAnimation;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.RequestBuilder;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.base.HelpActivity;
|
||||
import com.ubt.jimu.base.cache.Cache;
|
||||
import com.ubt.jimu.base.cache.SharePreferenceHelper;
|
||||
import com.ubt.jimu.base.dialog.UpdateDialog;
|
||||
import com.ubt.jimu.blockly.exception.JimuConnectionException;
|
||||
import com.ubt.jimu.connect.ConnectActivity;
|
||||
import com.ubt.jimu.connect.contract.ConnectContract$Presenter;
|
||||
import com.ubt.jimu.connect.contract.ConnectContract$View;
|
||||
import com.ubt.jimu.widgets.NavigationBarView;
|
||||
import com.ubtech.utils.DisplayUtil;
|
||||
import com.ubtech.utils.XLog;
|
||||
import com.ubtech.view.dialog.SimpleDialog;
|
||||
import com.ubtech.view.fragment.BaseFragment;
|
||||
import com.ubtrobot.jimu.bluetooth.base.discover.ScanResult;
|
||||
import com.ubtrobot.jimu.robotapi.ServoAngleReadInfo;
|
||||
import com.ubtrobot.log.ALog;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ConnectFragment extends BaseFragment implements ConnectContract$View {
|
||||
private Dialog A;
|
||||
private boolean B;
|
||||
private WaveView a;
|
||||
private NavigationBarView b;
|
||||
private ImageView c;
|
||||
private ImageView d;
|
||||
private ProgressBar e;
|
||||
private RelativeLayout f;
|
||||
private CircleProgressBar g;
|
||||
private Button i;
|
||||
private ListView j;
|
||||
private RobotsScanedAdapter k;
|
||||
private FrameLayout l;
|
||||
private Dialog m;
|
||||
private ExecutorService n;
|
||||
private ConnectContract$Presenter p;
|
||||
private String r;
|
||||
private int s;
|
||||
private String t;
|
||||
private Handler u;
|
||||
private SharePreferenceHelper x;
|
||||
private int h = -10;
|
||||
private List<ScanResult> o = new ArrayList();
|
||||
private boolean q = false;
|
||||
private Runnable v = new Runnable() { // from class: com.ubt.jimu.connect.view.ConnectFragment.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
ALog.a("ConnectFragment").d("scan timeout. ListRobot.isEmpty:" + ConnectFragment.this.o.isEmpty());
|
||||
if (ConnectFragment.this.o.isEmpty()) {
|
||||
ConnectFragment.this.x();
|
||||
} else {
|
||||
ConnectFragment.this.q();
|
||||
}
|
||||
}
|
||||
};
|
||||
private volatile boolean y = false;
|
||||
private Runnable z = new Runnable() { // from class: com.ubt.jimu.connect.view.ConnectFragment.7
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
ConnectFragment.this.y = true;
|
||||
if (ConnectFragment.this.isAdded() && !ConnectFragment.this.o.isEmpty()) {
|
||||
ConnectFragment connectFragment = ConnectFragment.this;
|
||||
if (connectFragment.j((List<ScanResult>) connectFragment.o)) {
|
||||
return;
|
||||
}
|
||||
ConnectFragment.this.A();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class ProgressRunable implements Runnable {
|
||||
ProgressRunable() {
|
||||
}
|
||||
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
while (ConnectFragment.this.h < 75 && ConnectFragment.this.h >= 0) {
|
||||
ConnectFragment.this.h++;
|
||||
ConnectFragment.this.g.setProgress(ConnectFragment.this.h);
|
||||
try {
|
||||
Thread.sleep(100L);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class RobotsScanedAdapter extends ArrayAdapter {
|
||||
private final int a;
|
||||
|
||||
public RobotsScanedAdapter(Context context, int i, List<ScanResult> list) {
|
||||
super(context, i, list);
|
||||
this.a = i;
|
||||
}
|
||||
|
||||
@Override // android.widget.ArrayAdapter, android.widget.Adapter
|
||||
public View getView(int i, View view, ViewGroup viewGroup) {
|
||||
ScanResult scanResult = (ScanResult) getItem(i);
|
||||
View inflate = LayoutInflater.from(getContext()).inflate(this.a, (ViewGroup) null);
|
||||
ImageView imageView = (ImageView) inflate.findViewById(R.id.iv_robot_rssi);
|
||||
TextView textView = (TextView) inflate.findViewById(R.id.tv_robot_name);
|
||||
if (scanResult != null && scanResult.a() != null) {
|
||||
String name = scanResult.a().getName();
|
||||
if (TextUtils.isEmpty(name)) {
|
||||
Log.e("ConnectFragment", "Device name is empty! show empty. deviceName:" + name);
|
||||
} else {
|
||||
Log.i("ConnectFragment", "DeviceName:" + name);
|
||||
int i2 = 0;
|
||||
if (name.toLowerCase().startsWith("My_Jimu_".toLowerCase())) {
|
||||
i2 = 8;
|
||||
} else if (name.toLowerCase().startsWith("Jimu_".toLowerCase())) {
|
||||
i2 = 5;
|
||||
}
|
||||
if (i2 != 0) {
|
||||
ForegroundColorSpan foregroundColorSpan = new ForegroundColorSpan(ConnectFragment.this.getResources().getColor(R.color.color_txt_red));
|
||||
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(name);
|
||||
spannableStringBuilder.setSpan(foregroundColorSpan, i2, name.length(), 18);
|
||||
textView.setText(spannableStringBuilder);
|
||||
} else {
|
||||
textView.setText(name);
|
||||
}
|
||||
}
|
||||
imageView.setImageResource(ConnectFragment.this.e(scanResult.b()));
|
||||
}
|
||||
return inflate;
|
||||
}
|
||||
}
|
||||
|
||||
class SortByRssi implements Comparator {
|
||||
SortByRssi(ConnectFragment connectFragment) {
|
||||
}
|
||||
|
||||
@Override // java.util.Comparator
|
||||
public int compare(Object obj, Object obj2) {
|
||||
return ((ScanResult) obj).b() < ((ScanResult) obj2).b() ? 1 : -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void A() {
|
||||
if (getActivity() == null) {
|
||||
return;
|
||||
}
|
||||
getActivity().runOnUiThread(new Runnable() { // from class: com.ubt.jimu.connect.view.ConnectFragment.8
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
if (ConnectFragment.this.p.m() != 0) {
|
||||
Log.i("ConnectFragment", "Bluetooth not in scan state, not show robot scaned view");
|
||||
return;
|
||||
}
|
||||
ConnectFragment.this.a.c();
|
||||
ConnectFragment.this.a.setVisibility(8);
|
||||
ConnectFragment.this.c.setVisibility(8);
|
||||
if (ConnectFragment.this.j.getVisibility() != 0) {
|
||||
TranslateAnimation translateAnimation = new TranslateAnimation(0.0f, 0.0f, 0.0f, ConnectFragment.this.d.getMeasuredHeight());
|
||||
translateAnimation.setDuration(300L);
|
||||
ConnectFragment.this.d.startAnimation(translateAnimation);
|
||||
ConnectFragment.this.d.setVisibility(4);
|
||||
}
|
||||
ConnectFragment.this.e.setVisibility(0);
|
||||
ConnectFragment.this.l.setVisibility(8);
|
||||
ConnectFragment.this.f.setVisibility(8);
|
||||
ConnectFragment.this.b.setTitle(R.string.select_jimu_model);
|
||||
ConnectFragment.this.i.setVisibility(8);
|
||||
ConnectFragment.this.j.setVisibility(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public int e(int i) {
|
||||
return i < -90 ? R.mipmap.signal1 : i < -80 ? R.mipmap.signal2 : i < -70 ? R.mipmap.signal3 : R.mipmap.signal4;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void x() {
|
||||
ALog.a("ConnectFragment").d("gotoSearchFailPage");
|
||||
String valueOf = String.valueOf(JimuConnectionException.NOT_FOUND_DEVICE.getType());
|
||||
if (getActivity() == null) {
|
||||
return;
|
||||
}
|
||||
String url = JimuConnectionException.getUrl(valueOf);
|
||||
if (TextUtils.isEmpty(url)) {
|
||||
return;
|
||||
}
|
||||
HelpActivity.startForResultFromFragment(101, this, getActivity(), url, " ", R.color.theme_background, false);
|
||||
}
|
||||
|
||||
private void y() {
|
||||
ALog.a("ConnectFragment").d("onNotConnect");
|
||||
if (b()) {
|
||||
this.i.setVisibility(0);
|
||||
this.i.setText(R.string.click_to_scan);
|
||||
this.i.setOnClickListener(new View.OnClickListener() { // from class: com.ubt.jimu.connect.view.ConnectFragment.3
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view) {
|
||||
if (ConnectFragment.this.p == null) {
|
||||
Log.e("ConnectFragment", "Present is null");
|
||||
return;
|
||||
}
|
||||
if (ConnectFragment.this.p.d()) {
|
||||
Log.w("ConnectFragment", "Bluetooth connected, disconnect bluetooth.");
|
||||
ConnectFragment.this.p.a();
|
||||
}
|
||||
ConnectFragment.this.p.k();
|
||||
}
|
||||
});
|
||||
this.a.setVisibility(8);
|
||||
this.a.c();
|
||||
this.c.setVisibility(0);
|
||||
this.d.setVisibility(8);
|
||||
this.j.setVisibility(8);
|
||||
this.e.setVisibility(8);
|
||||
this.l.setVisibility(0);
|
||||
this.f.setVisibility(8);
|
||||
this.g.setVisibility(0);
|
||||
this.h = -10;
|
||||
this.g.setProgress(this.h);
|
||||
this.b.setTitle(R.string.search_jimu_roobot);
|
||||
this.b.setRightIvVisibility(4);
|
||||
this.b.setListener(new NavigationBarView.OnActionClickListener() { // from class: com.ubt.jimu.connect.view.ConnectFragment.4
|
||||
public void a(View view) {
|
||||
ConnectFragment.this.d(0);
|
||||
}
|
||||
|
||||
public void b(View view) {
|
||||
ConnectFragment.this.p.k();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.NavigationBarView.OnActionClickListener
|
||||
public void onClick(View view) {
|
||||
int id = view.getId();
|
||||
if (id == R.id.iv_left) {
|
||||
a(view);
|
||||
} else if (id == R.id.iv_right || id == R.id.tv_right) {
|
||||
b(view);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$View
|
||||
public void G() {
|
||||
ALog.a("ConnectFragment").d("onShowNotAnyPeripherals");
|
||||
if (b() && getActivity() != null) {
|
||||
getActivity().runOnUiThread(new Runnable() { // from class: com.ubt.jimu.connect.view.ConnectFragment.16
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
SimpleDialog.Builder builder = new SimpleDialog.Builder(ConnectFragment.this.getContext());
|
||||
builder.a((CharSequence) ConnectFragment.this.getString(R.string.err_msg_not_any_peripheral)).b(ConnectFragment.this.getString(R.string.retry)).b(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.connect.view.ConnectFragment.16.1
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
dialogInterface.dismiss();
|
||||
ConnectFragment.this.p.k();
|
||||
}
|
||||
});
|
||||
builder.a().show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$View
|
||||
public void J() {
|
||||
if (b() && getActivity() != null) {
|
||||
getActivity().runOnUiThread(new Runnable() { // from class: com.ubt.jimu.connect.view.ConnectFragment.13
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
ConnectFragment.this.e.setVisibility(8);
|
||||
ConnectFragment.this.j.setVisibility(4);
|
||||
ConnectFragment.this.l.setVisibility(8);
|
||||
ConnectFragment.this.l.setVisibility(0);
|
||||
ConnectFragment.this.c.setVisibility(0);
|
||||
ConnectFragment.this.l.setVisibility(0);
|
||||
ConnectFragment.this.f.setVisibility(8);
|
||||
ConnectFragment.this.g.setVisibility(0);
|
||||
ConnectFragment.this.h = 85;
|
||||
ConnectFragment.this.g.setProgress(ConnectFragment.this.h);
|
||||
ConnectFragment.this.b.setTitle(R.string.connecting_to_jimu);
|
||||
ConnectFragment.this.b.setListener(new NavigationBarView.OnActionClickListener() { // from class: com.ubt.jimu.connect.view.ConnectFragment.13.1
|
||||
public void a(View view) {
|
||||
ConnectFragment.this.h = -10;
|
||||
ConnectFragment.this.g.setProgress(ConnectFragment.this.h);
|
||||
ConnectFragment.this.p.a();
|
||||
ConnectFragment.this.p.b(false);
|
||||
ConnectFragment.this.p.k();
|
||||
}
|
||||
|
||||
public void b(View view) {
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.NavigationBarView.OnActionClickListener
|
||||
public void onClick(View view) {
|
||||
int id = view.getId();
|
||||
if (id == R.id.iv_left) {
|
||||
a(view);
|
||||
} else if (id == R.id.iv_right || id == R.id.tv_right) {
|
||||
b(view);
|
||||
}
|
||||
}
|
||||
});
|
||||
ConnectFragment.this.i.setVisibility(8);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$View
|
||||
public void O() {
|
||||
ALog.a("ConnectFragment").d("onPeripheralsTooMuchForModifyId");
|
||||
if (b() && getActivity() != null) {
|
||||
getActivity().runOnUiThread(new Runnable() { // from class: com.ubt.jimu.connect.view.ConnectFragment.14
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
SimpleDialog.Builder builder = new SimpleDialog.Builder(ConnectFragment.this.getContext());
|
||||
builder.a((CharSequence) ConnectFragment.this.getString(R.string.err_msg_only_can_modify)).b(ConnectFragment.this.getString(R.string.retry)).b(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.connect.view.ConnectFragment.14.1
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
dialogInterface.dismiss();
|
||||
ConnectFragment.this.p.k();
|
||||
}
|
||||
});
|
||||
builder.a().show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$View
|
||||
public void R() {
|
||||
if (BluetoothAdapter.getDefaultAdapter().isEnabled()) {
|
||||
return;
|
||||
}
|
||||
startActivityForResult(new Intent("android.bluetooth.adapter.action.REQUEST_ENABLE"), 102);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$View
|
||||
public void U() {
|
||||
if (b() && getActivity() != null) {
|
||||
getActivity().runOnUiThread(new Runnable() { // from class: com.ubt.jimu.connect.view.ConnectFragment.6
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
Log.e("ConnectFragment", "onScanStart");
|
||||
ConnectFragment.this.y = false;
|
||||
ConnectFragment.this.o.clear();
|
||||
ConnectFragment.this.k.notifyDataSetChanged();
|
||||
ConnectFragment.this.u.removeCallbacks(ConnectFragment.this.v);
|
||||
ConnectFragment.this.u.postDelayed(ConnectFragment.this.v, 20000L);
|
||||
ConnectFragment.this.u.removeCallbacks(ConnectFragment.this.z);
|
||||
ConnectFragment.this.u.postDelayed(ConnectFragment.this.z, 2500L);
|
||||
ConnectFragment.this.i.setVisibility(8);
|
||||
ConnectFragment.this.a.setVisibility(0);
|
||||
ConnectFragment.this.a.b();
|
||||
ConnectFragment.this.c.setVisibility(0);
|
||||
ConnectFragment.this.d.setVisibility(0);
|
||||
ConnectFragment.this.d.post(new Runnable() { // from class: com.ubt.jimu.connect.view.ConnectFragment.6.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
TranslateAnimation translateAnimation = new TranslateAnimation(0.0f, 0.0f, ConnectFragment.this.d.getMeasuredHeight(), 0.0f);
|
||||
translateAnimation.setDuration(1000L);
|
||||
translateAnimation.setInterpolator(new OvershootInterpolator());
|
||||
ConnectFragment.this.d.startAnimation(translateAnimation);
|
||||
}
|
||||
});
|
||||
ConnectFragment.this.j.setVisibility(8);
|
||||
ConnectFragment.this.e.setVisibility(8);
|
||||
ConnectFragment.this.l.setVisibility(0);
|
||||
ConnectFragment.this.f.setVisibility(8);
|
||||
ConnectFragment.this.g.setVisibility(0);
|
||||
ConnectFragment.this.h = -10;
|
||||
ConnectFragment.this.g.setProgress(ConnectFragment.this.h);
|
||||
ConnectFragment.this.b.setTitle(R.string.search_for_jimu);
|
||||
ConnectFragment.this.b.setRightIvSrc(R.mipmap.rescan);
|
||||
ConnectFragment.this.b.setListener(new NavigationBarView.OnActionClickListener() { // from class: com.ubt.jimu.connect.view.ConnectFragment.6.2
|
||||
public void a(View view) {
|
||||
ConnectFragment.this.d(0);
|
||||
}
|
||||
|
||||
public void b(View view) {
|
||||
ConnectFragment.this.p.k();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.NavigationBarView.OnActionClickListener
|
||||
public void onClick(View view) {
|
||||
int id = view.getId();
|
||||
if (id == R.id.iv_left) {
|
||||
a(view);
|
||||
} else if (id == R.id.iv_right || id == R.id.tv_right) {
|
||||
b(view);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$View
|
||||
public void Y() {
|
||||
ALog.a("ConnectFragment").d("onShowForbitChangeId");
|
||||
if (b() && getActivity() != null) {
|
||||
getActivity().runOnUiThread(new Runnable() { // from class: com.ubt.jimu.connect.view.ConnectFragment.15
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
SimpleDialog.Builder builder = new SimpleDialog.Builder(ConnectFragment.this.getContext());
|
||||
builder.a((CharSequence) ConnectFragment.this.getString(R.string.forbit_modify_component_id)).b(ConnectFragment.this.getString(R.string.retry)).b(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.connect.view.ConnectFragment.15.1
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
dialogInterface.dismiss();
|
||||
ConnectFragment.this.p.k();
|
||||
}
|
||||
});
|
||||
builder.a().show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public boolean b() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$View
|
||||
public void b0() {
|
||||
Log.i("ConnectFragment", "onConnectFail");
|
||||
this.u.removeCallbacks(this.z);
|
||||
this.u.removeCallbacks(this.v);
|
||||
if (b() && getActivity() != null) {
|
||||
getActivity().runOnUiThread(new Runnable() { // from class: com.ubt.jimu.connect.view.ConnectFragment.12
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
ConnectFragment.this.a.setVisibility(8);
|
||||
ConnectFragment.this.a.c();
|
||||
ConnectFragment.this.e.setVisibility(8);
|
||||
ConnectFragment.this.j.setVisibility(4);
|
||||
ConnectFragment.this.l.setVisibility(0);
|
||||
ConnectFragment.this.f.setVisibility(0);
|
||||
ConnectFragment.this.c.setVisibility(0);
|
||||
ConnectFragment.this.d.setVisibility(8);
|
||||
ConnectFragment.this.g.setVisibility(8);
|
||||
ConnectFragment.this.h = -10;
|
||||
ConnectFragment.this.g.setProgress(ConnectFragment.this.h);
|
||||
ConnectFragment.this.b.setTitle(R.string.connect_fail);
|
||||
ConnectFragment.this.b.setRightIvSrc(R.mipmap.connect_help);
|
||||
ConnectFragment.this.b.setRightIvVisibility(0);
|
||||
ConnectFragment.this.b.setListener(new NavigationBarView.OnActionClickListener() { // from class: com.ubt.jimu.connect.view.ConnectFragment.12.1
|
||||
public void a(View view) {
|
||||
ConnectFragment.this.d(0);
|
||||
}
|
||||
|
||||
public void b(View view) {
|
||||
ConnectFragment.this.v();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.NavigationBarView.OnActionClickListener
|
||||
public void onClick(View view) {
|
||||
int id = view.getId();
|
||||
if (id == R.id.iv_left) {
|
||||
a(view);
|
||||
} else if (id == R.id.iv_right || id == R.id.tv_right) {
|
||||
b(view);
|
||||
}
|
||||
}
|
||||
});
|
||||
ConnectFragment.this.i.setText(R.string.reconnect);
|
||||
ConnectFragment.this.i.setOnClickListener(new View.OnClickListener() { // from class: com.ubt.jimu.connect.view.ConnectFragment.12.2
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view) {
|
||||
ConnectFragment.this.p.k();
|
||||
}
|
||||
});
|
||||
ConnectFragment.this.i.setVisibility(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void o() {
|
||||
}
|
||||
|
||||
@Override // androidx.fragment.app.Fragment
|
||||
public void onActivityResult(int i, int i2, Intent intent) {
|
||||
XLog.a("ConnectFragment", "onActivityResult requestCode:" + i + " resultCode:" + i2);
|
||||
if (i == 102) {
|
||||
if (i2 == -1) {
|
||||
ALog.a("ConnectFragment").d("BlueTooth is now Enabled");
|
||||
ConnectContract$Presenter connectContract$Presenter = this.p;
|
||||
if (connectContract$Presenter != null) {
|
||||
connectContract$Presenter.p();
|
||||
}
|
||||
}
|
||||
if (i2 == 0) {
|
||||
ALog.a("ConnectFragment").d("Error occured while enabling.");
|
||||
o();
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (i == 103) {
|
||||
ConnectContract$Presenter connectContract$Presenter2 = this.p;
|
||||
if (connectContract$Presenter2 != null) {
|
||||
connectContract$Presenter2.k();
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (i == 101) {
|
||||
ConnectContract$Presenter connectContract$Presenter3 = this.p;
|
||||
if (connectContract$Presenter3 != null) {
|
||||
connectContract$Presenter3.k();
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (i != 100) {
|
||||
return;
|
||||
}
|
||||
if (this.p == null) {
|
||||
d(i2);
|
||||
return;
|
||||
}
|
||||
if (i2 != -1) {
|
||||
XLog.a("ConnectFragment", "Match fail, scan robot");
|
||||
if (this.p.d()) {
|
||||
Log.w("ConnectFragment", "Bluetooth connected, disconnect bluetooth.");
|
||||
this.p.a();
|
||||
}
|
||||
this.p.r();
|
||||
d(0);
|
||||
return;
|
||||
}
|
||||
XLog.a("ConnectFragment", "Match success, back to busiess page.");
|
||||
BluetoothDevice l = this.p.l();
|
||||
if (l != null && l.getAddress() != null) {
|
||||
this.p.c(l.getAddress(), this.r);
|
||||
}
|
||||
this.p.a(getContext(), Cache.getInstance().getBoardInfo(), this.r, this.q);
|
||||
d(-1);
|
||||
}
|
||||
|
||||
@Override // com.ubtech.view.fragment.BaseFragment, androidx.fragment.app.Fragment
|
||||
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
|
||||
String str;
|
||||
ALog.a("ConnectFragment").d("onCreateView");
|
||||
this.u = new Handler();
|
||||
this.x = new SharePreferenceHelper();
|
||||
this.n = Executors.newSingleThreadExecutor();
|
||||
Bundle arguments = getArguments();
|
||||
if (arguments != null) {
|
||||
str = arguments.getString("KEY_PIC_PATH");
|
||||
this.q = arguments.getBoolean("KEY_IS_DIY_MODEL", false);
|
||||
this.r = arguments.getString("KEY_MODEL_ID", "");
|
||||
this.s = arguments.getInt("KEY_MODEL_CODE", -10);
|
||||
this.t = arguments.getString("KEY_MODEL_NAME", "");
|
||||
} else {
|
||||
Log.i("ConnectFragment", "Not bundle arguments");
|
||||
str = null;
|
||||
}
|
||||
View a = a(layoutInflater, str);
|
||||
y();
|
||||
ConnectContract$Presenter connectContract$Presenter = this.p;
|
||||
if (connectContract$Presenter == null) {
|
||||
Log.e("ConnectFragment", "Present is null");
|
||||
return a;
|
||||
}
|
||||
connectContract$Presenter.a(this.q);
|
||||
this.p.a(this.s);
|
||||
if (this.p.d()) {
|
||||
Log.w("ConnectFragment", "Bluetooth connected, disconnect bluetooth.");
|
||||
this.p.a();
|
||||
}
|
||||
this.p.k();
|
||||
return a;
|
||||
}
|
||||
|
||||
@Override // androidx.fragment.app.Fragment
|
||||
public void onDestroyView() {
|
||||
this.a.c();
|
||||
ConnectContract$Presenter connectContract$Presenter = this.p;
|
||||
if (connectContract$Presenter != null) {
|
||||
connectContract$Presenter.q();
|
||||
}
|
||||
Dialog dialog = this.m;
|
||||
if (dialog != null && dialog.isShowing()) {
|
||||
this.m.dismiss();
|
||||
}
|
||||
this.m = null;
|
||||
this.n.shutdown();
|
||||
this.u.removeCallbacks(this.v);
|
||||
this.u.removeCallbacks(this.z);
|
||||
this.u.removeCallbacksAndMessages(null);
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
@Override // androidx.fragment.app.Fragment
|
||||
public void onResume() {
|
||||
ALog.a("ConnectFragment").d("onResume");
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$View
|
||||
public void z() {
|
||||
if (isAdded() && Build.VERSION.SDK_INT >= 23) {
|
||||
if (this.A == null) {
|
||||
this.A = new SimpleDialog.Builder(getActivity()).a(false).a((CharSequence) getResources().getString(R.string.not_open_gps_tips)).b(getResources().getString(R.string.goto_setting)).a(getResources().getString(R.string.cancel), true).a(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.connect.view.ConnectFragment.19
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
dialogInterface.dismiss();
|
||||
ALog.a("ConnectFragment").d("dismiss setting dialog");
|
||||
ConnectFragment.this.B = false;
|
||||
}
|
||||
}).b(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.connect.view.ConnectFragment.18
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
dialogInterface.dismiss();
|
||||
ConnectFragment.this.B = false;
|
||||
ConnectFragment.this.startActivityForResult(new Intent("android.settings.LOCATION_SOURCE_SETTINGS"), 103);
|
||||
}
|
||||
}).a();
|
||||
}
|
||||
if (!this.A.isShowing()) {
|
||||
this.A.show();
|
||||
}
|
||||
ALog.a("ConnectFragment").d("show setting dialog");
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void d(int i) {
|
||||
FragmentActivity activity = getActivity();
|
||||
if (b() && activity != null) {
|
||||
if (activity instanceof ConnectActivity) {
|
||||
((ConnectActivity) activity).l(i);
|
||||
} else {
|
||||
Log.e("ConnectFragment", "Should not to this!");
|
||||
activity.finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public boolean j(List<ScanResult> list) {
|
||||
String string;
|
||||
if (this.y && this.p.g() && (string = this.x.getString(this.r, null)) != null) {
|
||||
for (ScanResult scanResult : list) {
|
||||
if (string.equals(scanResult.a().getAddress())) {
|
||||
ALog.a("ConnectFragment").d("Auto connect to mac " + string);
|
||||
this.p.a(scanResult.a());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void v() {
|
||||
ALog.a("ConnectFragment").d("gotoConnectFailPage");
|
||||
c(String.valueOf(JimuConnectionException.CONNECT_FAIL.getType()));
|
||||
}
|
||||
|
||||
public /* synthetic */ void h(final List list) {
|
||||
if (this.m == null) {
|
||||
UpdateDialog.Builder builder = new UpdateDialog.Builder();
|
||||
builder.backAble(false).canceledOnTouchOutside(false).title(getString(R.string.hand_damp_warming)).content(getString(R.string.hand_damp_warming_tips)).ok(getString(R.string.ok)).interactionListener(new UpdateDialog.InteractionListner() { // from class: com.ubt.jimu.connect.view.ConnectFragment.17
|
||||
@Override // com.ubt.jimu.base.dialog.UpdateDialog.InteractionListner
|
||||
public void onCancelClick(UpdateDialog updateDialog) {
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.dialog.UpdateDialog.InteractionListner
|
||||
public void onLeftImgClick(UpdateDialog updateDialog) {
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.dialog.UpdateDialog.InteractionListner
|
||||
public void onOkClick(UpdateDialog updateDialog) {
|
||||
if (ConnectFragment.this.p != null) {
|
||||
ConnectFragment.this.p.a(list);
|
||||
}
|
||||
updateDialog.dismiss();
|
||||
ConnectFragment.this.c(-1);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.dialog.UpdateDialog.InteractionListner
|
||||
public void onRightImgClick(UpdateDialog updateDialog) {
|
||||
}
|
||||
});
|
||||
this.m = new UpdateDialog(getActivity(), builder);
|
||||
this.m.setCancelable(false);
|
||||
}
|
||||
if (!b() || this.m.isShowing()) {
|
||||
return;
|
||||
}
|
||||
this.m.show();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$View
|
||||
public void i() {
|
||||
this.u.removeCallbacks(this.v);
|
||||
this.u.removeCallbacks(this.z);
|
||||
if (b() && getActivity() != null) {
|
||||
getActivity().runOnUiThread(new Runnable() { // from class: com.ubt.jimu.connect.view.ConnectFragment.11
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
ConnectFragment.this.e.setVisibility(8);
|
||||
ConnectFragment.this.j.setVisibility(4);
|
||||
ConnectFragment.this.a.c();
|
||||
ConnectFragment.this.a.setVisibility(8);
|
||||
ConnectFragment.this.i.setVisibility(8);
|
||||
ConnectFragment.this.c.setVisibility(0);
|
||||
ConnectFragment.this.l.setVisibility(0);
|
||||
ConnectFragment.this.f.setVisibility(8);
|
||||
ConnectFragment.this.h = 0;
|
||||
ConnectFragment.this.g.setVisibility(0);
|
||||
ConnectFragment.this.d.setVisibility(0);
|
||||
TranslateAnimation translateAnimation = new TranslateAnimation(0.0f, 0.0f, ConnectFragment.this.d.getMeasuredHeight(), 0.0f);
|
||||
translateAnimation.setDuration(500L);
|
||||
translateAnimation.setInterpolator(new OvershootInterpolator());
|
||||
ConnectFragment.this.d.startAnimation(translateAnimation);
|
||||
ConnectFragment.this.n.execute(ConnectFragment.this.new ProgressRunable());
|
||||
ConnectFragment.this.b.setTitle(R.string.connecting_to_jimu);
|
||||
ConnectFragment.this.b.setRightIvVisibility(8);
|
||||
ConnectFragment.this.b.setListener(new NavigationBarView.OnActionClickListener() { // from class: com.ubt.jimu.connect.view.ConnectFragment.11.1
|
||||
public void a(View view) {
|
||||
ConnectFragment.this.h = -10;
|
||||
ConnectFragment.this.g.setProgress(ConnectFragment.this.h);
|
||||
ConnectFragment.this.p.a();
|
||||
ConnectFragment.this.p.b(false);
|
||||
ConnectFragment.this.p.k();
|
||||
}
|
||||
|
||||
public void b(View view) {
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.NavigationBarView.OnActionClickListener
|
||||
public void onClick(View view) {
|
||||
int id = view.getId();
|
||||
if (id == R.id.iv_left) {
|
||||
a(view);
|
||||
} else if (id == R.id.iv_right || id == R.id.tv_right) {
|
||||
b(view);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void q() {
|
||||
if (getActivity() != null) {
|
||||
getActivity().runOnUiThread(new Runnable() { // from class: com.ubt.jimu.connect.view.ConnectFragment.10
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
ConnectFragment.this.e.setVisibility(8);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void c(String str) {
|
||||
if (getActivity() == null) {
|
||||
return;
|
||||
}
|
||||
String url = JimuConnectionException.getUrl(str);
|
||||
if (TextUtils.isEmpty(url)) {
|
||||
return;
|
||||
}
|
||||
HelpActivity.start(getActivity(), url, " ", R.color.theme_background, false);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$View
|
||||
public void a(ConnectContract$Presenter connectContract$Presenter) {
|
||||
this.p = connectContract$Presenter;
|
||||
}
|
||||
|
||||
private View a(LayoutInflater layoutInflater, String str) {
|
||||
View inflate = layoutInflater.inflate(R.layout.frag_connect, (ViewGroup) null);
|
||||
this.l = (FrameLayout) inflate.findViewById(R.id.fl_connect_state);
|
||||
this.l.setVisibility(0);
|
||||
this.g = (CircleProgressBar) inflate.findViewById(R.id.pb_connecting);
|
||||
this.e = (ProgressBar) inflate.findViewById(R.id.pb_progress);
|
||||
this.i = (Button) inflate.findViewById(R.id.btn_multi_function);
|
||||
this.f = (RelativeLayout) inflate.findViewById(R.id.rl_connect_fail);
|
||||
this.d = (ImageView) inflate.findViewById(R.id.iv_connect_hand);
|
||||
this.b = (NavigationBarView) inflate.findViewById(R.id.nbv_bar);
|
||||
this.b.setLeftIvSrc(R.drawable.community_cancel);
|
||||
this.c = (ImageView) inflate.findViewById(R.id.iv_robot);
|
||||
FragmentActivity activity = getActivity();
|
||||
if (activity == null) {
|
||||
return inflate;
|
||||
}
|
||||
RequestOptions N = RequestOptions.N();
|
||||
N.a(Integer.MIN_VALUE, Integer.MIN_VALUE);
|
||||
if (!TextUtils.isEmpty(str)) {
|
||||
RequestBuilder<Drawable> a = Glide.a(this).a(str);
|
||||
a.a(N);
|
||||
a.a(this.c);
|
||||
} else {
|
||||
RequestBuilder<Drawable> d = Glide.a(this).d(activity.getResources().getDrawable(R.drawable.controller_small, null));
|
||||
d.a(RequestOptions.P());
|
||||
d.a(this.c);
|
||||
}
|
||||
this.a = (WaveView) inflate.findViewById(R.id.wave);
|
||||
int a2 = DisplayUtil.a((Context) activity, R.dimen.searching_wave_width);
|
||||
int a3 = DisplayUtil.a((Context) activity, R.dimen.searching_wave_image_radius);
|
||||
int a4 = DisplayUtil.a((Context) activity, R.dimen.searching_wave_max_radius);
|
||||
this.a.setWidth(a2);
|
||||
this.a.setImageRadius(a3);
|
||||
this.a.setMaxRadius(a4);
|
||||
this.a.setFill(false);
|
||||
this.a.a();
|
||||
this.j = (ListView) inflate.findViewById(R.id.lv_robots_scaned);
|
||||
this.k = new RobotsScanedAdapter(getContext(), R.layout.item_robot_info_scaned, this.o);
|
||||
this.j.setAdapter((ListAdapter) this.k);
|
||||
this.j.setOnItemClickListener(new AdapterView.OnItemClickListener() { // from class: com.ubt.jimu.connect.view.ConnectFragment.2
|
||||
@Override // android.widget.AdapterView.OnItemClickListener
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
|
||||
ScanResult scanResult = (ScanResult) ConnectFragment.this.o.get(i);
|
||||
if (scanResult == null || scanResult.a() == null) {
|
||||
return;
|
||||
}
|
||||
if (scanResult.a().getAddress() == null) {
|
||||
Log.e("ConnectFragment", "click an device that address is null!");
|
||||
return;
|
||||
}
|
||||
ConnectFragment.this.o.clear();
|
||||
ConnectFragment.this.k.notifyDataSetChanged();
|
||||
ConnectFragment.this.p.a(scanResult.a());
|
||||
}
|
||||
});
|
||||
return inflate;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$View
|
||||
public void c(int i) {
|
||||
ALog.a("ConnectFragment").d("onBackToBusinessPage");
|
||||
d(i);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$View
|
||||
public void a(final ScanResult scanResult) {
|
||||
if (!b() || scanResult.a() == null || TextUtils.isEmpty(scanResult.a().getName()) || getActivity() == null) {
|
||||
return;
|
||||
}
|
||||
getActivity().runOnUiThread(new Runnable() { // from class: com.ubt.jimu.connect.view.ConnectFragment.9
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
ALog.a("ConnectFragment").d("scaned robot:" + scanResult.a().getAddress());
|
||||
Iterator it = ConnectFragment.this.o.iterator();
|
||||
while (it.hasNext()) {
|
||||
ScanResult scanResult2 = (ScanResult) it.next();
|
||||
if (TextUtils.isEmpty(scanResult2.a().getName())) {
|
||||
it.remove();
|
||||
} else if (scanResult.a().getName().equals(scanResult2.a().getName())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
ConnectFragment.this.o.add(scanResult);
|
||||
ConnectFragment.this.k.notifyDataSetChanged();
|
||||
ConnectFragment connectFragment = ConnectFragment.this;
|
||||
if (connectFragment.j((List<ScanResult>) connectFragment.o)) {
|
||||
return;
|
||||
}
|
||||
ALog.a("ConnectFragment").d("sort scaned robot by RSSI!");
|
||||
Collections.sort(ConnectFragment.this.o, new SortByRssi(ConnectFragment.this));
|
||||
ConnectFragment.this.k.notifyDataSetChanged();
|
||||
if (ConnectFragment.this.y) {
|
||||
ConnectFragment.this.A();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$View
|
||||
public void a(String str, boolean z) {
|
||||
ALog.a("ConnectFragment").d("onMatchErrorOrNeedUpdate");
|
||||
this.h = 100;
|
||||
this.g.setProgress(this.h);
|
||||
if (getContext() == null) {
|
||||
return;
|
||||
}
|
||||
Intent intent = new Intent(getContext(), (Class<?>) ComponentsListActivity.class);
|
||||
intent.putExtra("KEY_IS_DIY_MODEL", z);
|
||||
intent.putExtra("KEY_MODEL_ID", str);
|
||||
intent.putExtra("KEY_MODEL_NAME", this.t);
|
||||
if (this.p.l() != null) {
|
||||
intent.putExtra("KEY_DEVICE_NAME", this.p.l().getName());
|
||||
}
|
||||
startActivityForResult(intent, 100);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.connect.contract.ConnectContract$View
|
||||
public void a(final List<ServoAngleReadInfo> list) {
|
||||
if (list == null || list.size() == 0 || !b() || getActivity() == null) {
|
||||
return;
|
||||
}
|
||||
getActivity().runOnUiThread(new Runnable() { // from class: com.ubt.jimu.connect.view.l
|
||||
@Override // java.lang.Runnable
|
||||
public final void run() {
|
||||
ConnectFragment.this.h(list);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
264
sources/com/ubt/jimu/connect/view/DisconnectFragment.java
Normal file
264
sources/com/ubt/jimu/connect/view/DisconnectFragment.java
Normal file
@@ -0,0 +1,264 @@
|
||||
package com.ubt.jimu.connect.view;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.RequestBuilder;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import com.ubt.jimu.JimuApplication;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.base.cache.Cache;
|
||||
import com.ubt.jimu.base.dialog.UpdateDialog;
|
||||
import com.ubt.jimu.connect.ConnectActivity;
|
||||
import com.ubt.jimu.widgets.NavigationBarView;
|
||||
import com.ubtech.view.dialog.SimpleDialog;
|
||||
import com.ubtech.view.fragment.BaseFragment;
|
||||
import com.ubtrobot.jimu.bluetooth.ConnectionState;
|
||||
import com.ubtrobot.jimu.bluetooth.ConnectionStateListener;
|
||||
import com.ubtrobot.jimu.robotapi.JimuManager;
|
||||
import com.ubtrobot.log.ALog;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class DisconnectFragment extends BaseFragment {
|
||||
private NavigationBarView a;
|
||||
private ImageView b;
|
||||
private CircleProgressBar c;
|
||||
private RelativeLayout d;
|
||||
private Button e;
|
||||
private FrameLayout f;
|
||||
private String h;
|
||||
private JimuManager j;
|
||||
private Dialog n;
|
||||
private boolean g = false;
|
||||
private String i = null;
|
||||
private boolean k = false;
|
||||
private volatile boolean l = false;
|
||||
private ConnectionStateListener m = new ConnectionStateListener() { // from class: com.ubt.jimu.connect.view.DisconnectFragment.1
|
||||
@Override // com.ubtrobot.jimu.bluetooth.ConnectionStateListener
|
||||
public void onConnectionStateChange(String str, ConnectionState connectionState) {
|
||||
Log.e("DisconnectFragment", "onConnectionStateChange newState:" + connectionState);
|
||||
if (ConnectionState.STATE_DISCONNECTED != connectionState || DisconnectFragment.this.l) {
|
||||
return;
|
||||
}
|
||||
DisconnectFragment.this.x();
|
||||
}
|
||||
};
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void o() {
|
||||
this.l = true;
|
||||
JimuApplication.l().f().c();
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public boolean q() {
|
||||
return this.k;
|
||||
}
|
||||
|
||||
private void v() {
|
||||
ALog.a("DisconnectFragment").d("onConnected");
|
||||
if (b()) {
|
||||
this.d.setVisibility(8);
|
||||
this.c.setVisibility(0);
|
||||
this.c.setProgress(100);
|
||||
this.e.setText(R.string.bluetooth_disconnect);
|
||||
this.e.setOnClickListener(new View.OnClickListener() { // from class: com.ubt.jimu.connect.view.DisconnectFragment.3
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view) {
|
||||
new SimpleDialog.Builder(DisconnectFragment.this.getContext()).d(R.string.ok).b(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.connect.view.DisconnectFragment.3.2
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
dialogInterface.dismiss();
|
||||
DisconnectFragment.this.o();
|
||||
DisconnectFragment.this.d(-1);
|
||||
}
|
||||
}).a(R.string.cancel, true).a(new DialogInterface.OnClickListener(this) { // from class: com.ubt.jimu.connect.view.DisconnectFragment.3.1
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
dialogInterface.dismiss();
|
||||
}
|
||||
}).a((CharSequence) DisconnectFragment.this.getString(R.string.ensure_diconnect_bluetooth_connection)).a().show();
|
||||
}
|
||||
});
|
||||
this.e.setVisibility(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void x() {
|
||||
ALog.a("DisconnectFragment").d("Show bluetooth disconnect dialog");
|
||||
final FragmentActivity activity = getActivity();
|
||||
if (activity == null) {
|
||||
return;
|
||||
}
|
||||
activity.runOnUiThread(new Runnable() { // from class: com.ubt.jimu.connect.view.DisconnectFragment.4
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
if (DisconnectFragment.this.n == null) {
|
||||
String string = DisconnectFragment.this.getString(R.string.bluetooth_disconnected);
|
||||
UpdateDialog.Builder builder = new UpdateDialog.Builder();
|
||||
builder.content(string).ok(DisconnectFragment.this.getString(R.string.ok)).interactionListener(new UpdateDialog.InteractionListner() { // from class: com.ubt.jimu.connect.view.DisconnectFragment.4.1
|
||||
@Override // com.ubt.jimu.base.dialog.UpdateDialog.InteractionListner
|
||||
public void onCancelClick(UpdateDialog updateDialog) {
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.dialog.UpdateDialog.InteractionListner
|
||||
public void onLeftImgClick(UpdateDialog updateDialog) {
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.dialog.UpdateDialog.InteractionListner
|
||||
public void onOkClick(UpdateDialog updateDialog) {
|
||||
updateDialog.dismiss();
|
||||
DisconnectFragment.this.d(-1);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.dialog.UpdateDialog.InteractionListner
|
||||
public void onRightImgClick(UpdateDialog updateDialog) {
|
||||
}
|
||||
});
|
||||
DisconnectFragment.this.n = new UpdateDialog(activity, builder);
|
||||
}
|
||||
if (activity.isFinishing() || DisconnectFragment.this.n.isShowing() || !DisconnectFragment.this.q()) {
|
||||
return;
|
||||
}
|
||||
ALog.a("DisconnectFragment").d("real show bluetooth disconnect dialog");
|
||||
DisconnectFragment.this.n.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override // androidx.fragment.app.Fragment
|
||||
public void onActivityResult(int i, int i2, Intent intent) {
|
||||
if (i == 100 && i2 == 0) {
|
||||
d(-1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubtech.view.fragment.BaseFragment, androidx.fragment.app.Fragment
|
||||
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
|
||||
String str;
|
||||
ALog.a("DisconnectFragment").d("onCreateView");
|
||||
this.l = false;
|
||||
Bundle arguments = getArguments();
|
||||
if (arguments != null) {
|
||||
str = arguments.getString("KEY_PIC_PATH");
|
||||
this.g = arguments.getBoolean("KEY_IS_DIY_MODEL", false);
|
||||
this.h = arguments.getString("KEY_MODEL_ID", "");
|
||||
arguments.getInt("KEY_MODEL_CODE", -10);
|
||||
this.i = arguments.getString("KEY_MODEL_NAME", "");
|
||||
} else {
|
||||
Log.e("DisconnectFragment", "Not bundle arguments");
|
||||
str = null;
|
||||
}
|
||||
View a = a(layoutInflater, str);
|
||||
v();
|
||||
this.j = JimuApplication.l().f();
|
||||
this.j.a(this.m);
|
||||
return a;
|
||||
}
|
||||
|
||||
@Override // androidx.fragment.app.Fragment
|
||||
public void onDestroyView() {
|
||||
this.j.b(this.m);
|
||||
this.n = null;
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
@Override // androidx.fragment.app.Fragment
|
||||
public void onPause() {
|
||||
this.k = false;
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override // androidx.fragment.app.Fragment
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
this.k = true;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void d(int i) {
|
||||
FragmentActivity activity = getActivity();
|
||||
if (activity instanceof ConnectActivity) {
|
||||
((ConnectActivity) activity).l(i);
|
||||
} else {
|
||||
Log.e("DisconnectFragment", "Should not to this!");
|
||||
activity.finish();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean b() {
|
||||
return isAdded();
|
||||
}
|
||||
|
||||
private View a(LayoutInflater layoutInflater, String str) {
|
||||
View inflate = layoutInflater.inflate(R.layout.frag_disconnect, (ViewGroup) null);
|
||||
this.f = (FrameLayout) inflate.findViewById(R.id.fl_connect_state);
|
||||
this.f.setVisibility(0);
|
||||
this.e = (Button) inflate.findViewById(R.id.btn_multi_function);
|
||||
this.c = (CircleProgressBar) inflate.findViewById(R.id.pb_connecting);
|
||||
this.d = (RelativeLayout) inflate.findViewById(R.id.rl_connect_fail);
|
||||
this.a = (NavigationBarView) inflate.findViewById(R.id.nbv_bar);
|
||||
this.a.setLeftIvSrc(R.mipmap.icon_round_back);
|
||||
this.a.setRightIvSrc(R.drawable.bg_look_btn);
|
||||
this.a.setTitle(this.i);
|
||||
this.a.setListener(new NavigationBarView.OnActionClickListener() { // from class: com.ubt.jimu.connect.view.DisconnectFragment.2
|
||||
public void a(View view) {
|
||||
DisconnectFragment.this.d(0);
|
||||
}
|
||||
|
||||
public void b(View view) {
|
||||
if (DisconnectFragment.this.getContext() == null) {
|
||||
return;
|
||||
}
|
||||
Intent intent = new Intent(DisconnectFragment.this.getContext(), (Class<?>) ComponentsListActivity.class);
|
||||
intent.putExtra("KEY_MODEL_CODE", 5001);
|
||||
intent.putExtra("KEY_IS_DIY_MODEL", DisconnectFragment.this.g);
|
||||
intent.putExtra("KEY_MODEL_ID", DisconnectFragment.this.h);
|
||||
intent.putExtra("KEY_MODEL_NAME", DisconnectFragment.this.i);
|
||||
BluetoothDevice lastConnectedDevice = Cache.getInstance().getLastConnectedDevice();
|
||||
if (lastConnectedDevice != null) {
|
||||
intent.putExtra("KEY_DEVICE_NAME", lastConnectedDevice.getName());
|
||||
}
|
||||
DisconnectFragment.this.startActivityForResult(intent, 100);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.NavigationBarView.OnActionClickListener
|
||||
public void onClick(View view) {
|
||||
int id = view.getId();
|
||||
if (id == R.id.iv_left) {
|
||||
a(view);
|
||||
} else if (id == R.id.iv_right || id == R.id.tv_right) {
|
||||
b(view);
|
||||
}
|
||||
}
|
||||
});
|
||||
this.b = (ImageView) inflate.findViewById(R.id.iv_robot);
|
||||
RequestOptions N = RequestOptions.N();
|
||||
N.a(Integer.MIN_VALUE, Integer.MIN_VALUE);
|
||||
if (!TextUtils.isEmpty(str)) {
|
||||
RequestBuilder<Drawable> a = Glide.a(this).a(str);
|
||||
a.a(N);
|
||||
a.a(this.b);
|
||||
} else {
|
||||
RequestBuilder<Drawable> d = Glide.a(this).d(getActivity().getResources().getDrawable(R.drawable.controller, null));
|
||||
d.a(RequestOptions.P());
|
||||
d.a(this.b);
|
||||
}
|
||||
return inflate;
|
||||
}
|
||||
}
|
54
sources/com/ubt/jimu/connect/view/FirmwareUpdateDialog.java
Normal file
54
sources/com/ubt/jimu/connect/view/FirmwareUpdateDialog.java
Normal file
@@ -0,0 +1,54 @@
|
||||
package com.ubt.jimu.connect.view;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.view.KeyEvent;
|
||||
import android.widget.TextView;
|
||||
import com.ubt.jimu.R;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class FirmwareUpdateDialog extends Dialog {
|
||||
private TextView a;
|
||||
private TextView b;
|
||||
|
||||
public FirmwareUpdateDialog(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public void a(final String str, final int i) {
|
||||
TextView textView = this.a;
|
||||
if (textView == null) {
|
||||
return;
|
||||
}
|
||||
textView.post(new Runnable() { // from class: com.ubt.jimu.connect.view.m
|
||||
@Override // java.lang.Runnable
|
||||
public final void run() {
|
||||
FirmwareUpdateDialog.this.a(i, str);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override // android.app.Dialog
|
||||
protected void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
getWindow().requestFeature(1);
|
||||
setContentView(R.layout.dialog_firmware_update);
|
||||
getWindow().setBackgroundDrawable(new ColorDrawable(0));
|
||||
getWindow().setLayout(-1, -1);
|
||||
setCanceledOnTouchOutside(false);
|
||||
this.a = (TextView) findViewById(R.id.tvUpdateProgress);
|
||||
this.b = (TextView) findViewById(R.id.tvCurrentFirmware);
|
||||
}
|
||||
|
||||
@Override // android.app.Dialog, android.view.KeyEvent.Callback
|
||||
public boolean onKeyDown(int i, KeyEvent keyEvent) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public /* synthetic */ void a(int i, String str) {
|
||||
this.a.setText(i + "%");
|
||||
this.b.setText(str);
|
||||
}
|
||||
}
|
96
sources/com/ubt/jimu/connect/view/RecycleViewDivider.java
Normal file
96
sources/com/ubt/jimu/connect/view/RecycleViewDivider.java
Normal file
@@ -0,0 +1,96 @@
|
||||
package com.ubt.jimu.connect.view;
|
||||
|
||||
import android.R;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class RecycleViewDivider extends RecyclerView.ItemDecoration {
|
||||
private static final int[] e = {R.attr.listDivider};
|
||||
private Paint a;
|
||||
private Drawable b;
|
||||
private int c;
|
||||
private int d;
|
||||
|
||||
public RecycleViewDivider(Context context, int i) {
|
||||
this.c = 2;
|
||||
if (i != 1 && i != 0) {
|
||||
throw new IllegalArgumentException("请输入正确的参数!");
|
||||
}
|
||||
this.d = i;
|
||||
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(e);
|
||||
this.b = obtainStyledAttributes.getDrawable(0);
|
||||
obtainStyledAttributes.recycle();
|
||||
}
|
||||
|
||||
private void a(Canvas canvas, RecyclerView recyclerView) {
|
||||
int paddingLeft = recyclerView.getPaddingLeft();
|
||||
int measuredWidth = recyclerView.getMeasuredWidth() - recyclerView.getPaddingRight();
|
||||
int childCount = recyclerView.getChildCount();
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
View childAt = recyclerView.getChildAt(i);
|
||||
int bottom = childAt.getBottom() + ((ViewGroup.MarginLayoutParams) ((RecyclerView.LayoutParams) childAt.getLayoutParams())).bottomMargin;
|
||||
int i2 = this.c + bottom;
|
||||
Drawable drawable = this.b;
|
||||
if (drawable != null) {
|
||||
drawable.setBounds(paddingLeft, bottom, measuredWidth, i2);
|
||||
this.b.draw(canvas);
|
||||
}
|
||||
Paint paint = this.a;
|
||||
if (paint != null) {
|
||||
canvas.drawRect(paddingLeft, bottom, measuredWidth, i2, paint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void b(Canvas canvas, RecyclerView recyclerView) {
|
||||
int paddingTop = recyclerView.getPaddingTop();
|
||||
int measuredHeight = recyclerView.getMeasuredHeight() - recyclerView.getPaddingBottom();
|
||||
int childCount = recyclerView.getChildCount();
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
View childAt = recyclerView.getChildAt(i);
|
||||
int right = childAt.getRight() + ((ViewGroup.MarginLayoutParams) ((RecyclerView.LayoutParams) childAt.getLayoutParams())).rightMargin;
|
||||
int i2 = this.c + right;
|
||||
Drawable drawable = this.b;
|
||||
if (drawable != null) {
|
||||
drawable.setBounds(right, paddingTop, i2, measuredHeight);
|
||||
this.b.draw(canvas);
|
||||
}
|
||||
Paint paint = this.a;
|
||||
if (paint != null) {
|
||||
canvas.drawRect(right, paddingTop, i2, measuredHeight, paint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.ItemDecoration
|
||||
public void getItemOffsets(Rect rect, View view, RecyclerView recyclerView, RecyclerView.State state) {
|
||||
super.getItemOffsets(rect, view, recyclerView, state);
|
||||
rect.set(0, 0, 0, this.c);
|
||||
}
|
||||
|
||||
@Override // androidx.recyclerview.widget.RecyclerView.ItemDecoration
|
||||
public void onDraw(Canvas canvas, RecyclerView recyclerView, RecyclerView.State state) {
|
||||
super.onDraw(canvas, recyclerView, state);
|
||||
if (this.d == 1) {
|
||||
b(canvas, recyclerView);
|
||||
} else {
|
||||
a(canvas, recyclerView);
|
||||
}
|
||||
}
|
||||
|
||||
public RecycleViewDivider(Context context, int i, int i2, int i3) {
|
||||
this(context, i);
|
||||
this.c = i2;
|
||||
this.a = new Paint(1);
|
||||
this.a.setColor(i3);
|
||||
this.a.setStyle(Paint.Style.FILL);
|
||||
}
|
||||
}
|
143
sources/com/ubt/jimu/connect/view/WaveView.java
Normal file
143
sources/com/ubt/jimu/connect/view/WaveView.java
Normal file
@@ -0,0 +1,143 @@
|
||||
package com.ubt.jimu.connect.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.R$styleable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class WaveView extends View {
|
||||
private int a;
|
||||
private int b;
|
||||
private int c;
|
||||
private Integer d;
|
||||
private boolean e;
|
||||
private List<Integer> f;
|
||||
private List<Integer> g;
|
||||
private Paint h;
|
||||
private boolean i;
|
||||
|
||||
public WaveView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
private void d() {
|
||||
this.h = new Paint();
|
||||
this.h.setAntiAlias(true);
|
||||
this.f.add(255);
|
||||
this.g.add(0);
|
||||
}
|
||||
|
||||
public void a() {
|
||||
this.f.add(255);
|
||||
this.g.add(0);
|
||||
}
|
||||
|
||||
public void b() {
|
||||
this.e = true;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public void c() {
|
||||
this.e = false;
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void invalidate() {
|
||||
if (hasWindowFocus()) {
|
||||
super.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void onDraw(Canvas canvas) {
|
||||
this.h.setColor(this.a);
|
||||
for (int i = 0; i < this.f.size(); i++) {
|
||||
Integer num = this.f.get(i);
|
||||
this.h.setAlpha(num.intValue());
|
||||
Integer num2 = this.g.get(i);
|
||||
if (this.i) {
|
||||
this.h.setStyle(Paint.Style.FILL);
|
||||
canvas.drawCircle(getWidth() / 2, getHeight() / 2, this.b + num2.intValue(), this.h);
|
||||
this.h.setStyle(Paint.Style.STROKE);
|
||||
this.h.setStrokeWidth(3.0f);
|
||||
canvas.drawCircle(getWidth() / 2, getHeight() / 2, this.b + num2.intValue(), this.h);
|
||||
} else {
|
||||
this.h.setStyle(Paint.Style.STROKE);
|
||||
this.h.setStrokeWidth(3.0f);
|
||||
canvas.drawCircle(getWidth() / 2, getHeight() / 2, this.b + num2.intValue(), this.h);
|
||||
}
|
||||
if (this.d.intValue() == 0) {
|
||||
this.d = 600;
|
||||
}
|
||||
if (num.intValue() > 0 && this.b + num2.intValue() < this.d.intValue()) {
|
||||
this.f.set(i, Integer.valueOf((int) ((1.0f - (((this.b + num2.intValue()) * 1.0f) / this.d.intValue())) * 255.0f)));
|
||||
this.g.set(i, Integer.valueOf(num2.intValue() + 2));
|
||||
} else if (num.intValue() < 0 && this.b + num2.intValue() > this.d.intValue()) {
|
||||
this.g.remove(i);
|
||||
this.f.remove(i);
|
||||
}
|
||||
}
|
||||
if (this.g.get(r9.size() - 1).intValue() >= this.c) {
|
||||
a();
|
||||
}
|
||||
if (this.e) {
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void onWindowFocusChanged(boolean z) {
|
||||
super.onWindowFocusChanged(z);
|
||||
this.d = Integer.valueOf((getWidth() > getHeight() ? getHeight() : getWidth()) / 2);
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public void setColor(int i) {
|
||||
this.a = i;
|
||||
}
|
||||
|
||||
public void setFill(boolean z) {
|
||||
this.i = z;
|
||||
}
|
||||
|
||||
public void setImageRadius(int i) {
|
||||
this.b = i;
|
||||
}
|
||||
|
||||
public void setMaxRadius(int i) {
|
||||
this.d = Integer.valueOf(i);
|
||||
}
|
||||
|
||||
public void setWidth(int i) {
|
||||
this.c = i;
|
||||
}
|
||||
|
||||
public WaveView(Context context, AttributeSet attributeSet) {
|
||||
this(context, attributeSet, 0);
|
||||
}
|
||||
|
||||
public WaveView(Context context, AttributeSet attributeSet, int i) {
|
||||
super(context, attributeSet, i);
|
||||
this.a = getResources().getColor(R.color.bg_robot_search_wave);
|
||||
this.b = 60;
|
||||
this.c = 3;
|
||||
this.d = 600;
|
||||
this.e = false;
|
||||
this.f = new ArrayList();
|
||||
this.g = new ArrayList();
|
||||
this.i = true;
|
||||
d();
|
||||
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R$styleable.WaveView, i, 0);
|
||||
this.a = obtainStyledAttributes.getColor(0, this.a);
|
||||
this.c = obtainStyledAttributes.getInt(2, this.c);
|
||||
this.b = obtainStyledAttributes.getInt(1, this.b);
|
||||
obtainStyledAttributes.recycle();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user