[fix]
[relase 释放回调、并判空]
This commit is contained in:
yangyakun
2024-07-11 12:06:38 +08:00
parent bd75be898a
commit d6d5b9650e

View File

@@ -43,6 +43,7 @@ public class NaviPresenter extends Presenter<TaxiRottingNaviFragment> implements
@Override
public void onDestroy( @NonNull LifecycleOwner owner ) {
releaseListeners();
super.onDestroy( owner );
}
@@ -54,24 +55,22 @@ public class NaviPresenter extends Presenter<TaxiRottingNaviFragment> implements
TaxiModel.getInstance().setMoGoAutopilotPlanningListener(null);
}
private void runOnUIThread( Runnable executor ) {
if ( executor == null ) {
return;
}
if ( Looper.myLooper() != Looper.getMainLooper() ) {
UiThreadHandler.post( executor );
} else {
executor.run();
}
}
@Override
public void setLineMarker(LatLng startStation, LatLng endStation) {
runOnUIThread(() -> mView.setLineMarker(startStation,endStation));
UiThreadHandler.post(new Runnable() {
@Override
public void run() {
if(mView!=null) {
mView.setLineMarker(startStation, endStation);
}
}
},UiThreadHandler.MODE.QUEUE);
}
@Override
public void routeResult(List<LatLng> routeArrivied, List<LatLng> routeArriving, MogoLocation location) {
mView.routeResult(routeArrivied,routeArriving,location);
if(mView!=null) {
mView.routeResult(routeArrivied, routeArriving, location);
}
}
}