[add] 删除无用代码;解决互相引用引起的内存泄露;解决弹框重复
This commit is contained in:
@@ -11,6 +11,7 @@ import com.elegant.network.ParamsBuilder;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.commons.network.SubscribeImpl;
|
||||
import com.mogo.eagle.core.function.call.check.CallerCheckManager;
|
||||
import com.mogo.eagle.core.function.check.api.ICheckResultCallBack;
|
||||
import com.mogo.eagle.core.function.check.net.CheckApiServiceFactory;
|
||||
import com.mogo.eagle.core.function.check.net.CheckResultData;
|
||||
import com.mogo.eagle.core.function.check.view.CheckDialog;
|
||||
@@ -76,79 +77,35 @@ public class VehicleMonitoringManager implements ICheckProvider {
|
||||
|
||||
@Override
|
||||
public void startCheckActivity(Context context) {
|
||||
// if (context != null) {
|
||||
// CheckActivity.start(context);
|
||||
// }
|
||||
Intent starter = new Intent(context, CheckActivity.class);
|
||||
starter.putExtra("CheckResultData", checkResultData);
|
||||
starter.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(starter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showCheckDialog(Context context) {
|
||||
// if (context != null) {
|
||||
// CheckActivity.showDialog(context);
|
||||
// }
|
||||
showDialog(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkMonitor(Context context) {
|
||||
// if (context != null) {
|
||||
// return CheckActivity.checkMonitor(context);
|
||||
// }
|
||||
// .append("sn", MoGoAiCloudClientConfig.getInstance().getSn())
|
||||
|
||||
final Map<String, Object> params = ParamsBuilder.of(false)
|
||||
.append("sn", "QWE12E1211231R1212123")
|
||||
.build();
|
||||
CheckApiServiceFactory.getDataApiService(context).loadMonitorDetail(params)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<CheckResultData>(RequestOptions.create(context)) {
|
||||
@Override
|
||||
public void onSuccess(CheckResultData o) {
|
||||
super.onSuccess(o);
|
||||
Log.d("checkMonitor", "车辆自检结果是:" + o.toString());
|
||||
checkResultData = o;
|
||||
if (((CheckResultData) o).getData().getVehicle().getState() == 1) {
|
||||
CallerCheckManager.updateMonitoringStatus(MogoReceiver.ACTION_CHECK_VEHICLE_MONITORING, false);
|
||||
} else {
|
||||
CallerCheckManager.updateMonitoringStatus(MogoReceiver.ACTION_CHECK_VEHICLE_MONITORING, true);
|
||||
showDialog(context);
|
||||
}
|
||||
// ThreadUtils.runOnUiThread(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
//// if (o != null && mCheckAdapter != null) {
|
||||
//// mCheckAdapter.mCheckResultData = o;
|
||||
//// mCheckAdapter.notifyDataSetChanged();
|
||||
//// }
|
||||
//
|
||||
// if (((CheckResultData) o).getData().getVehicle().getState() == 1) {
|
||||
// CallerCheckManager.updateMonitoringStatus(MogoReceiver.ACTION_CHECK_VEHICLE_MONITORING, false);
|
||||
// } else {
|
||||
// CallerCheckManager.updateMonitoringStatus(MogoReceiver.ACTION_CHECK_VEHICLE_MONITORING, true);
|
||||
// showDialog(context);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
public void checkMonitor(Context context) {
|
||||
if (context != null) {
|
||||
CheckActivity.checkMonitor(context, new ICheckResultCallBack() {
|
||||
@Override
|
||||
public void callBackWithErrorState(Integer hasError) {
|
||||
if (hasError == 1) {
|
||||
updateMonitoringStatus(MogoReceiver.ACTION_CHECK_VEHICLE_MONITORING, false);
|
||||
} else {
|
||||
updateMonitoringStatus(MogoReceiver.ACTION_CHECK_VEHICLE_MONITORING, true);
|
||||
showDialog(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
// Log.d(TAG, "车辆自检失败,请稍后重试" + "==" + message + String.valueOf(code));
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
CheckResultData checkResultData;
|
||||
|
||||
CheckDialog dialog;
|
||||
static CheckDialog dialog;
|
||||
|
||||
/**
|
||||
* 指标异常弹框
|
||||
@@ -178,7 +135,6 @@ public class VehicleMonitoringManager implements ICheckProvider {
|
||||
PackageManager packageManager = context.getPackageManager();
|
||||
PackageInfo packageInfo = packageManager.getPackageInfo(
|
||||
context.getPackageName(), 0);
|
||||
// Log.d(TAG, "包名:" + packageInfo.packageName);
|
||||
return packageInfo.packageName;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.mogo.eagle.core.function.check.api;
|
||||
|
||||
/**
|
||||
* @author liujing
|
||||
* @description 描述
|
||||
* @since: 8/6/21
|
||||
*/
|
||||
public interface ICheckListener {
|
||||
|
||||
/**
|
||||
* 工控机->鹰眼定位数据延时
|
||||
*/
|
||||
void getAutoLocationTimeCallbackDelayed(long time);
|
||||
|
||||
/**
|
||||
* 工控机->鹰眼识别数据延时
|
||||
*/
|
||||
void getAutoDataCallbackDelayed(long time);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.mogo.eagle.core.function.check.api;
|
||||
|
||||
import com.mogo.service.adas.IMogoAdasDataCallback;
|
||||
|
||||
/**
|
||||
* @author liujing
|
||||
* @description 自车检测结果回调
|
||||
* @since: 9/28/21
|
||||
*/
|
||||
public interface ICheckResultCallBack {
|
||||
void callBackWithErrorState(Integer hasError);
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package com.mogo.eagle.core.function.check.api;
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
* @date 2021/7/5 2:54 下午
|
||||
* <p>
|
||||
* 软件环境检测
|
||||
* -----> 自动驾驶版本
|
||||
* -----> 鹰眼版本
|
||||
*/
|
||||
public interface SoftCheckApi {
|
||||
|
||||
/**
|
||||
* 检测「自动驾驶」版本
|
||||
*/
|
||||
void checkAutoPilotSoftVersion();
|
||||
|
||||
/**
|
||||
* 检测「鹰眼」版本
|
||||
*/
|
||||
void checkEagleEyeSoftVersion();
|
||||
|
||||
}
|
||||
@@ -25,6 +25,7 @@ import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.commons.network.SubscribeImpl;
|
||||
import com.mogo.eagle.core.function.call.check.CallerCheckManager;
|
||||
import com.mogo.eagle.core.function.check.R;
|
||||
import com.mogo.eagle.core.function.check.api.ICheckResultCallBack;
|
||||
import com.mogo.eagle.core.function.check.net.CheckApiServiceFactory;
|
||||
import com.mogo.eagle.core.function.check.net.CheckResultData;
|
||||
import com.mogo.eagle.core.utilcode.util.ActivityUtils;
|
||||
@@ -55,7 +56,6 @@ public class CheckActivity extends AppCompatActivity {
|
||||
private static Context context;
|
||||
private static NetworkStatusUtil.NetWorkStatus sNetWorkStatus;
|
||||
private ImageView mImageView;
|
||||
private static String packageName = "com.mogo.launcher.f";
|
||||
//车模
|
||||
private ImageView scanBottomCarImage;
|
||||
//扫描束
|
||||
@@ -73,7 +73,6 @@ public class CheckActivity extends AppCompatActivity {
|
||||
private final static long DURATION_TIME = 1000;
|
||||
private static CheckAdapter mCheckAdapter;
|
||||
private static boolean isFront = false;
|
||||
private static CheckDialog dialog;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
@@ -85,19 +84,9 @@ public class CheckActivity extends AppCompatActivity {
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
// loadDetail(context);
|
||||
Intent intent = getIntent();
|
||||
if (intent != null){
|
||||
CheckResultData checkResultData = (CheckResultData) intent.getSerializableExtra("CheckResultData");
|
||||
if (checkResultData != null&& mCheckAdapter != null){
|
||||
mCheckAdapter.mCheckResultData = checkResultData;
|
||||
mCheckAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}else{
|
||||
|
||||
}
|
||||
animation();
|
||||
loadDetail(context, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表View初始化
|
||||
*/
|
||||
@@ -111,11 +100,10 @@ public class CheckActivity extends AppCompatActivity {
|
||||
tipsImageView = findViewById(R.id.scan_car_tips);
|
||||
mProgressBar = findViewById(R.id.check_progress);
|
||||
context = mImageView.getContext();
|
||||
packageName = getPackageName(context);
|
||||
mImageView.setOnClickListener(v -> {
|
||||
finish();
|
||||
});
|
||||
animation();
|
||||
|
||||
mRecyclerView = findViewById(R.id.check_list);
|
||||
CheckLinearLayout linearLayoutManager =
|
||||
new CheckLinearLayout(this, CheckLinearLayout.VERTICAL, false);
|
||||
@@ -128,67 +116,44 @@ public class CheckActivity extends AppCompatActivity {
|
||||
/**
|
||||
* 自动驾驶状态下指标监测
|
||||
*/
|
||||
// public static boolean checkMonitor(Context context) {
|
||||
// Log.d(TAG, "checkMonitor");
|
||||
// loadDetail(context);
|
||||
// return true;
|
||||
// }
|
||||
public static void checkMonitor(Context context, ICheckResultCallBack checkResultCallBack) {
|
||||
Log.d(TAG, "checkMonitor");
|
||||
loadDetail(context, checkResultCallBack);
|
||||
}
|
||||
|
||||
// //网络请求,获取自车检测结果(工控机上报云端)
|
||||
// public static void loadDetail(Context context) {
|
||||
// final Map<String, Object> params = ParamsBuilder.of(false)
|
||||
// .append("sn", MoGoAiCloudClientConfig.getInstance().getSn())
|
||||
// .build();
|
||||
// CheckApiServiceFactory.getDataApiService(context).loadMonitorDetail(params)
|
||||
// .subscribeOn(Schedulers.io())
|
||||
// .observeOn(AndroidSchedulers.mainThread())
|
||||
// .subscribe(new SubscribeImpl<CheckResultData>(RequestOptions.create(context)) {
|
||||
// @Override
|
||||
// public void onSuccess(CheckResultData o) {
|
||||
// super.onSuccess(o);
|
||||
// Log.d(TAG, "车辆自检结果是:" + o.toString());
|
||||
// ThreadUtils.runOnUiThread(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// if (o != null && mCheckAdapter != null) {
|
||||
// mCheckAdapter.mCheckResultData = o;
|
||||
// mCheckAdapter.notifyDataSetChanged();
|
||||
// }
|
||||
//
|
||||
// if (((CheckResultData) o).getData().getVehicle().getState() == 1) {
|
||||
// CallerCheckManager.updateMonitoringStatus(MogoReceiver.ACTION_CHECK_VEHICLE_MONITORING, false);
|
||||
// } else {
|
||||
// CallerCheckManager.updateMonitoringStatus(MogoReceiver.ACTION_CHECK_VEHICLE_MONITORING, true);
|
||||
// showDialog(context);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onError(String message, int code) {
|
||||
// super.onError(message, code);
|
||||
// Log.d(TAG, "车辆自检失败,请稍后重试" + "==" + message + String.valueOf(code));
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// }
|
||||
//网络请求,获取自车检测结果(工控机上报云端)
|
||||
public static void loadDetail(Context context, ICheckResultCallBack checkResultCallBack) {
|
||||
final Map<String, Object> params = ParamsBuilder.of(false)
|
||||
.append("sn", MoGoAiCloudClientConfig.getInstance().getSn())
|
||||
.build();
|
||||
CheckApiServiceFactory.getDataApiService(context).loadMonitorDetail(params)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<CheckResultData>(RequestOptions.create(context)) {
|
||||
@Override
|
||||
public void onSuccess(CheckResultData o) {
|
||||
super.onSuccess(o);
|
||||
Log.d(TAG, "车辆自检结果是:" + o.toString());
|
||||
ThreadUtils.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (o != null && mCheckAdapter != null) {
|
||||
mCheckAdapter.mCheckResultData = o;
|
||||
mCheckAdapter.notifyDataSetChanged();
|
||||
}
|
||||
if (checkResultCallBack != null) {
|
||||
checkResultCallBack.callBackWithErrorState(o.getData().getVehicle().getState());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @param context
|
||||
* @return 当前应用的版本名称
|
||||
*/
|
||||
public synchronized String getPackageName(Context context) {
|
||||
try {
|
||||
PackageManager packageManager = context.getPackageManager();
|
||||
PackageInfo packageInfo = packageManager.getPackageInfo(
|
||||
context.getPackageName(), 0);
|
||||
Log.d(TAG, "包名:" + packageInfo.packageName);
|
||||
return packageInfo.packageName;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "com.mogo.launcher.f";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -279,29 +244,20 @@ public class CheckActivity extends AppCompatActivity {
|
||||
}
|
||||
}
|
||||
|
||||
// public static void start(Context context) {
|
||||
// Intent starter = new Intent(context, CheckActivity.class);
|
||||
// starter.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
// context.startActivity(starter);
|
||||
// }
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 指标异常弹框
|
||||
// */
|
||||
// public static void showDialog(Context context) {
|
||||
// try {
|
||||
// if (AppUtils.isAppRunning(getPackageName(context)) &&
|
||||
// (ActivityUtils.getTopActivity() instanceof CheckActivity == false)) {
|
||||
// if (dialog != null) {
|
||||
// dialog.cancel();
|
||||
// }
|
||||
// dialog = new CheckDialog(context, true);
|
||||
// dialog.show();
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestart() {
|
||||
super.onRestart();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
@@ -309,9 +265,4 @@ public class CheckActivity extends AppCompatActivity {
|
||||
isFront = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public interface ICheckProvider extends IProvider {
|
||||
/**
|
||||
* 指标监测
|
||||
*/
|
||||
boolean checkMonitor(Context context);
|
||||
void checkMonitor(Context context);
|
||||
|
||||
/**
|
||||
* 根据监测指标修改主页检测按钮
|
||||
|
||||
@@ -10,7 +10,7 @@ import com.mogo.eagle.core.function.call.base.CallerBase;
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
* @date 2021/9/17 8:26 下午
|
||||
*
|
||||
* <p>
|
||||
* HMI 调用者管理,这里对外及其他模块提供功能的调用,用啥写啥,不要过度设计,不允许直接将Provider暴露出去
|
||||
*/
|
||||
public class CallerCheckManager extends CallerBase {
|
||||
@@ -56,7 +56,7 @@ public class CallerCheckManager extends CallerBase {
|
||||
/**
|
||||
* 指标监测
|
||||
*/
|
||||
public static boolean checkMonitor(Context context) {
|
||||
return getCheckProvider().checkMonitor(context);
|
||||
public static void checkMonitor(Context context) {
|
||||
getCheckProvider().checkMonitor(context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,9 +60,9 @@ public class VehicleMonitoring implements Handler.Callback {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean vehicleMonitor() {
|
||||
public void vehicleMonitor() {
|
||||
Log.d(TAG, "vehicleMonitor");
|
||||
return CallerCheckManager.checkMonitor(mContext);
|
||||
CallerCheckManager.checkMonitor(mContext);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user