From d2933a09b4d7e3d1fe4e323f88bf600efda29d48 Mon Sep 17 00:00:00 2001 From: tongchenfei Date: Tue, 26 Jan 2021 20:32:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=B5=8B=E8=AF=95=E6=8C=89?= =?UTF-8?q?=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mogo/och/bus/fragment/OchBusFragment.java | 28 +++++++-- .../och/bus/presenter/OchBusPresenter.java | 49 +++++++-------- .../java/com/mogo/och/BaseOchFragment.java | 59 +++++++++++++------ .../layout/module_mogo_och_base_fragment.xml | 43 ++++++++++++++ .../service/adas/IMogoADASController.java | 2 + .../service/impl/adas/MogoADASController.java | 15 ++++- 6 files changed, 147 insertions(+), 49 deletions(-) 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 84c9c52551..fa65051d12 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 @@ -14,9 +14,9 @@ import com.mogo.och.bus.bean.OchBusStation; 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.logger.Logger; -import java.util.ArrayList; import java.util.List; @@ -44,6 +44,22 @@ public class OchBusFragment extends BaseOchFragment= stationList.size() - 3) { - moveTo = stationList.size()-1; + moveTo = stationList.size() - 1; } if (moveTo >= stationList.size()) { - moveTo = stationList.size()-1; + moveTo = stationList.size() - 1; } rvStationList.smoothScrollToPosition(moveTo); } @@ -154,15 +170,15 @@ public class OchBusFragment extends BaseOchFragment implements IMogoA currentAutopilot.endLatLon = new RemoteControlAutoPilotParameters.AutoPilotLonLat(nextStation.getLat(), nextStation.getLon()); currentAutopilot.vehicleType = VEHICAL_TYPE; MogoApisHandler.getInstance().getApis().getAdasControllerApi().aiCloudToAdasData(currentAutopilot); - - RequestBody request = RequestBody.create(MediaType.get("application/json"), GsonUtil.jsonFromObject(new OchBusLeaveStationRequest(Utils.getSn(), currentStation.getSiteId()))); - MogoApisHandler.getInstance().getApis().getNetworkApi() - .create(IOchBusApiService.class, HostConst.OCH_DOMAIN) - .leaveStation(request).subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(new SubscribeImpl(RequestOptions.create(getContext())) { - @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"); - } - }); - - - if (mView != null) { - mView.refreshBusStations(stationList); - } } private void refreshCurrentStation() { @@ -200,6 +176,31 @@ public class OchBusPresenter extends Presenter implements IMogoA case IMogoAdasOCHCallback.STATUS_AUTOPILOT_RUNNING: mView.onAutopilotEnableChange(true); mView.onAutopilotStatusChanged(true); + mView.hideSlidePanel(); + mView.hideNotice(); + 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(RequestOptions.create(getContext())) { + @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"); + } + }); + + + if (mView != null) { + mView.refreshBusStations(stationList); + } break; default: mView.onAutopilotEnableChange(false); 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 df7a4dbf15..8f30a4ad98 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 @@ -60,14 +60,23 @@ public abstract class BaseOchFragment> e @Override public void onClickImpl(View v) { // 如果能自动驾驶,就自动驾驶,不能就提示 - if (MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus() != IMogoAdasOCHCallback.STATUS_AUTOPILOT_DISABLE) { - restartAutopilot(); - } +// if (MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus() != IMogoAdasOCHCallback.STATUS_AUTOPILOT_DISABLE) { +// restartAutopilot(); +// } } }); checkCallView(MogoApisHandler.getInstance().getApis().getStatusManagerApi().isCallViewShow()); MogoApisHandler.getInstance().getApis().getStatusManagerApi().registerStatusChangedListener("Och", StatusDescriptor.CALL_VIEW, callViewListener); + + findViewById(R.id.btnAutopilotDisable).setOnClickListener(view-> MogoApisHandler.getInstance().getApis().getAdasControllerApi().mockOchStatus(IMogoAdasOCHCallback.STATUS_AUTOPILOT_DISABLE, "不能使用")); + + findViewById(R.id.btnAutopilotEnable).setOnClickListener(view-> MogoApisHandler.getInstance().getApis().getAdasControllerApi().mockOchStatus(IMogoAdasOCHCallback.STATUS_AUTOPILOT_ENABLE, "能使用")); + + findViewById(R.id.btnAutopilotRunning).setOnClickListener(view -> MogoApisHandler.getInstance().getApis().getAdasControllerApi().mockOchStatus(IMogoAdasOCHCallback.STATUS_AUTOPILOT_RUNNING, "Running")); + + findViewById(R.id.btnAutopilotArrive).setOnClickListener(view -> MogoApisHandler.getInstance().getApis().getAdasControllerApi().mockOchStatus(-1, "Running")); + } private void checkCallView(boolean isShown) { @@ -82,25 +91,33 @@ public abstract class BaseOchFragment> e } public void showSlidePanle(String text) { - slidePanelView.setText(text); - slidePanelView.setVisibility(View.VISIBLE); + getActivity().runOnUiThread(()->{ + slidePanelView.setText(text); + slidePanelView.setVisibility(View.VISIBLE); + }); } public void hideSlidePanel() { - slidePanelView.setVisibility(View.GONE); + getActivity().runOnUiThread(()->{ + slidePanelView.setVisibility(View.GONE); + }); } public void showNotice(String notice) { - tvNotice.setText(notice); - tvNotice.setVisibility(View.VISIBLE); - fivNoticeHead.setVisibility(View.VISIBLE); - fivNoticeHead.startAnim(); + getActivity().runOnUiThread(()->{ + tvNotice.setText(notice); + tvNotice.setVisibility(View.VISIBLE); + fivNoticeHead.setVisibility(View.VISIBLE); + fivNoticeHead.startAnim(); + }); } public void hideNotice() { - tvNotice.setVisibility(View.GONE); - fivNoticeHead.setVisibility(View.GONE); - fivNoticeHead.stopAnim(); + getActivity().runOnUiThread(()->{ + tvNotice.setVisibility(View.GONE); + fivNoticeHead.setVisibility(View.GONE); + fivNoticeHead.stopAnim(); + }); } /** @@ -109,17 +126,23 @@ public abstract class BaseOchFragment> e * @param isInAutopilot true - 在自动驾驶中 false - 不在自动驾驶中 */ public void onAutopilotStatusChanged(boolean isInAutopilot) { - ctvAutopilotStatus.setChecked(isInAutopilot); + getActivity().runOnUiThread(()->{ + ctvAutopilotStatus.setChecked(isInAutopilot); + }); } public void hideAutopilotBiz() { - ctvAutopilotStatus.setVisibility(View.GONE); - slidePanelView.setVisibility(View.GONE); + getActivity().runOnUiThread(()->{ + ctvAutopilotStatus.setVisibility(View.GONE); + slidePanelView.setVisibility(View.GONE); + }); } public void showAutopilotBiz() { - ctvAutopilotStatus.setVisibility(View.VISIBLE); - slidePanelView.setVisibility(View.VISIBLE); + getActivity().runOnUiThread(()->{ + ctvAutopilotStatus.setVisibility(View.VISIBLE); + slidePanelView.setVisibility(View.VISIBLE); + }); } public SlidePanelView.OnSlidePanelMoveToEndListener getSlidePanelOnEndListener() { diff --git a/OCH/mogo-och/src/main/res/layout/module_mogo_och_base_fragment.xml b/OCH/mogo-och/src/main/res/layout/module_mogo_och_base_fragment.xml index eca71bba3b..af945dfd30 100644 --- a/OCH/mogo-och/src/main/res/layout/module_mogo_och_base_fragment.xml +++ b/OCH/mogo-och/src/main/res/layout/module_mogo_och_base_fragment.xml @@ -65,4 +65,47 @@ app:layout_constraintRight_toRightOf="@id/module_mogo_och_notice" app:layout_constraintTop_toTopOf="@id/module_mogo_och_notice"/> +