增加取消自动驾驶接口
This commit is contained in:
1
.idea/gradle.xml
generated
1
.idea/gradle.xml
generated
@@ -89,6 +89,7 @@
|
||||
</set>
|
||||
</option>
|
||||
<option name="resolveModulePerSourceSet" value="false" />
|
||||
<option name="useQualifiedModuleNames" value="true" />
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
|
||||
@@ -108,17 +108,19 @@ public class OchBusFragment extends BaseOchFragment<OchBusFragment, OchBusPresen
|
||||
tvStationName.setText(station.getSiteName());
|
||||
tvStationNotice.setText("下一站");
|
||||
currPos = i;
|
||||
onAutopilotStatusChanged(true);
|
||||
// onAutopilotStatusChanged(true);
|
||||
break;
|
||||
} else if (station.getIsCurrentSite() == OchBusConst.STATION_STATUS_STOPED) {
|
||||
currPos = i;
|
||||
tvStationNotice.setText("当前车站");
|
||||
tvStationName.setText(station.getSiteName());
|
||||
onAutopilotStatusChanged(false);
|
||||
// onAutopilotStatusChanged(false);
|
||||
if (i == stationList.size() - 1) {
|
||||
showNotice("行程结束,请携带好随身物品\n注意侧后方来车\n感谢体验蘑菇智行自动驾驶车!");
|
||||
tvStationNotice.setText("终点");
|
||||
showSlidePanle("单程结束");
|
||||
} else if (i == 0) {
|
||||
hideNotice();
|
||||
showSlidePanle("准备出发");
|
||||
} else {
|
||||
showNotice("行程结束,请携带好随身物品\n注意侧后方来车\n感谢体验蘑菇智行自动驾驶车!");
|
||||
|
||||
@@ -150,6 +150,41 @@ public class OchBusPresenter extends Presenter<OchBusFragment> implements IMogoA
|
||||
currentAutopilot.vehicleType = VEHICAL_TYPE;
|
||||
Logger.d(TAG, "开启自动驾驶====" + currentAutopilot);
|
||||
MogoApisHandler.getInstance().getApis().getAdasControllerApi().aiCloudToAdasData(currentAutopilot);
|
||||
|
||||
if (mView != null) {
|
||||
mView.refreshBusStations(stationList);
|
||||
}
|
||||
mView.hideSlidePanel();
|
||||
mView.hideNotice();
|
||||
|
||||
if (isGoingToNextStation) {
|
||||
// 为了避免恢复自动驾驶时重复的接口请求
|
||||
return;
|
||||
}
|
||||
isGoingToNextStation = true;
|
||||
RequestBody request = RequestBody.create(MediaType.get("application/json"), GsonUtil.jsonFromObject(new OchBusLeaveStationRequest(Utils.getSn(), stationList.get(currentStationIndex).getSiteId())));
|
||||
MogoApisHandler.getInstance().getApis().getNetworkApi()
|
||||
.create(IOchBusApiService.class, HostConst.OCH_DOMAIN)
|
||||
.leaveStation(request).subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(getContext())) {
|
||||
@Override
|
||||
public void onSuccess(BaseData o) {
|
||||
super.onSuccess(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
Logger.d(TAG, "leave station error: " + message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
super.onError(e);
|
||||
Logger.e(TAG, e, "leave station exception");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void refreshCurrentStation() {
|
||||
@@ -182,6 +217,7 @@ public class OchBusPresenter extends Presenter<OchBusFragment> implements IMogoA
|
||||
return;
|
||||
}
|
||||
Logger.d(TAG, "单程结束====");
|
||||
MogoApisHandler.getInstance().getApis().getAdasControllerApi().cancelAutopilot();
|
||||
RequestBody request = RequestBody.create(MediaType.get("application/json"), GsonUtil.jsonFromObject(new OchBusLeaveStationRequest(Utils.getSn(), stationList.get(currentStationIndex).getSiteId())));
|
||||
MogoApisHandler.getInstance().getApis().getNetworkApi()
|
||||
.create(IOchBusApiService.class, HostConst.OCH_DOMAIN)
|
||||
@@ -227,43 +263,8 @@ public class OchBusPresenter extends Presenter<OchBusFragment> implements IMogoA
|
||||
}
|
||||
break;
|
||||
case IMogoAdasOCHCallback.STATUS_AUTOPILOT_RUNNING:
|
||||
mView.onAutopilotEnableChange(true);
|
||||
// mView.onAutopilotEnableChange(true);
|
||||
mView.onAutopilotStatusChanged(true);
|
||||
mView.hideSlidePanel();
|
||||
mView.hideNotice();
|
||||
if (mView != null) {
|
||||
mView.refreshBusStations(stationList);
|
||||
}
|
||||
if (isGoingToNextStation) {
|
||||
// 为了避免恢复自动驾驶时重复的接口请求
|
||||
return;
|
||||
}
|
||||
isGoingToNextStation = true;
|
||||
RequestBody request = RequestBody.create(MediaType.get("application/json"), GsonUtil.jsonFromObject(new OchBusLeaveStationRequest(Utils.getSn(), stationList.get(currentStationIndex).getSiteId())));
|
||||
MogoApisHandler.getInstance().getApis().getNetworkApi()
|
||||
.create(IOchBusApiService.class, HostConst.OCH_DOMAIN)
|
||||
.leaveStation(request).subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(getContext())) {
|
||||
@Override
|
||||
public void onSuccess(BaseData o) {
|
||||
super.onSuccess(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
Logger.d(TAG, "leave station error: " + message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
super.onError(e);
|
||||
Logger.e(TAG, e, "leave station exception");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
break;
|
||||
default:
|
||||
mView.onAutopilotEnableChange(false);
|
||||
|
||||
@@ -145,4 +145,6 @@ public interface IMogoADASController extends IProvider {
|
||||
int getAutopilotStatus();
|
||||
|
||||
void mockOchStatus(int state, String reason);
|
||||
|
||||
void cancelAutopilot();
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.mogo.service.impl.adas;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.RemoteException;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -689,4 +690,13 @@ public class MogoADASController implements IMogoADASController {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelAutopilot() {
|
||||
try {
|
||||
AutopilotServiceManage.getInstance().cancelAutopilot();
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user