对事件的处理进行异常包裹,保证程序不异常崩溃

appName=蘑菇出行
versionCode=8001873
sn=ZD802B1932L00622
versionName=8.0.7.1173
DISPLAY=K2101_ZD_S112101.20200521.21553235
appPackageName=com.mogo.launcher.app
TIME=1606470575675
fileName=debug-app-crash-com.mogo.launcher.app-2020-11-27-17-49-35.log
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Object[]
	at android.util.ArrayMap.allocArrays(ArrayMap.java:185)
	at android.util.ArrayMap.put(ArrayMap.java:444)
	at android.os.Bundle.putSerializable(Bundle.java:643)
	at android.content.Intent.putExtra(Intent.java:5866)
	at com.mogo.module.v2x.scenario.impl.V2XScenarioManager.lambda$handlerMessage$0$V2XScenarioManager(V2XScenarioManager.java:68)
	at com.mogo.module.v2x.scenario.impl.-$$Lambda$V2XScenarioManager$7EW5DB57RlPpJUn77fU606mlAJk.run(lambda)
	at com.mogo.module.v2x.utils.V2XUtils.runOnUiThread(V2XUtils.java:164)
	at com.mogo.module.v2x.scenario.impl.V2XScenarioManager.handlerMessage(V2XScenarioManager.java:61)
	at com.mogo.module.v2x.listener.V2XMessageListener_401005.lambda$handleSeekHelp$1(V2XMessageListener_401005.java:89)
	at com.mogo.module.v2x.listener.-$$Lambda$V2XMessageListener_401005$7Frk0OhryomEqYMaU1gKqg_o7N4.run(lambda)
	at android.os.Handler.handleCallback(Handler.java:733)
	at android.os.Handler.dispatchMessage(Handler.java:95)
	at android.os.Looper.loop(Looper.java:136)
	at android.app.ActivityThread.main(ActivityThread.java:5057)
	at java.lang.reflect.Method.invokeNative(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:515)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:676)
	at dalvik.system.NativeStart.main(Native Method)
This commit is contained in:
董宏宇
2020-11-30 12:13:12 +08:00
parent c6bdcc0eee
commit c9af523a75
2 changed files with 63 additions and 69 deletions

View File

