fix bug of thread problerm
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package com.mogo.module.adas;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
|
||||
import com.mogo.module.adas.entity.AdasAutoPilotLocReceiverBean;
|
||||
import com.mogo.module.adas.model.AdasServiceModel;
|
||||
@@ -28,6 +30,7 @@ public class AdasAutoPilotManager implements IMogoOnMessageListener<AdasAutoPilo
|
||||
private static volatile AdasAutoPilotManager instance;
|
||||
private static final byte[] obj = new byte[0];
|
||||
private static final int MSG_SOCKET_TYPE = 501000;
|
||||
private static final int MSG_TYPE_SHOW_DIALOG = 0;
|
||||
|
||||
private DispatchRemindDialog dispatchRemindDialog;
|
||||
|
||||
@@ -46,6 +49,17 @@ public class AdasAutoPilotManager implements IMogoOnMessageListener<AdasAutoPilo
|
||||
return instance;
|
||||
}
|
||||
|
||||
private final Handler handler = new Handler(){
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
if(msg.what == MSG_TYPE_SHOW_DIALOG){
|
||||
AdasAutoPilotLocReceiverBean msgData = (AdasAutoPilotLocReceiverBean) msg.obj;
|
||||
dispatchRemindDialog.showDialog(msgData.getPoiAddress());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public void initSocket(Context context) {
|
||||
MogoApisHandler.getInstance()
|
||||
.getApis()
|
||||
@@ -64,12 +78,17 @@ public class AdasAutoPilotManager implements IMogoOnMessageListener<AdasAutoPilo
|
||||
public void onMsgReceived(AdasAutoPilotLocReceiverBean adasAutoPilotLocReceiverBean) {
|
||||
if (adasAutoPilotLocReceiverBean != null
|
||||
&& adasAutoPilotLocReceiverBean.getLat() != 0.0
|
||||
&& adasAutoPilotLocReceiverBean.getLon() != 0.0) {
|
||||
if (AdasEventManager.getInstance().getAutopilotValuesStatus().getPilotmode() == 1) {
|
||||
&& adasAutoPilotLocReceiverBean.getLon() != 0.0
|
||||
&& adasAutoPilotLocReceiverBean.getPoiAddress() != null) {
|
||||
if (AdasEventManager.getInstance().getAutopilotValuesStatus()!=null &&
|
||||
AdasEventManager.getInstance().getAutopilotValuesStatus().getPilotmode() == 1) {
|
||||
Logger.d(TAG, "onMsgReceived 接收到服务端调度信息,但现在已经在自动驾驶状态,下发重复 略过");
|
||||
return;
|
||||
}
|
||||
dispatchRemindDialog.showDialog(adasAutoPilotLocReceiverBean.getPoiAddress());
|
||||
Message message = new Message();
|
||||
message.what = MSG_TYPE_SHOW_DIALOG;
|
||||
message.obj = adasAutoPilotLocReceiverBean;
|
||||
handler.sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +100,7 @@ public class AdasAutoPilotManager implements IMogoOnMessageListener<AdasAutoPilo
|
||||
@Override
|
||||
public void autopilotRoute(AutopilotRoute autopilotRoute) {
|
||||
AdasServiceModel.getInstance().uploadAutopilotRoute(autopilotRoute.getModels());
|
||||
//todo 划线
|
||||
//todo 画线
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user