eagle 调整checkactivity逻辑
This commit is contained in:
@@ -1,19 +1,38 @@
|
||||
package com.mogo.eagle.core.function.check;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.util.Log;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
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.net.CheckApiServiceFactory;
|
||||
import com.mogo.eagle.core.function.check.net.CheckResultData;
|
||||
import com.mogo.eagle.core.function.check.view.CheckDialog;
|
||||
import com.mogo.eagle.core.utilcode.util.ActivityUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.AppUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.LogUtils;
|
||||
import com.mogo.eagle.core.function.api.check.IMogoCheckListener;
|
||||
import com.mogo.eagle.core.function.check.view.CheckActivity;
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils;
|
||||
import com.mogo.module.service.receiver.MogoReceiver;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.eagle.core.function.api.check.ICheckProvider;
|
||||
import com.mogo.utils.network.RequestOptions;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
|
||||
/**
|
||||
* 鹰眼系统、自动驾驶系统 检测模块
|
||||
@@ -56,25 +75,111 @@ public class VehicleMonitoringManager implements ICheckProvider {
|
||||
|
||||
@Override
|
||||
public void startCheckActivity(Context context) {
|
||||
if (context != null) {
|
||||
CheckActivity.start(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);
|
||||
}
|
||||
// if (context != null) {
|
||||
// CheckActivity.showDialog(context);
|
||||
// }
|
||||
showDialog(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkMonitor(Context context) {
|
||||
if (context != null) {
|
||||
return CheckActivity.checkMonitor(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);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
@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;
|
||||
/**
|
||||
* 指标异常弹框
|
||||
*/
|
||||
public 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();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param context
|
||||
* @return 当前应用的版本名称
|
||||
*/
|
||||
public static 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";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMonitoringStatus(String module, boolean hasError) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.mogo.eagle.core.function.check.net;
|
||||
|
||||
import com.mogo.commons.data.BaseData;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -38,7 +39,7 @@ public class CheckResultData extends BaseData {
|
||||
'}';
|
||||
}
|
||||
|
||||
public static class Data {
|
||||
public static class Data implements Serializable{
|
||||
private Vehicle vehicle;
|
||||
private List<CheckListItem> soft;
|
||||
private List<CheckListItem> devices;
|
||||
@@ -97,7 +98,7 @@ public class CheckResultData extends BaseData {
|
||||
}
|
||||
}
|
||||
|
||||
public static class Vehicle {
|
||||
public static class Vehicle implements Serializable {
|
||||
private String id;
|
||||
private String sn;
|
||||
private String vin;
|
||||
@@ -236,7 +237,7 @@ public class CheckResultData extends BaseData {
|
||||
}
|
||||
}
|
||||
|
||||
public static class CheckListItem {
|
||||
public static class CheckListItem implements Serializable{
|
||||
private String name;
|
||||
private String stateValue;
|
||||
private List<CheckResultData.CheckListItem> items;
|
||||
|
||||
@@ -85,7 +85,17 @@ public class CheckActivity extends AppCompatActivity {
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
loadDetail(context);
|
||||
// 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{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,57 +128,57 @@ public class CheckActivity extends AppCompatActivity {
|
||||
/**
|
||||
* 自动驾驶状态下指标监测
|
||||
*/
|
||||
public static boolean checkMonitor(Context context) {
|
||||
Log.d(TAG, "checkMonitor");
|
||||
loadDetail(context);
|
||||
return true;
|
||||
}
|
||||
// public static boolean checkMonitor(Context context) {
|
||||
// Log.d(TAG, "checkMonitor");
|
||||
// loadDetail(context);
|
||||
// return true;
|
||||
// }
|
||||
|
||||
//网络请求,获取自车检测结果(工控机上报云端)
|
||||
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) {
|
||||
// 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));
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// }
|
||||
|
||||
/**
|
||||
* @param context
|
||||
* @return 当前应用的版本名称
|
||||
*/
|
||||
public static synchronized String getPackageName(Context context) {
|
||||
public synchronized String getPackageName(Context context) {
|
||||
try {
|
||||
PackageManager packageManager = context.getPackageManager();
|
||||
PackageInfo packageInfo = packageManager.getPackageInfo(
|
||||
@@ -269,29 +279,29 @@ 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);
|
||||
}
|
||||
// public static void start(Context context) {
|
||||
// Intent starter = new Intent(context, CheckActivity.class);
|
||||
// starter.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
// context.startActivity(starter);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 指标异常弹框
|
||||
*/
|
||||
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();
|
||||
}
|
||||
}
|
||||
// /**
|
||||
// * 指标异常弹框
|
||||
// */
|
||||
// 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 onDestroy() {
|
||||
|
||||
Reference in New Issue
Block a user