@@ -1,11 +1,11 @@
package com.mogo.module.v2x.listener;
import com.mogo.module.v2x.V2XConst;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.entity.net.V2XSpecialCarRes.V2XMarkerEntity;
import com.mogo.module.v2x.entity.net.V2XSpecialCarRes;
import com.mogo.module.common.entity.V2XMessageEntity;
import com.mogo.module.common.entity.V2XPoiTypeEnum;
import com.mogo.module.v2x.V2XConst;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.entity.net.V2XSpecialCarRes;
import com.mogo.module.v2x.entity.net.V2XSpecialCarRes.V2XMarkerEntity;
import com.mogo.module.v2x.scenario.impl.V2XScenarioManager;
import com.mogo.module.v2x.utils.MarkerUtils;
import com.mogo.module.v2x.utils.V2XUtils;
@@ -64,24 +64,14 @@ public class V2XMessageListener_401005 implements IMogoOnMessageListener<V2XSpec
V2XServiceManager.getMarkerManager().removeMarkers(V2XConst.V2X_MARKER_SPECIAL_CAR);
List<V2XMarkerEntity> coordinates = message.getCoordinates();
List<V2XMarkerEntity> entityList = new ArrayList<>();
// 移除上一次的数据
//Context context = V2XServiceManager.getContext();
for (V2XMarkerEntity coordinate : coordinates) {
//故障车机
if (coordinate.getTargetId() == V2XPoiTypeEnum.ALERT_CAR_TROUBLE_WARNING) {
//V2XMarkerEntity.UserInfoBean userInfoBean = coordinate.getUserInfo();
//if (userInfoBean != null) {
entityList.add(coordinate);
//}
//绘制
//V2XServiceManager
// .getMoGoV2XMarkerManager()
// .drawableSpecialCarPOI(context, coordinate, V2XMarkerClickListener.getInstance());
}
}
if (!entityList.isEmpty()) {
//V2XUtils.runOnUiThread(() -> V2XServiceManager.getMoGoV2XScenarioManager().showOtherSeekHelpWindow(entityList));
V2XUtils.runOnUiThread(() -> {
V2XMessageEntity<List<V2XMarkerEntity>> v2XMessageEntity = new V2XMessageEntity<>();
v2XMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_SEEK_WARNING);

View File

@@ -56,66 +56,70 @@ public class V2XScenarioManager implements IV2XScenarioManager {
@Override
public void handlerMessage(V2XMessageEntity v2XMessageEntity) {
//Logger.d(MODULE_NAME, "处理V2X场景" + GsonUtil.jsonFromObject(v2XMessageEntity));
synchronized (V2XScenarioManager.class) {
// 展示
V2XUtils.runOnUiThread(() -> {
// 提取之前存储的场景
if (v2XMessageEntity != null) {
try {
synchronized (V2XScenarioManager.class) {
// 展示
V2XUtils.runOnUiThread(() -> {
// 提取之前存储的场景
if (v2XMessageEntity != null) {
// 广播给应用内部其它模块
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_ACTION);
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
LocalBroadcastManager.getInstance(V2XUtils.getApp()).sendBroadcast(intent);
// 广播给应用内部其它模块
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_ACTION);
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
LocalBroadcastManager.getInstance(V2XUtils.getApp()).sendBroadcast(intent);
mV2XScenario = mV2XScenarioSet.get(v2XMessageEntity.getType());
// 如果没有拿到之前的,根据类型分发
if (mV2XScenario == null) {
switch (v2XMessageEntity.getType()) {
case V2XMessageEntity.V2XTypeEnum.ALERT_ROAD_WARNING:
mV2XScenario = V2XRoadEventScenario.getInstance();
break;
case V2XMessageEntity.V2XTypeEnum.ALERT_SEEK_WARNING:
mV2XScenario = V2XSeekHelpScenario.getInstance();
break;
case V2XMessageEntity.V2XTypeEnum.ALERT_FATIGUE_DRIVING:
mV2XScenario = V2XFatigueDrivingScenario.getInstance();
break;
case V2XMessageEntity.V2XTypeEnum.ALERT_PUSH_WINDOW_WARNING:
mV2XScenario = V2XPushEventScenario.getInstance();
break;
case V2XMessageEntity.V2XTypeEnum.ALERT_PUSH_LIVE_CAR_WARNING:
mV2XScenario = V2XPushLiveCarScenario.getInstance();
break;
case V2XMessageEntity.V2XTypeEnum.ALERT_ANIMATION_WARNING:
mV2XScenario = V2XAnimationScenario.getInstance();
break;
case V2XMessageEntity.V2XTypeEnum.ALERT_CAR_FOR_HELP:
mV2XScenario = V2XCarForHelpScenario.getInstance();
break;
case V2XMessageEntity.V2XTypeEnum.ALERT_ILLEGAL_PARK_WARNING:
mV2XScenario = V2XIllegalParkScenario.getInstance();
break;
case V2XMessageEntity.V2XTypeEnum.ALERT_EVENT_UGC_WARNING:
mV2XScenario = V2XEventUgcScenario.getInstance();
break;
default:
Logger.e(MODULE_NAME, "当前V2X消息类型未定义。");
TipToast.tip("当前V2X消息类型未定义");
return;
mV2XScenario = mV2XScenarioSet.get(v2XMessageEntity.getType());
// 如果没有拿到之前的,根据类型分发
if (mV2XScenario == null) {
switch (v2XMessageEntity.getType()) {
case V2XMessageEntity.V2XTypeEnum.ALERT_ROAD_WARNING:
mV2XScenario = V2XRoadEventScenario.getInstance();
break;
case V2XMessageEntity.V2XTypeEnum.ALERT_SEEK_WARNING:
mV2XScenario = V2XSeekHelpScenario.getInstance();
break;
case V2XMessageEntity.V2XTypeEnum.ALERT_FATIGUE_DRIVING:
mV2XScenario = V2XFatigueDrivingScenario.getInstance();
break;
case V2XMessageEntity.V2XTypeEnum.ALERT_PUSH_WINDOW_WARNING:
mV2XScenario = V2XPushEventScenario.getInstance();
break;
case V2XMessageEntity.V2XTypeEnum.ALERT_PUSH_LIVE_CAR_WARNING:
mV2XScenario = V2XPushLiveCarScenario.getInstance();
break;
case V2XMessageEntity.V2XTypeEnum.ALERT_ANIMATION_WARNING:
mV2XScenario = V2XAnimationScenario.getInstance();
break;
case V2XMessageEntity.V2XTypeEnum.ALERT_CAR_FOR_HELP:
mV2XScenario = V2XCarForHelpScenario.getInstance();
break;
case V2XMessageEntity.V2XTypeEnum.ALERT_ILLEGAL_PARK_WARNING:
mV2XScenario = V2XIllegalParkScenario.getInstance();
break;
case V2XMessageEntity.V2XTypeEnum.ALERT_EVENT_UGC_WARNING:
mV2XScenario = V2XEventUgcScenario.getInstance();
break;
default:
Logger.e(MODULE_NAME, "当前V2X消息类型未定义。");
TipToast.tip("当前V2X消息类型未定义");
return;
}
}
// 展示最新的消息
if (mV2XScenario != null) {
if (v2XMessageEntity.getType() != V2XMessageEntity.V2XTypeEnum.ALERT_CAR_FOR_HELP) {
hidOtherPanel();
}
mV2XScenario.init(v2XMessageEntity);
mV2XScenarioSet.put(v2XMessageEntity.getType(), mV2XScenario);
}
}
// 展示最新的消息
if (mV2XScenario != null) {
if (v2XMessageEntity.getType() != V2XMessageEntity.V2XTypeEnum.ALERT_CAR_FOR_HELP) {
hidOtherPanel();
}
mV2XScenario.init(v2XMessageEntity);
mV2XScenarioSet.put(v2XMessageEntity.getType(), mV2XScenario);
}
}
});
});
}
} catch (Exception e) {
e.printStackTrace();
}
}