diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/bean/OchBusResetRequest.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/bean/OchBusResetRequest.java new file mode 100644 index 0000000000..b14c7071b6 --- /dev/null +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/bean/OchBusResetRequest.java @@ -0,0 +1,32 @@ +package com.mogo.och.bus.bean; + +/** + * 重置车站状态请求参数 + * + * @author tongchenfei + */ +public class OchBusResetRequest { + private String sn; + private int siteId; + + public OchBusResetRequest(String sn, int siteId) { + this.sn = sn; + this.siteId = siteId; + } + + public String getSn() { + return sn; + } + + public void setSn(String sn) { + this.sn = sn; + } + + public int getSiteId() { + return siteId; + } + + public void setSiteId(int siteId) { + this.siteId = siteId; + } +} diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/fragment/OchBusFragment.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/fragment/OchBusFragment.java index bda0787c98..979e45642b 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/fragment/OchBusFragment.java +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/fragment/OchBusFragment.java @@ -16,6 +16,7 @@ import com.mogo.och.bus.constant.OchBusConst; import com.mogo.och.bus.presenter.OchBusPresenter; import com.mogo.och.view.SlidePanelView; import com.mogo.service.adas.IMogoAdasOCHCallback; +import com.mogo.utils.TipToast; import com.mogo.utils.logger.Logger; import java.util.ArrayList; @@ -49,91 +50,101 @@ public class OchBusFragment extends BaseOchFragment { - // todo debug code - List stationList = new ArrayList<>(); - OchBusStation station; - switch (stationSizeLevel) { - case 2: - stationSizeLevel++; - station = new OchBusStation(); - station.setSiteName("第一站"); - station.setIsCurrentSite(OchBusConst.STATION_STATUS_STOPED); - stationList.add(station); - station = new OchBusStation(); - station.setSiteName("第二站"); - station.setIsCurrentSite(OchBusConst.STATION_STATUS_IDLE); - stationList.add(station); - break; - case 3: - stationSizeLevel++; - station = new OchBusStation(); - station.setSiteName("第一站"); - station.setIsCurrentSite(OchBusConst.STATION_STATUS_STOPED); - stationList.add(station); - station = new OchBusStation(); - station.setSiteName("第二站"); - station.setIsCurrentSite(OchBusConst.STATION_STATUS_IDLE); - stationList.add(station); - station = new OchBusStation(); - station.setSiteName("第三站"); - station.setIsCurrentSite(OchBusConst.STATION_STATUS_IDLE); - stationList.add(station); - break; - case 4: - stationSizeLevel++; - station = new OchBusStation(); - station.setSiteName("第一站"); - station.setIsCurrentSite(OchBusConst.STATION_STATUS_STOPED); - stationList.add(station); - station = new OchBusStation(); - station.setSiteName("第二站"); - station.setIsCurrentSite(OchBusConst.STATION_STATUS_IDLE); - stationList.add(station); - station = new OchBusStation(); - station.setSiteName("第三站"); - station.setIsCurrentSite(OchBusConst.STATION_STATUS_IDLE); - stationList.add(station); - station = new OchBusStation(); - station.setSiteName("第四站"); - station.setIsCurrentSite(OchBusConst.STATION_STATUS_IDLE); - stationList.add(station); - break; - default: - stationSizeLevel = 2; - station = new OchBusStation(); - station.setSiteName("第一站"); - station.setIsCurrentSite(OchBusConst.STATION_STATUS_STOPED); - stationList.add(station); - station = new OchBusStation(); - station.setSiteName("第二站"); - station.setIsCurrentSite(OchBusConst.STATION_STATUS_IDLE); - stationList.add(station); - station = new OchBusStation(); - station.setSiteName("第三站"); - station.setIsCurrentSite(OchBusConst.STATION_STATUS_IDLE); - stationList.add(station); - station = new OchBusStation(); - station.setSiteName("第四站"); - station.setIsCurrentSite(OchBusConst.STATION_STATUS_IDLE); - stationList.add(station); - station = new OchBusStation(); - station.setSiteName("第五站"); - station.setIsCurrentSite(OchBusConst.STATION_STATUS_IDLE); - stationList.add(station); - station = new OchBusStation(); - station.setSiteName("第五站"); - station.setIsCurrentSite(OchBusConst.STATION_STATUS_IDLE); - stationList.add(station); - station = new OchBusStation(); - station.setSiteName("第五站"); - station.setIsCurrentSite(OchBusConst.STATION_STATUS_IDLE); - stationList.add(station); - break; - } - refreshBusStations(stationList); + tvStationName.setOnLongClickListener(view -> { + TipToast.shortTip("重置了车站状态"); + mPresenter.debugResetStationStatus(); + return true; }); + tvStationNotice.setOnLongClickListener(view -> { + getActivity().finish(); + return true; + }); +// tvStationNotice.setOnClickListener(view -> { +// // todo debug code +// List stationList = new ArrayList<>(); +// OchBusStation station; +// switch (stationSizeLevel) { +// case 2: +// stationSizeLevel++; +// station = new OchBusStation(); +// station.setSiteName("第一站"); +// station.setIsCurrentSite(OchBusConst.STATION_STATUS_STOPED); +// stationList.add(station); +// station = new OchBusStation(); +// station.setSiteName("第二站"); +// station.setIsCurrentSite(OchBusConst.STATION_STATUS_IDLE); +// stationList.add(station); +// break; +// case 3: +// stationSizeLevel++; +// station = new OchBusStation(); +// station.setSiteName("第一站"); +// station.setIsCurrentSite(OchBusConst.STATION_STATUS_STOPED); +// stationList.add(station); +// station = new OchBusStation(); +// station.setSiteName("第二站"); +// station.setIsCurrentSite(OchBusConst.STATION_STATUS_IDLE); +// stationList.add(station); +// station = new OchBusStation(); +// station.setSiteName("第三站"); +// station.setIsCurrentSite(OchBusConst.STATION_STATUS_IDLE); +// stationList.add(station); +// break; +// case 4: +// stationSizeLevel++; +// station = new OchBusStation(); +// station.setSiteName("第一站"); +// station.setIsCurrentSite(OchBusConst.STATION_STATUS_STOPED); +// stationList.add(station); +// station = new OchBusStation(); +// station.setSiteName("第二站"); +// station.setIsCurrentSite(OchBusConst.STATION_STATUS_IDLE); +// stationList.add(station); +// station = new OchBusStation(); +// station.setSiteName("第三站"); +// station.setIsCurrentSite(OchBusConst.STATION_STATUS_IDLE); +// stationList.add(station); +// station = new OchBusStation(); +// station.setSiteName("第四站"); +// station.setIsCurrentSite(OchBusConst.STATION_STATUS_IDLE); +// stationList.add(station); +// break; +// default: +// stationSizeLevel = 2; +// station = new OchBusStation(); +// station.setSiteName("第一站"); +// station.setIsCurrentSite(OchBusConst.STATION_STATUS_STOPED); +// stationList.add(station); +// station = new OchBusStation(); +// station.setSiteName("第二站"); +// station.setIsCurrentSite(OchBusConst.STATION_STATUS_IDLE); +// stationList.add(station); +// station = new OchBusStation(); +// station.setSiteName("第三站"); +// station.setIsCurrentSite(OchBusConst.STATION_STATUS_IDLE); +// stationList.add(station); +// station = new OchBusStation(); +// station.setSiteName("第四站"); +// station.setIsCurrentSite(OchBusConst.STATION_STATUS_IDLE); +// stationList.add(station); +// station = new OchBusStation(); +// station.setSiteName("第五站"); +// station.setIsCurrentSite(OchBusConst.STATION_STATUS_IDLE); +// stationList.add(station); +// station = new OchBusStation(); +// station.setSiteName("第五站"); +// station.setIsCurrentSite(OchBusConst.STATION_STATUS_IDLE); +// stationList.add(station); +// station = new OchBusStation(); +// station.setSiteName("第五站"); +// station.setIsCurrentSite(OchBusConst.STATION_STATUS_IDLE); +// stationList.add(station); +// break; +// } +// refreshBusStations(stationList); +// }); + Logger.d(TAG, "initView: " + MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus()); switch (MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus()) { case IMogoAdasOCHCallback.STATUS_AUTOPILOT_DISABLE: @@ -211,12 +222,7 @@ public class OchBusFragment extends BaseOchFragment leaveStation(@Body RequestBody requestBody); + /** + * 调试用重置接口 + * @param requestBody 请求参数{"siteId":1,"sn":"F803EB2046PZD00229"} + * @return 返回值是重置后的车站列表 + */ + @Headers({"Content-Type:application/json;charset=UTF-8"}) + @POST("/yycp-onlinecar-hailing/onlineCarHailing/site/resetSiteByCoordinate/v1") + Observable debugResetStationStatus(@Body RequestBody requestBody); + } diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/OchBusPresenter.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/OchBusPresenter.java index 3859fc1fbf..70965978e2 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/OchBusPresenter.java +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/OchBusPresenter.java @@ -11,6 +11,7 @@ import com.mogo.map.location.MogoLocation; import com.mogo.module.common.MogoApisHandler; import com.mogo.module.common.constants.HostConst; import com.mogo.och.bus.bean.OchBusLeaveStationRequest; +import com.mogo.och.bus.bean.OchBusResetRequest; import com.mogo.och.bus.bean.OchBusRoutesRequest; import com.mogo.och.bus.bean.OchBusRoutesResponse; import com.mogo.och.bus.bean.OchBusStation; @@ -137,6 +138,59 @@ public class OchBusPresenter extends Presenter implements IMogoA } } + public void debugResetStationStatus(){ + OchBusResetRequest request = new OchBusResetRequest(Utils.getSn(), 1); + RequestBody requestBody = RequestBody.create(MediaType.get("application/json;charset=UTF-8"), GsonUtil.jsonFromObject(request)); + MogoApisHandler.getInstance().getApis().getNetworkApi() + .create(IOchBusApiService.class, HostConst.OCH_DOMAIN) + .debugResetStationStatus(requestBody) + .subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()) + .subscribe(new SubscribeImpl(RequestOptions.create(getContext())) { + + @Override + public void onSuccess(OchBusRoutesResponse o) { + super.onSuccess(o); + Logger.d(TAG, "获取到小巴路线数据: " + o); + isGoingToNextStation = false; + if (mView != null && o.getResult() != null && o.getResult().getSite() != null) { + stationList.clear(); + stationList.addAll(o.getResult().getSite()); + for (int i = 0; i < stationList.size(); i++) { + OchBusStation s = stationList.get(i); + if (s.getIsCurrentSite() == STATION_STATUS_LEAVING) { + // 服务端只记录了leaving状态,没有记录arriving状态,此处端上自己增加一个arriving状态 + isGoingToNextStation = true; + currentStationIndex = i; + if (i < stationList.size() - 1) { + // 将其下一站置为arriving状态 + stationList.get(i + 1).setIsCurrentSite(STATION_STATUS_ARRIVING); + } + mView.hideSlidePanel(); + } + } + refreshCurrentStation(); + mView.refreshBusStations(stationList); + } + } + + @Override + public void onError(Throwable e) { + super.onError(e); + Logger.e(TAG, e, "获取小巴路线图失败"); + // 重复请求小巴路线,直至成功 + requeryBusStation(); + } + + @Override + public void onError(String message, int code) { + super.onError(message, code); + Logger.e(TAG, "获取小巴路线失败 code: " + code + " msg: " + message); + // 重复请求小巴路线,直至成功 + requeryBusStation(); + } + }); + } + public void autoDriveToNextStation() { if (currentStationIndex >= stationList.size() - 1) { // 当前站是最后一站,结束当前行程 diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/view/NoTouchConstraintLayout.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/view/NoTouchConstraintLayout.java index 46f9244da8..558a515bd9 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/view/NoTouchConstraintLayout.java +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/view/NoTouchConstraintLayout.java @@ -6,6 +6,8 @@ import android.view.MotionEvent; import androidx.constraintlayout.widget.ConstraintLayout; +import com.mogo.commons.debug.DebugConfig; + /** * 强制拦截所有touch时间的约束布局 * @@ -26,6 +28,10 @@ public class NoTouchConstraintLayout extends ConstraintLayout { @Override public boolean onInterceptTouchEvent(MotionEvent ev) { - return true; + if(DebugConfig.isDebug()){ + return super.onInterceptTouchEvent(ev); + }else { + return true; + } } } diff --git a/OCH/mogo-och/src/main/java/com/mogo/och/BaseOchFragment.java b/OCH/mogo-och/src/main/java/com/mogo/och/BaseOchFragment.java index 6d56510d06..c39173fad8 100644 --- a/OCH/mogo-och/src/main/java/com/mogo/och/BaseOchFragment.java +++ b/OCH/mogo-och/src/main/java/com/mogo/och/BaseOchFragment.java @@ -118,6 +118,9 @@ public abstract class BaseOchFragment> e public void showNotice(String notice) { getActivity().runOnUiThread(() -> { tvNotice.setText(notice); + if (MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus() == IMogoAdasOCHCallback.STATUS_AUTOPILOT_DISABLE) { + return; + } AIAssist.getInstance(getContext()).speakTTSVoice(notice); tvNoticeContainer.setVisibility(View.VISIBLE); fivNoticeHead.setVisibility(View.VISIBLE);