[6.4.0]
[mView使用前判空]
This commit is contained in:
@@ -62,7 +62,14 @@ public class BusLinePresenter extends Presenter<BusSwitchLineView> implements IB
|
||||
@Override
|
||||
public void onChangeLineIdSuccess() {
|
||||
OrderModel.getInstance().clearBusStationDatas();
|
||||
runOnUIThread(() -> mView.onChangeLineIdSuccess());
|
||||
UiThreadHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if(mView!=null) {
|
||||
mView.onChangeLineIdSuccess();
|
||||
}
|
||||
}
|
||||
}, UiThreadHandler.MODE.QUEUE);
|
||||
}
|
||||
|
||||
public void queryBusLines(){
|
||||
@@ -105,6 +112,8 @@ public class BusLinePresenter extends Presenter<BusSwitchLineView> implements IB
|
||||
|
||||
@Override
|
||||
public void onBusLineTasks(BusQueryLineTaskResponse o, int position,boolean autoRefresh) {
|
||||
mView.onBusLineTasks(o,position,autoRefresh);
|
||||
if(mView!=null) {
|
||||
mView.onBusLineTasks(o,position,autoRefresh);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,8 +84,8 @@ public class BusPresenter extends Presenter<BusFragment>
|
||||
OrderModel.getInstance().setControllerStatusCallback(this);
|
||||
OrderModel.getInstance().setPassengerCallback(this);
|
||||
OrderModel.getInstance().setAdasStatusCallback(this);
|
||||
OchAutoPilotStatusListenerManager.INSTANCE.addListener(TAG,this);
|
||||
LoginStatusManager.INSTANCE.addListener(TAG,this);
|
||||
OchAutoPilotStatusListenerManager.INSTANCE.addListener(TAG, this);
|
||||
LoginStatusManager.INSTANCE.addListener(TAG, this);
|
||||
}
|
||||
|
||||
public void releaseListener() {
|
||||
@@ -108,7 +108,7 @@ public class BusPresenter extends Presenter<BusFragment>
|
||||
}
|
||||
|
||||
public void restartAutopilot() {
|
||||
if (OrderModel.getInstance().isGoingToNextStation()){
|
||||
if (OrderModel.getInstance().isGoingToNextStation()) {
|
||||
OrderModel.getInstance().restartAutopilot();
|
||||
}
|
||||
}
|
||||
@@ -119,32 +119,51 @@ public class BusPresenter extends Presenter<BusFragment>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBusTaskStatus(String lineName,String lineTime,
|
||||
public void updateBusTaskStatus(String lineName, String lineTime,
|
||||
List<BusStationBean> stationList,
|
||||
int arrivingOrArrivedIndex,
|
||||
boolean isArrived) {
|
||||
mStationList.clear();
|
||||
mStationList.addAll(stationList);
|
||||
if (arrivingOrArrivedIndex == 0 || isArrived){
|
||||
if (arrivingOrArrivedIndex == 0 || isArrived) {
|
||||
mCurrentStation = arrivingOrArrivedIndex;
|
||||
}else {
|
||||
mCurrentStation = arrivingOrArrivedIndex -1;
|
||||
} else {
|
||||
mCurrentStation = arrivingOrArrivedIndex - 1;
|
||||
}
|
||||
CallerLogger.d(M_BUS + "BusOrderModel =", " mCurrentStation =" + mCurrentStation);
|
||||
if (mView != null) {
|
||||
runOnUIThread(() -> mView.updateBusTaskStatus(lineName,lineTime,
|
||||
stationList, arrivingOrArrivedIndex, isArrived));
|
||||
}
|
||||
UiThreadHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mView != null) {
|
||||
mView.updateBusTaskStatus(lineName, lineTime,
|
||||
stationList, arrivingOrArrivedIndex, isArrived);
|
||||
}
|
||||
}
|
||||
}, UiThreadHandler.MODE.QUEUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEmptyUi() {
|
||||
runOnUIThread(() -> mView.updateLineEmptyUI());
|
||||
UiThreadHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mView != null) {
|
||||
mView.updateLineEmptyUI();
|
||||
}
|
||||
}
|
||||
}, UiThreadHandler.MODE.QUEUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearBusStationsMarkers() {
|
||||
runOnUIThread(() -> mView.clearBusStationsMarkers());
|
||||
UiThreadHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mView != null) {
|
||||
mView.clearBusStationsMarkers();
|
||||
}
|
||||
}
|
||||
}, UiThreadHandler.MODE.QUEUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -157,12 +176,12 @@ public class BusPresenter extends Presenter<BusFragment>
|
||||
|
||||
@Override
|
||||
public void onAutopilotArriveAtStation(ArrivedStation arrivedStation) {
|
||||
CallerLogger.e( M_BUS + TAG, "行程日志-onAutopilotArriveAtStation arrive");
|
||||
arriveStation(arrivedStation,"底盘触发进站");
|
||||
CallerLogger.e(M_BUS + TAG, "行程日志-onAutopilotArriveAtStation arrive");
|
||||
arriveStation(arrivedStation, "底盘触发进站");
|
||||
}
|
||||
|
||||
public void arriveStation(ArrivedStation arrivedStation,String type){
|
||||
OrderModel.getInstance().onArriveAt(arrivedStation,type);
|
||||
public void arriveStation(ArrivedStation arrivedStation, String type) {
|
||||
OrderModel.getInstance().onArriveAt(arrivedStation, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -186,16 +205,37 @@ public class BusPresenter extends Presenter<BusFragment>
|
||||
return;
|
||||
}
|
||||
// 改变UI自动驾驶状态
|
||||
runOnUIThread(() -> mView.onAutopilotStatusChanged(state, CallerAutoPilotControlManager.INSTANCE.isCanStartAutopilot(false, 0)));
|
||||
UiThreadHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mView != null) {
|
||||
mView.onAutopilotStatusChanged(state, CallerAutoPilotControlManager.INSTANCE.isCanStartAutopilot(false, 0));
|
||||
}
|
||||
}
|
||||
}, UiThreadHandler.MODE.QUEUE);
|
||||
break;
|
||||
case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING:
|
||||
OrderModel.getInstance().triggerStartServiceEvent(
|
||||
OrderModel.getInstance().isRestartAutopilot(), true);
|
||||
OrderModel.getInstance().isRestartAutopilot(), true);
|
||||
// 改变UI自动驾驶状态
|
||||
runOnUIThread(() -> mView.onAutopilotStatusChanged(state, CallerAutoPilotControlManager.INSTANCE.isCanStartAutopilot(false, 0)));
|
||||
UiThreadHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mView != null) {
|
||||
mView.onAutopilotStatusChanged(state, CallerAutoPilotControlManager.INSTANCE.isCanStartAutopilot(false, 0));
|
||||
}
|
||||
}
|
||||
}, UiThreadHandler.MODE.QUEUE);
|
||||
break;
|
||||
default:
|
||||
runOnUIThread(() -> mView.onAutopilotEnableChange(false));
|
||||
UiThreadHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mView != null) {
|
||||
mView.onAutopilotEnableChange(false);
|
||||
}
|
||||
}
|
||||
}, UiThreadHandler.MODE.QUEUE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -208,26 +248,22 @@ public class BusPresenter extends Presenter<BusFragment>
|
||||
@Override
|
||||
public void startOpenAutopilot() {
|
||||
//非美化模式下启动动画
|
||||
runOnUIThread(() -> mView.startAutopilotAnimation());
|
||||
UiThreadHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mView != null) {
|
||||
mView.startAutopilotAnimation();
|
||||
}
|
||||
}
|
||||
}, UiThreadHandler.MODE.QUEUE);
|
||||
|
||||
//中间站点再次开启自驾时, 自动驾驶状态是2未改变, 此次鹰眼底层不再返给业务,需优化按钮动画显示
|
||||
if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING
|
||||
== CallerAutoPilotStatusListenerManager.INSTANCE.getState()){
|
||||
== CallerAutoPilotStatusListenerManager.INSTANCE.getState() && mView != null) {
|
||||
mView.onAutopilotStatusChanged(CallerAutoPilotStatusListenerManager.INSTANCE.getState(), CallerAutoPilotControlManager.INSTANCE.isCanStartAutopilot(false, 0));
|
||||
}
|
||||
}
|
||||
|
||||
private void runOnUIThread(Runnable executor) {
|
||||
if (executor == null) {
|
||||
return;
|
||||
}
|
||||
if (Looper.myLooper() != Looper.getMainLooper()) {
|
||||
UiThreadHandler.post(executor);
|
||||
} else {
|
||||
executor.run();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试使用
|
||||
*/
|
||||
@@ -238,22 +274,24 @@ public class BusPresenter extends Presenter<BusFragment>
|
||||
|
||||
@Override
|
||||
public void onAutopilotGuardian(@Nullable MogoReportMsg.MogoReportMessage guardianInfo, long lineId) {
|
||||
BusTrajectoryManager.getInstance().onAutopilotGuardian(guardianInfo,lineId);
|
||||
BusTrajectoryManager.getInstance().onAutopilotGuardian(guardianInfo, lineId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onStatusChange(LoginStatusEnum currentStatus) {
|
||||
CallerLogger.d(M_BUS + TAG, " loginStatus =" + LoginStatusManager.isLogin());
|
||||
if(LoginStatusManager.isLogin()){
|
||||
if (LoginStatusManager.isLogin()) {
|
||||
OrderModel.getInstance().startOrStopOrderLoop(true);
|
||||
OrderModel.getInstance().queryBusRoutes();
|
||||
}else {
|
||||
} else {
|
||||
BusTrajectoryManager.getInstance().stopTrajReqLoop();
|
||||
OrderModel.getInstance().startOrStopOrderLoop(false);
|
||||
BusTrajectoryManager.getInstance().stopTrajReqLoop();
|
||||
clearBusStationsMarkers();
|
||||
mView.hideSlidePanel();
|
||||
if(mView!=null) {
|
||||
mView.hideSlidePanel();
|
||||
}
|
||||
OrderModel.getInstance().closeBeautificationMode();
|
||||
}
|
||||
}
|
||||
@@ -261,9 +299,9 @@ public class BusPresenter extends Presenter<BusFragment>
|
||||
@Override
|
||||
public void playPassenger(WriteOffPassenger passenger) {
|
||||
int passengerNum = passenger.passengerSize;
|
||||
if (passengerNum > 1){ //多人播报 "x人" ---》x人核验通过
|
||||
OrderModel.getInstance().sendWriteOffNumToClient(passengerNum+"人核验通过");
|
||||
}else { //是 1 播放 "滴" 2022.11.09 改为: "核验通过"
|
||||
if (passengerNum > 1) { //多人播报 "x人" ---》x人核验通过
|
||||
OrderModel.getInstance().sendWriteOffNumToClient(passengerNum + "人核验通过");
|
||||
} else { //是 1 播放 "滴" 2022.11.09 改为: "核验通过"
|
||||
// mView.playDI();
|
||||
OrderModel.getInstance().sendWriteOffNumToClient("核验通过");
|
||||
}
|
||||
@@ -272,11 +310,20 @@ public class BusPresenter extends Presenter<BusFragment>
|
||||
|
||||
@Override
|
||||
public void onStartAdasFailure() {
|
||||
runOnUIThread(() -> mView.stopAnimAndUpdateBtnStatus());
|
||||
UiThreadHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if(mView!=null) {
|
||||
mView.stopAnimAndUpdateBtnStatus();
|
||||
}
|
||||
}
|
||||
}, UiThreadHandler.MODE.QUEUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void canStartAutopilot(boolean canStart) {
|
||||
mView.onAutopilotStatusChanged(CallerAutoPilotStatusListenerManager.INSTANCE.getState(), canStart);
|
||||
if(mView!=null) {
|
||||
mView.onAutopilotStatusChanged(CallerAutoPilotStatusListenerManager.INSTANCE.getState(), canStart);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user