[taxi/bus-d 270] bus 自动驾驶按钮逻辑优化

This commit is contained in:
wangmingjun
2022-05-10 19:44:55 +08:00
parent 3a4a0af55f
commit 8573af96b0
4 changed files with 42 additions and 14 deletions

View File

@@ -63,5 +63,7 @@ class BusConst {
* 订单起终点Marker类型
*/
const val TYPE_MARKER_BUS_ORDER = "TYPE_MARKER_BUS_ORDER"
const val TIMER_START_AUTOPILOT_INTERVAL = 10 * 1000L
}
}

View File

@@ -156,7 +156,9 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
@Override
public void onClickImpl(View v) {
restartAutopilot();
if (CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState() != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE){
restartAutopilot();
}
}
});
@@ -309,14 +311,15 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
CallerLogger.INSTANCE.d(M_BUS + TAG, "onStateChangeChangeAutopilotBtnView: " + autopilotStatus + "isAnimateRunning = " + isAnimateRunning);
if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE
== autopilotStatus) {//0不可用
if (isAnimateRunning) {
if (isAnimateRunning){
stopAutopilotAnimation();
ctvAutopilotStatusIv.setImageResource(R.drawable.bus_wrong_autopilot_icon);
ctvAutopilotStatusTv.setTextColor(getResources().getColor(R.color.bus_autopilot_text_color_normal));
ctvAutopilotStatusTv.setText(getResources().getString(R.string.bus_loading_autopilot_failure_tv));
ctvAutopilotStatus.setFocusableInTouchMode(false);
ctvAutopilotStatus.setSelected(false);
}
ctvAutopilotStatusIv.setImageResource(R.drawable.bus_wrong_autopilot_icon);
ctvAutopilotStatusTv.setTextColor(getResources().getColor(R.color.bus_autopilot_text_color_normal));
ctvAutopilotStatusTv.setText(getResources().getString(R.string.bus_loading_autopilot_failure_tv));
ctvAutopilotStatus.setFocusableInTouchMode(false);
ctvAutopilotStatus.setSelected(false);
UiThreadHandler.postDelayed(new Runnable() {
@Override
public void run() {
@@ -332,7 +335,7 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
} else if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE
== autopilotStatus) {//1可用
if (isAnimateRunning) {
return;
stopAutopilotAnimation();
}
ctvAutopilotStatusTv.setTextColor(getResources().getColor(R.color.bus_autopilot_text_color_normal));
ctvAutopilotStatusTv.setText(getResources().getString(R.string.bus_loading_autopilot_runnig_tv));
@@ -342,7 +345,7 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
// ctvAutopilotStatus.setPressed(true);
} else if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING
== autopilotStatus) {//2 running
if (isAnimateRunning) {
if (isAnimateRunning){
stopAutopilotAnimation();
}
ctvAutopilotStatusIv.setImageResource(R.drawable.bus_right_autopilot_icon);
@@ -450,9 +453,12 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
autopilotLoadingAnimator.end();
ctvAutopilotStatusIv.clearAnimation();
autopilotLoadingAnimator = null;
setIsAnimateRunning(false);
}
}
public abstract void setIsAnimateRunning(boolean isAnimateRunning);
/**
* 迈速表实时更新
*

View File

@@ -347,6 +347,11 @@ public class BusFragment extends BaseBusTabFragment<BusFragment, BusPresenter>
mPresenter.debugAutoPilotStatus(status);
}
@Override
public void setIsAnimateRunning(boolean isAnimateRunning) {
mPresenter.setIsAnimateRunning(isAnimateRunning);
}
@Override
public void onClick(View v) {
if (v.getId() == R.id.switch_line_btn) {//切换路线条件: 自动驾驶过程中点击则toast提示自动驾驶中不可切换路线

View File

@@ -1,6 +1,7 @@
package com.mogo.och.bus.presenter;
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS;
import static com.mogo.och.bus.constant.BusConst.TIMER_START_AUTOPILOT_INTERVAL;
import android.location.Location;
import android.os.Looper;
@@ -83,6 +84,10 @@ public class BusPresenter extends Presenter<BusFragment>
BusOrderModel.getInstance().setControllerStatusCallback(null);
}
public void setIsAnimateRunning(boolean isAnimateRunning){
this.isAnimateRunning = isAnimateRunning;
}
public void queryBusRoutes() {
BusOrderModel.getInstance().queryBusRoutes();
}
@@ -97,8 +102,10 @@ public class BusPresenter extends Presenter<BusFragment>
}
public void restartAutopilot() {
currentAutopilotStatus = -1;
BusOrderModel.getInstance().restartAutopilot();
if (!isAnimateRunning){
currentAutopilotStatus = -1;
BusOrderModel.getInstance().restartAutopilot();
}
}
public void onChangeOperationStatus() {
@@ -132,7 +139,7 @@ public class BusPresenter extends Presenter<BusFragment>
|| ((mCurrentStation == 0 || mCurrentStation == mStationList.size() - 1)
&& BusOrderModel.getInstance().isGoingToNextStation()))) {
runOnUIThread(() -> mView.onAutopilotStatusChanged(
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING, false));
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING, isAnimateRunning));
}
}
@@ -194,7 +201,6 @@ public class BusPresenter extends Presenter<BusFragment>
runOnUIThread(() -> mView.onAutopilotStatusChanged(currentAutopilotStatus, isAnimateRunning));
BusOrderModel.getInstance().triggerStartServiceEvent(true);
}
isAnimateRunning = false;
break;
case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE:
if (currentAutopilotStatus != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE) {
@@ -219,7 +225,6 @@ public class BusPresenter extends Presenter<BusFragment>
mView.onAutopilotStatusChanged(currentAutopilotStatus, isAnimateRunning);
});
}
isAnimateRunning = false;
break;
default:
runOnUIThread(() -> mView.onAutopilotEnableChange(false));
@@ -243,6 +248,16 @@ public class BusPresenter extends Presenter<BusFragment>
public void startOpenAutopilot() {
isAnimateRunning = true;
runOnUIThread(() -> mView.startAutopilotAnimation());
//10s 若自动驾驶没有开启,则结束动画
UiThreadHandler.postDelayed(new Runnable() {
@Override
public void run() { //未启动成功做处理
if (CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState()
!= IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING && isAnimateRunning){
mView.onAutopilotStatusChanged(CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState(), isAnimateRunning);
}
}
},TIMER_START_AUTOPILOT_INTERVAL);
// TODO: 2021/8/20 无工控机环境, 手动调起自动驾驶开启返回结果,有工控机环境要删除
// UiThreadHandler.postDelayed(new Runnable() {
// @Override