diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/BusLinePresenter.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/BusLinePresenter.java index b4c4446589..04bf358f4e 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/BusLinePresenter.java +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/BusLinePresenter.java @@ -1,9 +1,12 @@ package com.mogo.och.bus.presenter; +import android.os.Looper; + import androidx.annotation.NonNull; import androidx.lifecycle.LifecycleOwner; import com.mogo.commons.mvp.Presenter; +import com.mogo.eagle.core.utilcode.util.UiThreadHandler; import com.mogo.och.bus.bean.BusQueryLinesResponse; import com.mogo.och.bus.callback.IBusLinesCallback; import com.mogo.och.bus.ui.BusSwitchLineView; @@ -30,14 +33,25 @@ public class BusLinePresenter extends Presenter implements IB BusLineModel.getInstance().setBusLinesCallback(this); } + private void runOnUIThread( Runnable executor ) { + if ( executor == null ) { + return; + } + if ( Looper.myLooper() != Looper.getMainLooper() ) { + UiThreadHandler.post( executor ); + } else { + executor.run(); + } + } + @Override public void onBusLinesChange(BusQueryLinesResponse lines) { - mView.onBusLinesChange(lines); + runOnUIThread(() -> mView.onBusLinesChange(lines)); } @Override public void onChangeLineIdSuccess() { - mView.onChangeLineIdSuccess(); + runOnUIThread(() -> mView.onChangeLineIdSuccess()); } public void queryBusLines(){ diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/BusPresenter.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/BusPresenter.java index 550af083d5..8c2f855e50 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/BusPresenter.java +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/BusPresenter.java @@ -107,7 +107,7 @@ public class BusPresenter extends Presenter @Override public void changeOperationStatus(boolean changeStatus) { if (mView != null) { - mView.changeOperationStatus(changeStatus); + runOnUIThread(() -> mView.changeOperationStatus(changeStatus)); } } @@ -119,29 +119,26 @@ public class BusPresenter extends Presenter functionDemoModeChange(); CallerLogger.INSTANCE.d(M_BUS + "BusOrderModel =", " mCurrentStation =" + mCurrentStation); if (mView != null) { - mView.refreshBusStations(stationList, currentStation, nextStation, isArrived); + runOnUIThread(() -> mView.refreshBusStations( + stationList, currentStation, nextStation, isArrived)); } } private void functionDemoModeChange() { // CallerLogger.INSTANCE.d(M_BUS + "BusOrderModel ="," functionDemoModeChange ="+mCurrentStation); if (FunctionBuildConfig.isDemoMode - && ( - (mCurrentStation > 0 && mCurrentStation < mStationList.size() - 1) - || ( - (mCurrentStation == 0 || mCurrentStation == mStationList.size() - 1) - && BusOrderModel.getInstance().isGoingToNextStation() - ) - ) - ) { - mView.onAutopilotStatusChanged(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING, false); + && ((mCurrentStation > 0 && mCurrentStation < mStationList.size() - 1) + || ((mCurrentStation == 0 || mCurrentStation == mStationList.size() - 1) + && BusOrderModel.getInstance().isGoingToNextStation()))) { + runOnUIThread(() -> mView.onAutopilotStatusChanged( + IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING, false)); } } @Override public void hideSlidePanel() { if (mView != null) { - mView.hideSlidePanel(); + runOnUIThread(() -> mView.hideSlidePanel()); } } @@ -168,9 +165,9 @@ public class BusPresenter extends Presenter } currentAutopilotStatus = IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE; // 设置UI【自动驾驶】按钮是否展示 - mView.onAutopilotEnableChange(true); + runOnUIThread(() -> mView.onAutopilotEnableChange(true)); if (BusOrderModel.getInstance().isGoingToNextStation()) { - mView.hideSlidePanel(); + runOnUIThread(() -> mView.hideSlidePanel()); } if (FunctionBuildConfig.isDemoMode && ( @@ -185,7 +182,7 @@ public class BusPresenter extends Presenter return; } // 改变UI自动驾驶状态 - mView.onAutopilotStatusChanged(currentAutopilotStatus, isAnimateRunning); + runOnUIThread(() -> mView.onAutopilotStatusChanged(currentAutopilotStatus, isAnimateRunning)); } break; case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING: @@ -193,7 +190,7 @@ public class BusPresenter extends Presenter if (currentAutopilotStatus != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) { currentAutopilotStatus = IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING; // 改变UI自动驾驶状态 - mView.onAutopilotStatusChanged(currentAutopilotStatus, isAnimateRunning); + runOnUIThread(() -> mView.onAutopilotStatusChanged(currentAutopilotStatus, isAnimateRunning)); BusOrderModel.getInstance().triggerStartServiceEvent(true); } isAnimateRunning = false; @@ -216,13 +213,15 @@ public class BusPresenter extends Presenter CallerLogger.INSTANCE.d(M_BUS + "BusOrderModel=", "有美化功能"); return; } - mView.onAutopilotEnableChange(false); - mView.onAutopilotStatusChanged(currentAutopilotStatus, isAnimateRunning); + runOnUIThread(() -> { + mView.onAutopilotEnableChange(false); + mView.onAutopilotStatusChanged(currentAutopilotStatus, isAnimateRunning); + }); } isAnimateRunning = false; break; default: - mView.onAutopilotEnableChange(false); + runOnUIThread(() -> mView.onAutopilotEnableChange(false)); break; } } diff --git a/OCH/mogo-och-taxi-passenger/src/main/java/com/mogo/och/taxi/passenger/presenter/BaseTaxiPassengerPresenter.java b/OCH/mogo-och-taxi-passenger/src/main/java/com/mogo/och/taxi/passenger/presenter/BaseTaxiPassengerPresenter.java index 3b670315d9..92f9623830 100644 --- a/OCH/mogo-och-taxi-passenger/src/main/java/com/mogo/och/taxi/passenger/presenter/BaseTaxiPassengerPresenter.java +++ b/OCH/mogo-och-taxi-passenger/src/main/java/com/mogo/och/taxi/passenger/presenter/BaseTaxiPassengerPresenter.java @@ -94,17 +94,20 @@ public class BaseTaxiPassengerPresenter extends Presenter mView.onAutopilotStatusChanged( + IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE)); } @Override public void onAutopilotDisable() { - mView.onAutopilotStatusChanged(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE); + runOnUIThread(() -> mView.onAutopilotStatusChanged( + IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE)); } @Override public void onAutopilotRunning() { - mView.onAutopilotStatusChanged(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING); + runOnUIThread(() -> mView.onAutopilotStatusChanged( + IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING)); } @Override @@ -141,25 +144,29 @@ public class BaseTaxiPassengerPresenter extends Presenter { + mView.showOrHideServingOrderFragment(false); + mView.showOrHideArrivedEndLayout(false, ""); + }); mCurrentPassengerOrder = null; return; } diff --git a/OCH/mogo-och-taxi/src/main/java/com/mogo/och/taxi/presenter/TaxiPresenter.java b/OCH/mogo-och-taxi/src/main/java/com/mogo/och/taxi/presenter/TaxiPresenter.java index 7c15f98ab6..b002924cab 100644 --- a/OCH/mogo-och-taxi/src/main/java/com/mogo/och/taxi/presenter/TaxiPresenter.java +++ b/OCH/mogo-och-taxi/src/main/java/com/mogo/och/taxi/presenter/TaxiPresenter.java @@ -149,27 +149,30 @@ public class TaxiPresenter extends Presenter implements ITaxiADASS @Override public void onAutopilotEnable() { - mView.updateAutopilotStatus(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE); + runOnUIThread(() -> mView.updateAutopilotStatus( + IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE)); } @Override public void onAutopilotDisable() { - mView.updateAutopilotStatus(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE); + runOnUIThread(() -> mView.updateAutopilotStatus( + IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE)); } @Override public void onAutopilotRunning() { - mView.updateAutopilotStatus(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING); + runOnUIThread(() -> mView.updateAutopilotStatus( + IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING)); } @Override public void onCarStatusChanged(boolean inOperation, String role) { - mView.updateOperationStatus(inOperation,role); + runOnUIThread(() -> mView.updateOperationStatus(inOperation,role)); } @Override public void onServiceDataUpdate(long dailyTimeDuration, long dailyOrderNum) { - mView.onServiceDataUpdate(dailyTimeDuration,dailyOrderNum); + runOnUIThread(() -> mView.onServiceDataUpdate(dailyTimeDuration,dailyOrderNum)); } @Override @@ -179,7 +182,7 @@ public class TaxiPresenter extends Presenter implements ITaxiADASS @Override public void onOrdersWaitServiceChanged(@NonNull @NotNull List waitServiceList) { - mView.onOrdersWaitServiceChanged(waitServiceList); + runOnUIThread(() -> mView.onOrdersWaitServiceChanged(waitServiceList)); } @RequiresApi(api = Build.VERSION_CODES.P) @@ -194,57 +197,57 @@ public class TaxiPresenter extends Presenter implements ITaxiADASS TaxiOrderStatusEnum.JourneyCompleted.getCode() == order.orderStatus){ TaxiModel.getInstance().startOrStopCalculateRouteInfo(false); } - mView.updateCurrentOrderStatusChanged(order); + runOnUIThread(() -> mView.updateCurrentOrderStatusChanged(order)); } @Override public void onCurrentOrderCancelDone() { - mView.onCurrentOrderCancelDone(); + runOnUIThread(() -> mView.onCurrentOrderCancelDone()); } @Override public void onOrderCancelDone(String orderNo) { - mView.onOrderCancelDone(orderNo); + runOnUIThread(() -> mView.onOrderCancelDone(orderNo)); } @Override public void onCurrentOrderRouteInfoGot(OrderQueryRouteInfoRespBean.Result routeInfo) { - mView.onCurrentOrderRouteInfoGot(routeInfo); + runOnUIThread(() -> mView.onCurrentOrderRouteInfoGot(routeInfo)); } @Override public void onCurrentOrderDistToStartChanged(long meters, long timeInSecond) { - mView.onCurrentOrderDistToStartChanged(meters,timeInSecond); + runOnUIThread(() -> mView.onCurrentOrderDistToStartChanged(meters,timeInSecond)); } @Override public void onCurrentOrderDistToEndChanged(long meters, long timeInSecond) { - mView.onCurrentOrderDistToEndChanged(meters,timeInSecond); + runOnUIThread(() -> mView.onCurrentOrderDistToEndChanged(meters,timeInSecond)); } @Override public void onOrdersListPageRefresh(List ordersList) { - mView.onOrdersListPageRefresh(ordersList); + runOnUIThread(() -> mView.onOrdersListPageRefresh(ordersList)); } @Override public void onNewBookingOrderGot(OrderQueryRespBean.Result order) { - mView.onNewBookingOrderGot(order); + runOnUIThread(() -> mView.onNewBookingOrderGot(order)); } @Override public void onGrabOrderExecuteDone() { - mView.onGrabOrderExecuteDone(); + runOnUIThread(() -> mView.onGrabOrderExecuteDone()); } @Override public void onGrabOrderSuccess(OrderQueryRespBean.Result order) { - mView.onGrabOrderSuccess(order); + runOnUIThread(() -> mView.onGrabOrderSuccess(order)); } @Override public void onGrabOrderFailed(OrderQueryRespBean.Result order) { - mView.onGrabOrderFailed(order); + runOnUIThread(() -> mView.onGrabOrderFailed(order)); } @Override @@ -255,8 +258,10 @@ public class TaxiPresenter extends Presenter implements ITaxiADASS @Override public void onCarLocationChanged(Location location) { if (null != location){ - runOnUIThread(() -> mView.updateSpeedView(location.getSpeed())); - mView.updateLocation(location.getLatitude(),location.getLongitude()); + runOnUIThread(() -> { + mView.updateSpeedView(location.getSpeed()); + mView.updateLocation(location.getLatitude(),location.getLongitude()); + }); } } // @Override