opt och bus
This commit is contained in:
@@ -45,6 +45,7 @@ public class OchBusFragment extends BaseOchFragment<OchBusFragment, OchBusPresen
|
||||
rvStationList.setAdapter(adapter);
|
||||
rvStationList.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
|
||||
Logger.d(TAG, "initView: " + MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus());
|
||||
switch (MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus()) {
|
||||
case IMogoAdasOCHCallback.STATUS_AUTOPILOT_DISABLE:
|
||||
hideAutopilotBiz();
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.mogo.och.bus.presenter;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
|
||||
import com.mogo.commons.data.BaseData;
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.commons.network.SubscribeImpl;
|
||||
@@ -38,15 +41,18 @@ import static com.mogo.och.bus.constant.OchBusConst.STATION_STATUS_STOPED;
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class OchBusPresenter extends Presenter<OchBusFragment> implements IMogoAdasOCHCallback {
|
||||
public class OchBusPresenter extends Presenter<OchBusFragment> implements IMogoAdasOCHCallback, Handler.Callback {
|
||||
private static final String TAG = "OchBusPresenter";
|
||||
private static final int VEHICAL_TYPE = 10;
|
||||
|
||||
private static final int MSG_REQUERY_BUS_STATION = 1001;
|
||||
private static final long REQUERY_BUS_STATION_DELAY = 5000;
|
||||
public OchBusPresenter(OchBusFragment view) {
|
||||
super(view);
|
||||
MogoApisHandler.getInstance().getApis().getAdasControllerApi().addAdasOCHCallback(this);
|
||||
}
|
||||
|
||||
private final Handler handler = new Handler(this);
|
||||
|
||||
private final List<OchBusStation> stationList = new ArrayList<>();
|
||||
|
||||
private int currentStationIndex = 0;
|
||||
@@ -83,18 +89,20 @@ public class OchBusPresenter extends Presenter<OchBusFragment> implements IMogoA
|
||||
public void onError(Throwable e) {
|
||||
super.onError(e);
|
||||
Logger.e(TAG, e, "获取小巴路线图失败");
|
||||
if (mView != null) {
|
||||
mView.refreshBusStations(null);
|
||||
}
|
||||
requeryBusStation();
|
||||
// if (mView != null) {
|
||||
// mView.refreshBusStations(null);
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
Logger.e(TAG, "获取小巴路线失败 code: " + code + " msg: " + message);
|
||||
if (mView != null) {
|
||||
mView.refreshBusStations(null);
|
||||
}
|
||||
requeryBusStation();
|
||||
// if (mView != null) {
|
||||
// mView.refreshBusStations(null);
|
||||
// }
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -109,6 +117,10 @@ public class OchBusPresenter extends Presenter<OchBusFragment> implements IMogoA
|
||||
// }
|
||||
}
|
||||
|
||||
private void requeryBusStation(){
|
||||
handler.sendEmptyMessageDelayed(MSG_REQUERY_BUS_STATION, REQUERY_BUS_STATION_DELAY);
|
||||
}
|
||||
|
||||
public void restartAutopilot(){
|
||||
MogoApisHandler.getInstance().getApis().getAdasControllerApi().aiCloudToAdasData(currentAutopilot);
|
||||
}
|
||||
@@ -207,4 +219,13 @@ public class OchBusPresenter extends Presenter<OchBusFragment> implements IMogoA
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleMessage(Message msg) {
|
||||
if (msg.what == MSG_REQUERY_BUS_STATION) {
|
||||
queryBusRoutes();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,6 +93,9 @@ public abstract class BaseOchFragment<V extends IView, P extends Presenter<V>> e
|
||||
public void showSlidePanle(String text) {
|
||||
getActivity().runOnUiThread(()->{
|
||||
slidePanelView.setText(text);
|
||||
if (MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus() == IMogoAdasOCHCallback.STATUS_AUTOPILOT_DISABLE) {
|
||||
return;
|
||||
}
|
||||
slidePanelView.setVisibility(View.VISIBLE);
|
||||
});
|
||||
}
|
||||
@@ -106,6 +109,9 @@ public abstract class BaseOchFragment<V extends IView, P extends Presenter<V>> e
|
||||
public void showNotice(String notice) {
|
||||
getActivity().runOnUiThread(()->{
|
||||
tvNotice.setText(notice);
|
||||
if (MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus() == IMogoAdasOCHCallback.STATUS_AUTOPILOT_DISABLE) {
|
||||
return;
|
||||
}
|
||||
tvNotice.setVisibility(View.VISIBLE);
|
||||
fivNoticeHead.setVisibility(View.VISIBLE);
|
||||
fivNoticeHead.startAnim();
|
||||
|
||||
@@ -354,6 +354,7 @@ public class MogoADASController implements IMogoADASController {
|
||||
|
||||
@Override
|
||||
public void notifyAutopilotState(AdasAIDLAutopilotStateModel autopilotStateModel) {
|
||||
Logger.d(TAG, "notifyAutopilotState: " + autopilotStateModel);
|
||||
if (mAdasOCHCallback != null) {
|
||||
mAdasOCHCallback.onStateChanged(autopilotStateModel.getState(), autopilotStateModel.getReason());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user