[6.4.4]
[代码修改]
This commit is contained in:
@@ -1,526 +0,0 @@
|
||||
package com.mogo.och.bus.fragment;
|
||||
|
||||
import static com.mogo.och.bus.constant.BusConst.TIMER_START_AUTOPILOT_INTERVAL;
|
||||
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.LinearInterpolator;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.widget.Group;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.mvp.IView;
|
||||
import com.mogo.commons.mvp.MvpFragment;
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
|
||||
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager;
|
||||
import com.mogo.eagle.core.function.hmi.ui.msgbox.DriverMsgBoxBubbleView;
|
||||
import com.mogo.eagle.core.function.hmi.ui.msgbox.DriverMsgBoxButtonView;
|
||||
import com.mogo.eagle.core.function.hmi.ui.msgbox.DriverMsgBoxListView;
|
||||
import com.mogo.eagle.core.function.smp.view.SmallMapView;
|
||||
import com.mogo.eagle.core.utilcode.mogo.view.OnPreventFastClickListener;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.och.bus.R;
|
||||
import com.mogo.och.bus.bean.BusRoutesResult;
|
||||
import com.mogo.och.bus.model.OrderModel;
|
||||
import com.mogo.och.bus.util.BDRouteDataTestUtils;
|
||||
import com.mogo.och.bus.view.BizMapView;
|
||||
import com.mogo.och.bus.view.SlidePanelView;
|
||||
import com.mogo.och.common.module.utils.SoundPoolHelper;
|
||||
import com.mogo.och.common.module.utils.ResourcesUtils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
/**
|
||||
* 网约车基础Fragment,主要负责布局通用界面,处理站点面板和通话面板互斥情况
|
||||
* <p>
|
||||
* 部分业务放在了此处处理
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>> extends MvpFragment<V, P> {
|
||||
|
||||
private static final String TAG = "BaseBusTabFragment";
|
||||
|
||||
protected SlidePanelView slidePanelView;
|
||||
private RelativeLayout ctvAutopilotStatus;
|
||||
private ImageView ctvAutopilotStatusIv;
|
||||
private TextView ctvAutopilotStatusTv;
|
||||
protected TextView tvArrived;
|
||||
private FrameLayout flStationPanelContainer;
|
||||
private BizMapView mapBizView;
|
||||
private Group groupTestPanel;
|
||||
|
||||
protected SmallMapView smallMapView;
|
||||
|
||||
//消息盒子
|
||||
private DriverMsgBoxButtonView viewDriverMsgBoxButton;
|
||||
private DriverMsgBoxListView viewDriverMsgBoxList;
|
||||
private DriverMsgBoxBubbleView viewDriverMsgBoxBubble;
|
||||
|
||||
private ObjectAnimator autopilotLoadingAnimator;
|
||||
|
||||
public boolean isAnimateRunning = false;
|
||||
|
||||
|
||||
/**
|
||||
* 滑动按钮触发的事件
|
||||
*/
|
||||
private final SlidePanelView.OnSlidePanelMoveToEndListener onSlideToEndListener = () -> {
|
||||
// 此处做一个代理,处理一下共有情况
|
||||
if (getSlidePanelOnEndListener() != null) {
|
||||
getSlidePanelOnEndListener().moveToEnd();
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.bus_base_fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initViews() {
|
||||
mapBizView = findViewById(R.id.mapBizView);
|
||||
groupTestPanel = findViewById(R.id.groupTestPanel);
|
||||
slidePanelView = findViewById(R.id.module_mogo_och_slide_panel);
|
||||
ctvAutopilotStatus = findViewById(R.id.module_mogo_och_autopilot_status);
|
||||
ctvAutopilotStatusIv = findViewById(R.id.bus_autopilot_btn_iv);
|
||||
ctvAutopilotStatusTv = findViewById(R.id.bus_autopolot_btn_tv);
|
||||
flStationPanelContainer = findViewById(R.id.module_mogo_och_station_panel_container);
|
||||
|
||||
tvArrived = findViewById(R.id.module_mogo_och_arrived_tv);
|
||||
|
||||
|
||||
FrameLayout flSpeed = findViewById(R.id.fl_speed);
|
||||
if (flSpeed != null) {
|
||||
CallerDevaToolsManager.INSTANCE.attachAutopilotBeforeLaunchView(flSpeed.getContext(), flSpeed);
|
||||
}
|
||||
|
||||
|
||||
|
||||
LayoutInflater.from(getContext()).inflate(getStationPanelViewId(), flStationPanelContainer);
|
||||
slidePanelView.setOnSlidePanelMoveToEndListener(onSlideToEndListener);
|
||||
|
||||
initListener();
|
||||
setAutopilotBtnStatus(CallerAutoPilotStatusListenerManager.INSTANCE.getState(), CallerAutoPilotControlManager.INSTANCE.isCanStartAutopilot(false, 0));
|
||||
ctvAutopilotStatus.setOnClickListener(new OnPreventFastClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClickImpl(View v) {
|
||||
restartAutopilot();
|
||||
}
|
||||
});
|
||||
|
||||
// 模拟 不可自动驾驶,目前场景是刚开机,adas还未和工控机连接
|
||||
findViewById(R.id.btnAutopilotDisable).setOnClickListener(view ->
|
||||
debugAutoPilotStatus(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE)
|
||||
);
|
||||
|
||||
// 模拟 可自动驾驶,工控机连接正常,且处于人工干预状态
|
||||
findViewById(R.id.btnAutopilotEnable).setOnClickListener(view ->
|
||||
debugAutoPilotStatus(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE)
|
||||
);
|
||||
|
||||
// 模拟 自动驾驶能力,自动驾驶中,可能是停车,可能是行进,但是是机器在处理车的前进后退,不是人
|
||||
findViewById(R.id.btnAutopilotRunning).setOnClickListener(view ->
|
||||
debugAutoPilotStatus(IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING)
|
||||
);
|
||||
|
||||
findViewById(R.id.btnAutopilotPingxing).setOnClickListener(view ->
|
||||
debugAutoPilotStatus(IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING)
|
||||
);
|
||||
|
||||
// 模拟 自动驾驶网约车回调数据
|
||||
findViewById(R.id.btnAutopilotArrive).setOnClickListener(view ->
|
||||
debugArrivedStation()
|
||||
);
|
||||
|
||||
findViewById(R.id.btnAutopilotRoute).setOnClickListener(view -> debugArrivedRoute());
|
||||
|
||||
tvArrived.setOnClickListener(view -> {
|
||||
onArriveStation();
|
||||
});
|
||||
|
||||
//消息盒子
|
||||
viewDriverMsgBoxButton = findViewById(R.id.viewDriverMsgBoxButton);
|
||||
viewDriverMsgBoxList = findViewById(R.id.viewDriverMsgBoxList);
|
||||
viewDriverMsgBoxBubble = findViewById(R.id.viewDriverMsgBoxBubble);
|
||||
viewDriverMsgBoxButton.setClickListener(show -> {
|
||||
if (show) {
|
||||
viewDriverMsgBoxList.setVisibility(View.VISIBLE);
|
||||
viewDriverMsgBoxList.notifyData();
|
||||
viewDriverMsgBoxBubble.setVisibility(View.GONE);
|
||||
viewDriverMsgBoxBubble.isShowData(false);
|
||||
} else {
|
||||
viewDriverMsgBoxList.setVisibility(View.GONE);
|
||||
viewDriverMsgBoxBubble.setVisibility(View.VISIBLE);
|
||||
viewDriverMsgBoxBubble.isShowData(true);
|
||||
}
|
||||
});
|
||||
|
||||
smallMapView = findViewById(R.id.smallMapView);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initViews(Bundle savedInstanceState) {
|
||||
super.initViews(savedInstanceState);
|
||||
mapBizView.onCreate(savedInstanceState);
|
||||
smallMapView.onCreateView(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
mapBizView.onResume();
|
||||
smallMapView.onResume();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container
|
||||
, @Nullable Bundle savedInstanceState) {
|
||||
EventBus.getDefault().register(this);
|
||||
return super.onCreateView(inflater, container, savedInstanceState);
|
||||
}
|
||||
|
||||
protected abstract void onArriveStation();
|
||||
|
||||
private void debugArrivedRoute() {
|
||||
BDRouteDataTestUtils.converToRouteData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
mapBizView.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLowMemory() {
|
||||
super.onLowMemory();
|
||||
mapBizView.onLowMemory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
mapBizView.onPause();
|
||||
smallMapView.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
mapBizView.onDestroy();
|
||||
if(smallMapView != null){
|
||||
smallMapView.onDestroy();
|
||||
}
|
||||
EventBus.getDefault().unregister(this);
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试到站
|
||||
*/
|
||||
protected abstract void debugArrivedStation();
|
||||
|
||||
private void initListener() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示滑动按钮
|
||||
*
|
||||
* @param text 指定的文字
|
||||
*/
|
||||
public void showSlidePanel(String text) {
|
||||
UiThreadHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
slidePanelView.setText(text);
|
||||
slidePanelView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
},UiThreadHandler.MODE.QUEUE);
|
||||
setArrivedClickable(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置进站按钮状态
|
||||
*
|
||||
* @param isClickable
|
||||
*/
|
||||
public void setArrivedClickable(boolean isClickable) {
|
||||
UiThreadHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
tvArrived.setEnabled(isClickable);
|
||||
if (isClickable) {
|
||||
tvArrived.setTextColor(ResourcesUtils.getColor(R.color.bus_white));
|
||||
} else {
|
||||
tvArrived.setTextColor(ResourcesUtils.getColor(R.color.bus_arrived_btn_un_clickable_color));
|
||||
}
|
||||
}
|
||||
},UiThreadHandler.MODE.QUEUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 隐藏滑动按钮
|
||||
*/
|
||||
public void hideSlidePanel() {
|
||||
UiThreadHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
slidePanelView.setVisibility(View.GONE);
|
||||
}
|
||||
},UiThreadHandler.MODE.QUEUE);
|
||||
}
|
||||
|
||||
public void playDI() {
|
||||
SoundPoolHelper.getSoundPoolHelper().playSoundWithRedId(getContext(), R.raw.bus_di);
|
||||
}
|
||||
|
||||
/**
|
||||
* 改变自动驾驶状态
|
||||
*
|
||||
* @param autopilotStatus 0:不可用 1:可用状态 2:自动驾驶中
|
||||
*/
|
||||
public void onAutopilotStatusChanged(int autopilotStatus,boolean canStartAutopilt) {
|
||||
UiThreadHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
changeAutopilotBtnView(autopilotStatus, isAnimateRunning,canStartAutopilt);
|
||||
}
|
||||
},UiThreadHandler.MODE.QUEUE);
|
||||
}
|
||||
|
||||
public void setAutopilotBtnStatus(int autopilotStatus,boolean canStartAutopilt) {
|
||||
if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE
|
||||
== autopilotStatus) {//0不可用
|
||||
ctvAutopilotStatusTv.setTextColor(ResourcesUtils.getColor(R.color.bus_autopilot_text_color_disable));
|
||||
ctvAutopilotStatusTv.setText(ResourcesUtils.getString(R.string.bus_loading_autopilot_runnig_tv));
|
||||
ctvAutopilotStatusIv.setImageResource(R.drawable.bus_disable_autopilot_icon);
|
||||
ctvAutopilotStatus.setClickable(true);
|
||||
ctvAutopilotStatus.setBackgroundResource(R.drawable.bus_autopilot_0_1_status_bg);
|
||||
} else {
|
||||
ctvAutopilotStatusTv.setTextColor(AbsMogoApplication.getApp().getColor(R.color.bus_autopilot_text_color_normal));
|
||||
ctvAutopilotStatusIv.setImageResource(R.drawable.bus_ic_autopilot);
|
||||
if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE == autopilotStatus) { //1可用
|
||||
ctvAutopilotStatusTv.setText(ResourcesUtils.getString(R.string.bus_loading_autopilot_runnig_tv));
|
||||
if(canStartAutopilt){
|
||||
ctvAutopilotStatus.setClickable(true);
|
||||
ctvAutopilotStatus.setBackgroundResource(R.drawable.bus_autopilot_0_1_status_bg);
|
||||
}else {
|
||||
ctvAutopilotStatusTv.setTextColor(AbsMogoApplication.getApp().getColor(R.color.bus_autopilot_text_color_disable));
|
||||
ctvAutopilotStatusIv.setImageResource(R.drawable.bus_disable_autopilot_icon);
|
||||
ctvAutopilotStatus.setClickable(true);
|
||||
ctvAutopilotStatus.setBackgroundResource(R.drawable.bus_autopilot_0_1_status_bg);
|
||||
}
|
||||
} else if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING == autopilotStatus) {
|
||||
ctvAutopilotStatusTv.setText(R.string.bus_loading_autopilot_runnig_tv);
|
||||
ctvAutopilotStatus.setClickable(true);
|
||||
ctvAutopilotStatus.setBackgroundResource(R.drawable.bus_autopilot_2_status_bg);
|
||||
} else if (IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING
|
||||
== autopilotStatus) {
|
||||
ctvAutopilotStatusTv.setText(R.string.bus_pingxing_driver);
|
||||
ctvAutopilotStatus.setClickable(false);
|
||||
ctvAutopilotStatus.setBackgroundResource(R.drawable.common_autopilot_pxjs);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void updateAutopilotStatus(int autopilotStatus) {
|
||||
if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING
|
||||
== autopilotStatus) {//2 running
|
||||
ctvAutopilotStatusIv.setImageResource(R.drawable.bus_right_autopilot_icon);
|
||||
ctvAutopilotStatusTv.setTextColor(ResourcesUtils.getColor(R.color.bus_autopilot_text_color_normal));
|
||||
ctvAutopilotStatusTv.setText(ResourcesUtils.getString(R.string.bus_loading_autopilot_success_tv));
|
||||
// ctvAutopilotStatus.setSelected(false);
|
||||
ctvAutopilotStatus.setClickable(false);
|
||||
} else {
|
||||
ctvAutopilotStatusIv.setImageResource(R.drawable.bus_wrong_autopilot_icon);
|
||||
ctvAutopilotStatusTv.setTextColor(ResourcesUtils.getColor(R.color.bus_autopilot_text_color_normal));
|
||||
ctvAutopilotStatusTv.setText(ResourcesUtils.getString(R.string.bus_loading_autopilot_failure_tv));
|
||||
ctvAutopilotStatus.setClickable(false);
|
||||
// ctvAutopilotStatus.setSelected(false);
|
||||
}
|
||||
UiThreadHandler.postDelayed(() -> setAutopilotBtnStatus(autopilotStatus,CallerAutoPilotControlManager.INSTANCE.isCanStartAutopilot(false, 0)), 1000);
|
||||
}
|
||||
|
||||
private void changeAutopilotBtnView(int autopilotStatus, boolean isAnimateRunning, boolean canStartAutopilt) {
|
||||
if (isAnimateRunning && IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING
|
||||
!= autopilotStatus) {
|
||||
// 主动开启自动驾驶中,不为2(为0、1)则继续loading
|
||||
return;
|
||||
}
|
||||
if (isAnimateRunning) {
|
||||
stopAnimAndUpdateBtnStatus();
|
||||
} else {
|
||||
setAutopilotBtnStatus(autopilotStatus,canStartAutopilt);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void stopAnimAndUpdateBtnStatus() {
|
||||
stopAutopilotAnimation();
|
||||
updateAutopilotStatus(CallerAutoPilotStatusListenerManager.INSTANCE.getState());
|
||||
}
|
||||
|
||||
/**
|
||||
* 隐藏【自动驾驶】按钮
|
||||
*/
|
||||
public void hideAutopilotBiz() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示【自动驾驶】按钮
|
||||
*/
|
||||
public void showAutopilotBiz() {
|
||||
}
|
||||
|
||||
public SlidePanelView.OnSlidePanelMoveToEndListener getSlidePanelOnEndListener() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取站点面板view,在{@link #initViews()}时候添加到container中
|
||||
*
|
||||
* @return 站点面板view
|
||||
*/
|
||||
public abstract int getStationPanelViewId();
|
||||
|
||||
/**
|
||||
* 重新开启自动驾驶
|
||||
*/
|
||||
public abstract void restartAutopilot();
|
||||
|
||||
/**
|
||||
* 模拟自动驾驶返回状态
|
||||
*
|
||||
* @param status
|
||||
*/
|
||||
public abstract void debugAutoPilotStatus(int status);
|
||||
|
||||
/**
|
||||
* 开启自动驾驶中间动画
|
||||
*/
|
||||
public void startAutopilotAnimation() {
|
||||
isAnimateRunning = true;
|
||||
ctvAutopilotStatusTv.setText(ResourcesUtils.getString(R.string.bus_loading_autopilot_tv));
|
||||
ctvAutopilotStatusTv.setTextColor(ResourcesUtils.getColor(R.color.bus_autopilot_text_color_normal));
|
||||
ctvAutopilotStatus.setClickable(true);
|
||||
ctvAutopilotStatusIv.setImageResource(R.drawable.bus_loading_autopilot_icon);
|
||||
if (autopilotLoadingAnimator == null) {
|
||||
autopilotLoadingAnimator = ObjectAnimator.ofFloat(ctvAutopilotStatusIv, "rotation", 0f, 360f);
|
||||
autopilotLoadingAnimator.setInterpolator(new LinearInterpolator());
|
||||
autopilotLoadingAnimator.setRepeatCount(-1);//无限循环
|
||||
autopilotLoadingAnimator.setDuration(1000);//设置持续时间
|
||||
}
|
||||
autopilotLoadingAnimator.start();//动画开始
|
||||
|
||||
startingAutoApilotCountDown();
|
||||
|
||||
}
|
||||
|
||||
private void startingAutoApilotCountDown() {
|
||||
//10s 若自动驾驶没有开启,则结束动画
|
||||
UiThreadHandler.postDelayed(() -> { //未启动成功做处理
|
||||
if (isAnimateRunning) {// 只判断动画是否在进行,根据自动驾驶当前状态去设置自动驾驶状态
|
||||
stopAutopilotAnimation();
|
||||
updateAutopilotStatus(CallerAutoPilotStatusListenerManager.INSTANCE.getState());
|
||||
}
|
||||
}, TIMER_START_AUTOPILOT_INTERVAL);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止自动驾驶中间动画
|
||||
*/
|
||||
protected void stopAutopilotAnimation() {
|
||||
if (autopilotLoadingAnimator != null) {
|
||||
autopilotLoadingAnimator.end();
|
||||
ctvAutopilotStatusIv.clearAnimation();
|
||||
autopilotLoadingAnimator = null;
|
||||
isAnimateRunning = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* bus调试面板打开关闭
|
||||
*/
|
||||
public void debugTestBar() {
|
||||
if (groupTestPanel.getVisibility() == View.VISIBLE) {
|
||||
groupTestPanel.setVisibility(View.GONE);
|
||||
} else {
|
||||
groupTestPanel.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Bus调试信息:线路、轨迹等信息
|
||||
* <p>
|
||||
* START
|
||||
*/
|
||||
private View busTestBar;
|
||||
private TextView lineIdTV;
|
||||
private TextView lineNameTV;
|
||||
private TextView trajMd5TV;
|
||||
private TextView stopMd5TV;
|
||||
private TextView trajMd5DPQPTV;
|
||||
private TextView stopMd5DPQPTV;
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
public void showHideTestBar() {
|
||||
if (busTestBar == null) {
|
||||
busTestBar = findViewById(R.id.module_mogo_och_bus_test_bar);
|
||||
lineIdTV = findViewById(R.id.bus_test_bar_current_line_id);
|
||||
lineNameTV = findViewById(R.id.bus_test_bar_current_line_name);
|
||||
trajMd5TV = findViewById(R.id.bus_test_bar_current_traj_md5);
|
||||
stopMd5TV = findViewById(R.id.bus_test_bar_current_stop_md5);
|
||||
trajMd5DPQPTV = findViewById(R.id.bus_test_bar_current_traj_md5_dpqp);
|
||||
stopMd5DPQPTV = findViewById(R.id.bus_test_bar_current_stop_md5_dpqp);
|
||||
}
|
||||
|
||||
if (busTestBar.getVisibility() == View.VISIBLE) {
|
||||
busTestBar.setVisibility(View.GONE);
|
||||
} else {
|
||||
BusRoutesResult routesResult = OrderModel.getInstance().getBusRoutesResult();
|
||||
lineIdTV.setText("lineId:" + (routesResult == null ? "" : String.valueOf(routesResult.getLineId())));
|
||||
lineNameTV.setText("lineName:" + (routesResult == null ? "" : routesResult.getName()));
|
||||
trajMd5TV.setText("TMd5:" + (routesResult == null ? "" : routesResult.csvFileMd5));
|
||||
stopMd5TV.setText("SMd5:" + (routesResult == null ? "" : routesResult.txtFileMd5));
|
||||
trajMd5DPQPTV.setText("TMd5DPQP:" + (routesResult == null ? "" : routesResult.csvFileMd5DPQP));
|
||||
stopMd5DPQPTV.setText("SMd5DPQP:" + (routesResult == null ? "" : routesResult.txtFileMd5DPQP));
|
||||
busTestBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
public void updateBusTestBarInfo() {
|
||||
if (busTestBar != null && busTestBar.getVisibility() == View.VISIBLE) {
|
||||
BusRoutesResult routesResult = OrderModel.getInstance().getBusRoutesResult();
|
||||
lineIdTV.setText("lineId:" + (routesResult == null ? "" : String.valueOf(routesResult.getLineId())));
|
||||
lineNameTV.setText("lineName:" + (routesResult == null ? "" : routesResult.getName()));
|
||||
trajMd5TV.setText("TMd5:" + (routesResult == null ? "" : routesResult.csvFileMd5));
|
||||
stopMd5TV.setText("SMd5:" + (routesResult == null ? "" : routesResult.txtFileMd5));
|
||||
trajMd5DPQPTV.setText("TMd5DPQP:" + (routesResult == null ? "" : routesResult.csvFileMd5DPQP));
|
||||
stopMd5DPQPTV.setText("SMd5DPQP:" + (routesResult == null ? "" : routesResult.txtFileMd5DPQP));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,440 @@
|
||||
package com.mogo.och.bus.fragment
|
||||
|
||||
import android.animation.ObjectAnimator
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.animation.LinearInterpolator
|
||||
import android.widget.TextView
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
import com.mogo.commons.mvp.IView
|
||||
import com.mogo.commons.mvp.MvpFragment
|
||||
import com.mogo.commons.mvp.Presenter
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.isCanStartAutopilot
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager.getState
|
||||
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager.attachAutopilotBeforeLaunchView
|
||||
import com.mogo.eagle.core.function.hmi.ui.msgbox.DriverMsgBoxButtonView
|
||||
import com.mogo.eagle.core.utilcode.mogo.view.OnPreventFastClickListener
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import com.mogo.och.bus.R
|
||||
import com.mogo.och.bus.constant.BusConst
|
||||
import com.mogo.och.bus.model.OrderModel
|
||||
import com.mogo.och.bus.view.SlidePanelView
|
||||
import com.mogo.och.common.module.utils.ResourcesUtils
|
||||
import com.mogo.och.common.module.utils.ResourcesUtils.getColor
|
||||
import com.mogo.och.common.module.utils.SoundPoolHelper
|
||||
import kotlinx.android.synthetic.main.bus_base_fragment.bus_autopilot_btn_iv
|
||||
import kotlinx.android.synthetic.main.bus_base_fragment.bus_autopolot_btn_tv
|
||||
import kotlinx.android.synthetic.main.bus_base_fragment.fl_speed
|
||||
import kotlinx.android.synthetic.main.bus_base_fragment.mapBizView
|
||||
import kotlinx.android.synthetic.main.bus_base_fragment.module_mogo_och_arrived_tv
|
||||
import kotlinx.android.synthetic.main.bus_base_fragment.module_mogo_och_autopilot_status
|
||||
import kotlinx.android.synthetic.main.bus_base_fragment.module_mogo_och_slide_panel
|
||||
import kotlinx.android.synthetic.main.bus_base_fragment.module_mogo_och_station_panel_container
|
||||
import kotlinx.android.synthetic.main.bus_base_fragment.smallMapView
|
||||
import kotlinx.android.synthetic.main.bus_base_fragment.viewDriverMsgBoxBubble
|
||||
import kotlinx.android.synthetic.main.bus_base_fragment.viewDriverMsgBoxButton
|
||||
import kotlinx.android.synthetic.main.bus_base_fragment.viewDriverMsgBoxList
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
|
||||
/**
|
||||
* 网约车基础Fragment,主要负责布局通用界面,处理站点面板和通话面板互斥情况
|
||||
*
|
||||
*
|
||||
* 部分业务放在了此处处理
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
abstract class BaseBusTabFragment<V : IView?, P : Presenter<V>?> : MvpFragment<V, P>() {
|
||||
|
||||
//启动自驾动画
|
||||
private var autopilotLoadingAnimator: ObjectAnimator? = null
|
||||
var isAnimateRunning = false
|
||||
|
||||
private val TAG = "BaseBusTabFragment"
|
||||
|
||||
/**
|
||||
* 滑动按钮触发的事件
|
||||
*/
|
||||
private val onSlideToEndListener = SlidePanelView.OnSlidePanelMoveToEndListener {
|
||||
// 此处做一个代理,处理一下共有情况
|
||||
if (slidePanelOnEndListener != null) {
|
||||
slidePanelOnEndListener!!.moveToEnd()
|
||||
}
|
||||
}
|
||||
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.bus_base_fragment
|
||||
}
|
||||
|
||||
override fun initViews() {
|
||||
attachAutopilotBeforeLaunchView(fl_speed.context, fl_speed)
|
||||
LayoutInflater.from(context).inflate(stationPanelViewId, module_mogo_och_station_panel_container)
|
||||
module_mogo_och_slide_panel!!.setOnSlidePanelMoveToEndListener(onSlideToEndListener)
|
||||
initListener()
|
||||
setAutopilotBtnStatus(getState(), isCanStartAutopilot(false, 0))
|
||||
module_mogo_och_autopilot_status!!.setOnClickListener(object : OnPreventFastClickListener() {
|
||||
override fun onClickImpl(v: View) {
|
||||
restartAutopilot()
|
||||
}
|
||||
})
|
||||
|
||||
module_mogo_och_arrived_tv.setOnClickListener { onArriveStation() }
|
||||
|
||||
//消息盒子
|
||||
viewDriverMsgBoxButton!!.setClickListener(object :DriverMsgBoxButtonView.ClickListener{
|
||||
override fun showMsgBoxList(show: Boolean) {
|
||||
if (show) {
|
||||
viewDriverMsgBoxList!!.visibility = View.VISIBLE
|
||||
viewDriverMsgBoxList!!.notifyData()
|
||||
viewDriverMsgBoxBubble!!.visibility = View.GONE
|
||||
viewDriverMsgBoxBubble!!.isShowData(false)
|
||||
} else {
|
||||
viewDriverMsgBoxList!!.visibility = View.GONE
|
||||
viewDriverMsgBoxBubble!!.visibility = View.VISIBLE
|
||||
viewDriverMsgBoxBubble!!.isShowData(true)
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
override fun initViews(savedInstanceState: Bundle?) {
|
||||
super.initViews(savedInstanceState)
|
||||
mapBizView!!.onCreate(savedInstanceState)
|
||||
smallMapView!!.onCreateView(savedInstanceState)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapBizView!!.onResume()
|
||||
smallMapView!!.onResume()
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
||||
): View? {
|
||||
EventBus.getDefault().register(this)
|
||||
return super.onCreateView(inflater, container, savedInstanceState)
|
||||
}
|
||||
|
||||
protected abstract fun onArriveStation()
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapBizView!!.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapBizView!!.onLowMemory()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapBizView!!.onPause()
|
||||
smallMapView!!.onPause()
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
mapBizView!!.onDestroy()
|
||||
if (smallMapView != null) {
|
||||
smallMapView!!.onDestroy()
|
||||
}
|
||||
EventBus.getDefault().unregister(this)
|
||||
super.onDestroyView()
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试到站
|
||||
*/
|
||||
protected abstract fun debugArrivedStation()
|
||||
private fun initListener() {}
|
||||
|
||||
/**
|
||||
* 展示滑动按钮
|
||||
*
|
||||
* @param text 指定的文字
|
||||
*/
|
||||
fun showSlidePanel(text: String?) {
|
||||
UiThreadHandler.post({
|
||||
module_mogo_och_slide_panel!!.setText(text)
|
||||
module_mogo_och_slide_panel!!.visibility = View.VISIBLE
|
||||
}, UiThreadHandler.MODE.QUEUE)
|
||||
setArrivedClickable(false)
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置进站按钮状态
|
||||
*
|
||||
* @param isClickable
|
||||
*/
|
||||
fun setArrivedClickable(isClickable: Boolean) {
|
||||
UiThreadHandler.post({
|
||||
module_mogo_och_arrived_tv!!.isEnabled = isClickable
|
||||
if (isClickable) {
|
||||
module_mogo_och_arrived_tv!!.setTextColor(getColor(R.color.bus_white))
|
||||
} else {
|
||||
module_mogo_och_arrived_tv!!.setTextColor(getColor(R.color.bus_arrived_btn_un_clickable_color))
|
||||
}
|
||||
}, UiThreadHandler.MODE.QUEUE)
|
||||
}
|
||||
|
||||
/**
|
||||
* 隐藏滑动按钮
|
||||
*/
|
||||
fun hideSlidePanel() {
|
||||
UiThreadHandler.post(
|
||||
{ module_mogo_och_slide_panel!!.visibility = View.GONE },
|
||||
UiThreadHandler.MODE.QUEUE
|
||||
)
|
||||
}
|
||||
|
||||
fun playDI() {
|
||||
SoundPoolHelper.getSoundPoolHelper().playSoundWithRedId(context, R.raw.bus_di)
|
||||
}
|
||||
|
||||
/**
|
||||
* 改变自动驾驶状态
|
||||
*
|
||||
* @param autopilotStatus 0:不可用 1:可用状态 2:自动驾驶中
|
||||
*/
|
||||
fun onAutopilotStatusChanged(autopilotStatus: Int, canStartAutopilt: Boolean) {
|
||||
UiThreadHandler.post({
|
||||
changeAutopilotBtnView(
|
||||
autopilotStatus,
|
||||
isAnimateRunning,
|
||||
canStartAutopilt
|
||||
)
|
||||
}, UiThreadHandler.MODE.QUEUE)
|
||||
}
|
||||
|
||||
fun setAutopilotBtnStatus(autopilotStatus: Int, canStartAutopilt: Boolean) {
|
||||
if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE
|
||||
== autopilotStatus
|
||||
) { //0不可用
|
||||
bus_autopolot_btn_tv!!.setTextColor(getColor(R.color.bus_autopilot_text_color_disable))
|
||||
bus_autopolot_btn_tv!!.text =
|
||||
ResourcesUtils.getString(R.string.bus_loading_autopilot_runnig_tv)
|
||||
bus_autopilot_btn_iv!!.setImageResource(R.drawable.bus_disable_autopilot_icon)
|
||||
module_mogo_och_autopilot_status!!.isClickable = true
|
||||
module_mogo_och_autopilot_status!!.setBackgroundResource(R.drawable.bus_autopilot_0_1_status_bg)
|
||||
} else {
|
||||
bus_autopolot_btn_tv!!.setTextColor(
|
||||
AbsMogoApplication.getApp().getColor(R.color.bus_autopilot_text_color_normal)
|
||||
)
|
||||
bus_autopilot_btn_iv!!.setImageResource(R.drawable.bus_ic_autopilot)
|
||||
if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE == autopilotStatus) { //1可用
|
||||
bus_autopolot_btn_tv!!.text =
|
||||
ResourcesUtils.getString(R.string.bus_loading_autopilot_runnig_tv)
|
||||
if (canStartAutopilt) {
|
||||
module_mogo_och_autopilot_status!!.isClickable = true
|
||||
module_mogo_och_autopilot_status!!.setBackgroundResource(R.drawable.bus_autopilot_0_1_status_bg)
|
||||
} else {
|
||||
bus_autopolot_btn_tv!!.setTextColor(
|
||||
AbsMogoApplication.getApp()
|
||||
.getColor(R.color.bus_autopilot_text_color_disable)
|
||||
)
|
||||
bus_autopilot_btn_iv!!.setImageResource(R.drawable.bus_disable_autopilot_icon)
|
||||
module_mogo_och_autopilot_status!!.isClickable = true
|
||||
module_mogo_och_autopilot_status!!.setBackgroundResource(R.drawable.bus_autopilot_0_1_status_bg)
|
||||
}
|
||||
} else if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING == autopilotStatus) {
|
||||
bus_autopolot_btn_tv!!.setText(R.string.bus_loading_autopilot_runnig_tv)
|
||||
module_mogo_och_autopilot_status!!.isClickable = true
|
||||
module_mogo_och_autopilot_status!!.setBackgroundResource(R.drawable.bus_autopilot_2_status_bg)
|
||||
} else if (IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING
|
||||
== autopilotStatus
|
||||
) {
|
||||
bus_autopolot_btn_tv!!.setText(R.string.bus_pingxing_driver)
|
||||
module_mogo_och_autopilot_status!!.isClickable = false
|
||||
module_mogo_och_autopilot_status!!.setBackgroundResource(R.drawable.common_autopilot_pxjs)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun updateAutopilotStatus(autopilotStatus: Int) {
|
||||
if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING
|
||||
== autopilotStatus
|
||||
) { //2 running
|
||||
bus_autopilot_btn_iv!!.setImageResource(R.drawable.bus_right_autopilot_icon)
|
||||
bus_autopolot_btn_tv!!.setTextColor(getColor(R.color.bus_autopilot_text_color_normal))
|
||||
bus_autopolot_btn_tv!!.text =
|
||||
ResourcesUtils.getString(R.string.bus_loading_autopilot_success_tv)
|
||||
// ctvAutopilotStatus.setSelected(false);
|
||||
module_mogo_och_autopilot_status!!.isClickable = false
|
||||
} else {
|
||||
bus_autopilot_btn_iv!!.setImageResource(R.drawable.bus_wrong_autopilot_icon)
|
||||
bus_autopolot_btn_tv!!.setTextColor(getColor(R.color.bus_autopilot_text_color_normal))
|
||||
bus_autopolot_btn_tv!!.text =
|
||||
ResourcesUtils.getString(R.string.bus_loading_autopilot_failure_tv)
|
||||
module_mogo_och_autopilot_status!!.isClickable = false
|
||||
// ctvAutopilotStatus.setSelected(false);
|
||||
}
|
||||
UiThreadHandler.postDelayed({
|
||||
setAutopilotBtnStatus(
|
||||
autopilotStatus,
|
||||
isCanStartAutopilot(false, 0)
|
||||
)
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
private fun changeAutopilotBtnView(
|
||||
autopilotStatus: Int,
|
||||
isAnimateRunning: Boolean,
|
||||
canStartAutopilt: Boolean
|
||||
) {
|
||||
if (isAnimateRunning && IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING
|
||||
!= autopilotStatus
|
||||
) {
|
||||
// 主动开启自动驾驶中,不为2(为0、1)则继续loading
|
||||
return
|
||||
}
|
||||
if (isAnimateRunning) {
|
||||
stopAnimAndUpdateBtnStatus()
|
||||
} else {
|
||||
setAutopilotBtnStatus(autopilotStatus, canStartAutopilt)
|
||||
}
|
||||
}
|
||||
|
||||
fun stopAnimAndUpdateBtnStatus() {
|
||||
stopAutopilotAnimation()
|
||||
updateAutopilotStatus(getState())
|
||||
}
|
||||
|
||||
/**
|
||||
* 隐藏【自动驾驶】按钮
|
||||
*/
|
||||
fun hideAutopilotBiz() {}
|
||||
|
||||
/**
|
||||
* 展示【自动驾驶】按钮
|
||||
*/
|
||||
fun showAutopilotBiz() {}
|
||||
open val slidePanelOnEndListener: SlidePanelView.OnSlidePanelMoveToEndListener?
|
||||
get() = null
|
||||
|
||||
/**
|
||||
* 获取站点面板view,在[.initViews]时候添加到container中
|
||||
*
|
||||
* @return 站点面板view
|
||||
*/
|
||||
abstract val stationPanelViewId: Int
|
||||
|
||||
/**
|
||||
* 重新开启自动驾驶
|
||||
*/
|
||||
abstract fun restartAutopilot()
|
||||
|
||||
/**
|
||||
* 模拟自动驾驶返回状态
|
||||
*
|
||||
* @param status
|
||||
*/
|
||||
abstract fun debugAutoPilotStatus(status: Int)
|
||||
|
||||
/**
|
||||
* 开启自动驾驶中间动画
|
||||
*/
|
||||
fun startAutopilotAnimation() {
|
||||
isAnimateRunning = true
|
||||
bus_autopolot_btn_tv!!.text =
|
||||
ResourcesUtils.getString(R.string.bus_loading_autopilot_tv)
|
||||
bus_autopolot_btn_tv!!.setTextColor(getColor(R.color.bus_autopilot_text_color_normal))
|
||||
module_mogo_och_autopilot_status!!.isClickable = true
|
||||
bus_autopilot_btn_iv!!.setImageResource(R.drawable.bus_loading_autopilot_icon)
|
||||
if (autopilotLoadingAnimator == null) {
|
||||
autopilotLoadingAnimator =
|
||||
ObjectAnimator.ofFloat(bus_autopilot_btn_iv, "rotation", 0f, 360f)
|
||||
autopilotLoadingAnimator!!.interpolator = LinearInterpolator()
|
||||
autopilotLoadingAnimator!!.repeatCount = -1 //无限循环
|
||||
autopilotLoadingAnimator!!.setDuration(1000) //设置持续时间
|
||||
}
|
||||
autopilotLoadingAnimator!!.start() //动画开始
|
||||
startingAutoApilotCountDown()
|
||||
}
|
||||
|
||||
private fun startingAutoApilotCountDown() {
|
||||
//10s 若自动驾驶没有开启,则结束动画
|
||||
UiThreadHandler.postDelayed({ //未启动成功做处理
|
||||
if (isAnimateRunning) { // 只判断动画是否在进行,根据自动驾驶当前状态去设置自动驾驶状态
|
||||
stopAutopilotAnimation()
|
||||
updateAutopilotStatus(getState())
|
||||
}
|
||||
}, BusConst.TIMER_START_AUTOPILOT_INTERVAL)
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止自动驾驶中间动画
|
||||
*/
|
||||
protected fun stopAutopilotAnimation() {
|
||||
if (autopilotLoadingAnimator != null) {
|
||||
autopilotLoadingAnimator!!.end()
|
||||
bus_autopilot_btn_iv!!.clearAnimation()
|
||||
autopilotLoadingAnimator = null
|
||||
isAnimateRunning = false
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
/**
|
||||
* Bus调试信息:线路、轨迹等信息
|
||||
*
|
||||
*
|
||||
* START
|
||||
*/
|
||||
private var busTestBar: View? = null
|
||||
private var lineIdTV: TextView? = null
|
||||
private var lineNameTV: TextView? = null
|
||||
private var trajMd5TV: TextView? = null
|
||||
private var stopMd5TV: TextView? = null
|
||||
private var trajMd5DPQPTV: TextView? = null
|
||||
private var stopMd5DPQPTV: TextView? = null
|
||||
@SuppressLint("SetTextI18n")
|
||||
fun showHideTestBar() {
|
||||
if (busTestBar == null) {
|
||||
busTestBar = findViewById(R.id.module_mogo_och_bus_test_bar)
|
||||
lineIdTV = findViewById(R.id.bus_test_bar_current_line_id)
|
||||
lineNameTV = findViewById(R.id.bus_test_bar_current_line_name)
|
||||
trajMd5TV = findViewById(R.id.bus_test_bar_current_traj_md5)
|
||||
stopMd5TV = findViewById(R.id.bus_test_bar_current_stop_md5)
|
||||
trajMd5DPQPTV = findViewById(R.id.bus_test_bar_current_traj_md5_dpqp)
|
||||
stopMd5DPQPTV = findViewById(R.id.bus_test_bar_current_stop_md5_dpqp)
|
||||
}
|
||||
if (busTestBar!!.visibility == View.VISIBLE) {
|
||||
busTestBar!!.visibility = View.GONE
|
||||
} else {
|
||||
val routesResult = OrderModel.getInstance().busRoutesResult
|
||||
lineIdTV!!.text = "lineId:" + (routesResult?.lineId?.toString() ?: "")
|
||||
lineNameTV!!.text = "lineName:" + if (routesResult == null) "" else routesResult.name
|
||||
trajMd5TV!!.text = "TMd5:" + if (routesResult == null) "" else routesResult.csvFileMd5
|
||||
stopMd5TV!!.text = "SMd5:" + if (routesResult == null) "" else routesResult.txtFileMd5
|
||||
trajMd5DPQPTV!!.text =
|
||||
"TMd5DPQP:" + if (routesResult == null) "" else routesResult.csvFileMd5DPQP
|
||||
stopMd5DPQPTV!!.text =
|
||||
"SMd5DPQP:" + if (routesResult == null) "" else routesResult.txtFileMd5DPQP
|
||||
busTestBar!!.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
fun updateBusTestBarInfo() {
|
||||
if (busTestBar != null && busTestBar!!.visibility == View.VISIBLE) {
|
||||
val routesResult = OrderModel.getInstance().busRoutesResult
|
||||
lineIdTV!!.text = "lineId:" + (routesResult?.lineId?.toString() ?: "")
|
||||
lineNameTV!!.text = "lineName:" + if (routesResult == null) "" else routesResult.name
|
||||
trajMd5TV!!.text = "TMd5:" + if (routesResult == null) "" else routesResult.csvFileMd5
|
||||
stopMd5TV!!.text = "SMd5:" + if (routesResult == null) "" else routesResult.txtFileMd5
|
||||
trajMd5DPQPTV!!.text =
|
||||
"TMd5DPQP:" + if (routesResult == null) "" else routesResult.csvFileMd5DPQP
|
||||
stopMd5DPQPTV!!.text =
|
||||
"SMd5DPQP:" + if (routesResult == null) "" else routesResult.txtFileMd5DPQP
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,547 +0,0 @@
|
||||
package com.mogo.och.bus.fragment;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS;
|
||||
import static com.mogo.map.MogoMap.DEFAULT;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.constraintlayout.widget.Group;
|
||||
|
||||
import com.mogo.commons.storage.SharedPrefsMgr;
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
|
||||
import com.mogo.eagle.core.data.temp.EventLogout;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant;
|
||||
import com.mogo.eagle.core.utilcode.util.ActivityUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.map.overlay.IMoGoOverlayManager;
|
||||
import com.mogo.map.overlay.core.Level;
|
||||
import com.mogo.map.overlay.point.Point;
|
||||
import com.mogo.och.bus.R;
|
||||
import com.mogo.och.bus.bean.BusStationBean;
|
||||
import com.mogo.och.bus.constant.BusConst;
|
||||
import com.mogo.och.bus.presenter.BusPresenter;
|
||||
import com.mogo.och.bus.ui.BusStationCommonItem;
|
||||
import com.mogo.och.bus.ui.BusSwitchLineActivity;
|
||||
import com.mogo.och.bus.view.SlidePanelView;
|
||||
import com.mogo.och.common.module.utils.BlinkAnimationUtil;
|
||||
import com.mogo.och.common.module.utils.OCHThreadPoolManager;
|
||||
import com.mogo.och.common.module.utils.QRUtilsKt;
|
||||
import com.mogo.och.common.module.utils.ResourcesUtils;
|
||||
import com.mogo.och.common.module.wigets.BindQRCodeDialog;
|
||||
import com.mogo.och.common.module.wigets.MarqueeTextView;
|
||||
import com.mogo.och.common.module.wigets.OCHCommitDialog;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import me.jessyan.autosize.utils.AutoSizeUtils;
|
||||
|
||||
|
||||
/**
|
||||
* 网约车小巴界面
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class BusFragment extends BaseBusTabFragment<BusFragment, BusPresenter>
|
||||
implements SlidePanelView.OnSlidePanelMoveToEndListener, View.OnClickListener {
|
||||
public static final String TAG = "BusFragment";
|
||||
|
||||
private TextView mSwitchLine; //切换路线
|
||||
private MarqueeTextView mLineName;
|
||||
private TextView mTaskTime;
|
||||
private Group groupStationsPanel;
|
||||
private ConstraintLayout noDataView;
|
||||
|
||||
private BusStationBean startStation = null;
|
||||
private BusStationBean endStation = null;
|
||||
private BusStationCommonItem firstStationItem;
|
||||
private BusStationCommonItem secondStationItem;
|
||||
private BusStationCommonItem thirdStationItem;
|
||||
|
||||
@Override
|
||||
public String getTagName() {
|
||||
return "BusFragment";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
if (mPresenter != null) {
|
||||
mPresenter.onDestroy(this);
|
||||
}
|
||||
IMoGoOverlayManager overlayManager = CallerMapUIServiceManager.INSTANCE.getOverlayManager();
|
||||
if(overlayManager!=null) {
|
||||
overlayManager.removeAllLines();
|
||||
overlayManager.removeAllPoints();
|
||||
}
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initViews() {
|
||||
super.initViews();
|
||||
|
||||
mSwitchLine = findViewById(R.id.switch_line_btn);
|
||||
mSwitchLine.setTag(0);
|
||||
mLineName = findViewById(R.id.module_och_bus_line_name);
|
||||
|
||||
firstStationItem = findViewById(R.id.bus_panel_first_station);
|
||||
secondStationItem = findViewById(R.id.bus_panel_second_station);
|
||||
thirdStationItem = findViewById(R.id.bus_panel_third_station);
|
||||
mTaskTime = findViewById(R.id.bus_task_time_tv);
|
||||
groupStationsPanel = findViewById(R.id.group_stations_panel);
|
||||
noDataView = findViewById(R.id.no_line_data_view);
|
||||
|
||||
CallerLogger.d(M_BUS + TAG, "initView: " + CallerAutoPilotStatusListenerManager.INSTANCE.getState());
|
||||
// 初始化的时候设置 UI 按钮状态
|
||||
showAutopilotBiz();
|
||||
|
||||
mSwitchLine.setOnClickListener(this);
|
||||
|
||||
mLineName.setOnLongClickListener(v -> {
|
||||
showHideTestBar();
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void changeOverview(EventLogout eventLogout){
|
||||
if (eventLogout.getMessgae() == EventLogout.LOGOUT_TYPE){
|
||||
CallerLogger.d(M_BUS + TAG,"changeOverview Event消息去登出");
|
||||
mPresenter.logout();
|
||||
}else if (eventLogout.getMessgae() == EventLogout.SHOW_QR_TYPE){ //显示二维码
|
||||
CallerLogger.d(M_BUS + TAG,"changeOverview Event qrcode");
|
||||
String qrUrl = String.format(FunctionBuildConfig.urlJson.getBindDriverQRUrl(),
|
||||
SharedPrefsMgr.getInstance().getSn());
|
||||
Bitmap bmQr = QRUtilsKt.createQRCodeWithPicture(
|
||||
BitmapFactory.decodeResource(getResources(), R.drawable.icon_qr_center_logo)
|
||||
,qrUrl, AutoSizeUtils.dp2px(getContext(),340f),
|
||||
AutoSizeUtils.dp2px(getContext(),340f),true);
|
||||
if (bmQr != null){
|
||||
BindQRCodeDialog.Builder builder = new BindQRCodeDialog.Builder();
|
||||
builder.title(ResourcesUtils.getString(R.string.bind_driver_qr_title))
|
||||
.cancelStr(ResourcesUtils.getString(R.string.qr_cancel))
|
||||
.qrBm(bmQr).build(getContext()).show();
|
||||
}else {
|
||||
CallerLogger.d(M_BUS + TAG,"bmQr = null ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onArriveStation() {
|
||||
mPresenter.arriveStation(null,"点击进站触发进站操作");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void debugArrivedStation() {
|
||||
mPresenter.arriveStation(null,"点击debug进站按钮触发进站操作");
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected BusPresenter createPresenter() {
|
||||
return new BusPresenter(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
public void hideStationsPanel(){
|
||||
groupStationsPanel.setVisibility(View.GONE);
|
||||
noDataView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
public void showStationsPanel(){
|
||||
groupStationsPanel.setVisibility(View.VISIBLE);
|
||||
noDataView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
public void updateLineEmptyUI(){
|
||||
setArrivedClickable(false);
|
||||
showOrHideSwitchLineBtn(true);
|
||||
hideStationsPanel();
|
||||
hideSlidePanel();
|
||||
resetStationBlinkAnim();
|
||||
}
|
||||
|
||||
private void resetStationBlinkAnim() {
|
||||
BlinkAnimationUtil.clearAnimation(firstStationItem.getCircleImageView());
|
||||
BlinkAnimationUtil.clearAnimation(secondStationItem.getCircleImageView());
|
||||
BlinkAnimationUtil.clearAnimation(thirdStationItem.getCircleImageView());
|
||||
}
|
||||
|
||||
public void updateBusTaskStatus(String lineName, String lineTime,
|
||||
List<BusStationBean> stationList,
|
||||
int arrivingOrArrivedIndex,
|
||||
boolean isArrived){
|
||||
|
||||
if (getActivity() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
UiThreadHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (stationList == null) {
|
||||
// 获取小巴数据失败
|
||||
return;
|
||||
}
|
||||
|
||||
showStationsPanel();
|
||||
showOrHideSwitchLineBtn(false);
|
||||
|
||||
mLineName.setText(lineName);
|
||||
mTaskTime.setText(ResourcesUtils.getString(R.string.bus_line_time_tag)+ lineTime);
|
||||
// 渲染小巴路线数据
|
||||
updateBusStationStatus(stationList,arrivingOrArrivedIndex,isArrived);
|
||||
}
|
||||
},UiThreadHandler.MODE.QUEUE);
|
||||
}
|
||||
|
||||
private void updateBusStationStatus(List<BusStationBean> stationList,
|
||||
int arrivingOrArrivedIndex,
|
||||
boolean isArrived) {
|
||||
|
||||
startStation = stationList.get(0);
|
||||
endStation = stationList.get(stationList.size() - 1);
|
||||
|
||||
if (arrivingOrArrivedIndex == stationList.size() - 1 && isArrived){
|
||||
//切换路线和结束路线按钮切换
|
||||
showSlidePanel("单程结束");
|
||||
|
||||
setOrRemoveMapMaker(false, BusConst.BUS_END_MAP_MAKER, endStation.getLat()
|
||||
, endStation.getLon(),R.raw.end_marker);
|
||||
}else if (arrivingOrArrivedIndex == 0 && isArrived){
|
||||
|
||||
showSlidePanel("滑动出发");
|
||||
|
||||
setOrRemoveMapMaker(true, BusConst.BUS_START_MAP_MAKER,
|
||||
startStation.getLat(), startStation.getLon(),R.raw.star_marker);
|
||||
setOrRemoveMapMaker(true, BusConst.BUS_END_MAP_MAKER,
|
||||
endStation.getLat(), endStation.getLon(),R.raw.end_marker);
|
||||
}else{
|
||||
if (isArrived){
|
||||
// 重置滑动按钮文字
|
||||
showSlidePanel("滑动出发");
|
||||
}
|
||||
|
||||
setOrRemoveMapMaker(false, BusConst.BUS_START_MAP_MAKER, startStation.getLat()
|
||||
, startStation.getLon(),R.raw.star_marker);
|
||||
setOrRemoveMapMaker(true, BusConst.BUS_END_MAP_MAKER, endStation.getLat()
|
||||
, endStation.getLon(),R.raw.end_marker);
|
||||
}
|
||||
|
||||
if (stationList.size() > 2){ //只有两个站点
|
||||
updateMoreThanTwoStationsUI(stationList,arrivingOrArrivedIndex,isArrived);
|
||||
}else {
|
||||
updateTwoStationsUI(stationList,arrivingOrArrivedIndex,isArrived);
|
||||
}
|
||||
|
||||
updateBusTestBarInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* 有两个以上站点的路线
|
||||
* @param stationList
|
||||
* @param arrivingOrArrivedIndex
|
||||
* @param isArrived
|
||||
*/
|
||||
private void updateMoreThanTwoStationsUI(List<BusStationBean> stationList,
|
||||
int arrivingOrArrivedIndex,
|
||||
boolean isArrived) {
|
||||
secondStationItem.setStationTag("");
|
||||
secondStationItem.showOrHideStationArrowBg(true);
|
||||
thirdStationItem.setStationTag("");
|
||||
secondStationItem.setVisibility(View.VISIBLE);
|
||||
thirdStationItem.showOrHideStationArrowBg(false);
|
||||
|
||||
if (arrivingOrArrivedIndex == 0 || arrivingOrArrivedIndex -1 == 0
|
||||
|| (arrivingOrArrivedIndex -2 == 0 && stationList.size() == 3)){
|
||||
firstStationItem.setStationTag(ResourcesUtils.getString(R.string.bus_station_txt_tag_start));
|
||||
}else {
|
||||
firstStationItem.setStationTag("");
|
||||
}
|
||||
|
||||
if (arrivingOrArrivedIndex + 1 == stationList.size() - 1 || arrivingOrArrivedIndex == stationList.size() - 1
|
||||
|| (arrivingOrArrivedIndex == 0 && arrivingOrArrivedIndex + 2 == stationList.size() - 1)){ //确认是否显示 "终"
|
||||
thirdStationItem.setStationTag(ResourcesUtils.getString(R.string.bus_station_txt_tag_end));
|
||||
}else {
|
||||
thirdStationItem.setStationTag("");
|
||||
}
|
||||
|
||||
//圆点: 0:灰色 过站 1:绿色 到站或者即将到站 2:蓝色:未到站
|
||||
if (arrivingOrArrivedIndex == 0 && isArrived){
|
||||
firstStationItem.setStationNameColor(ResourcesUtils.getColor(R.color.bus_line_station_color_selected));
|
||||
secondStationItem.setStationNameColor(ResourcesUtils.getColor(R.color.bus_arrived_station_name_text_color));
|
||||
thirdStationItem.setStationNameColor(ResourcesUtils.getColor(R.color.bus_arrived_station_name_text_color));
|
||||
|
||||
firstStationItem.setStationName(stationList.get(0).getName());
|
||||
secondStationItem.setStationName(stationList.get(1).getName());
|
||||
thirdStationItem.setStationName(stationList.get(2).getName());
|
||||
|
||||
firstStationItem.setStationPointBg(1);
|
||||
secondStationItem.setStationPointBg(2);
|
||||
thirdStationItem.setStationPointBg(2);
|
||||
|
||||
firstStationItem.setStationArrowBg(2);
|
||||
secondStationItem.setStationArrowBg(2);
|
||||
|
||||
}else if (arrivingOrArrivedIndex == stationList.size() - 1){
|
||||
firstStationItem.setStationNameColor(ResourcesUtils.getColor(R.color.bus_station_tag_txt_un_color));
|
||||
secondStationItem.setStationNameColor(ResourcesUtils.getColor(R.color.bus_station_tag_txt_un_color));
|
||||
thirdStationItem.setStationNameColor(ResourcesUtils.getColor(R.color.bus_line_station_color_selected));
|
||||
|
||||
firstStationItem.setStationName(stationList.get(arrivingOrArrivedIndex -2).getName());
|
||||
secondStationItem.setStationName(stationList.get(arrivingOrArrivedIndex -1).getName());
|
||||
thirdStationItem.setStationName(stationList.get(arrivingOrArrivedIndex).getName());
|
||||
|
||||
firstStationItem.setStationPointBg(0);
|
||||
secondStationItem.setStationPointBg(0);
|
||||
thirdStationItem.setStationPointBg(1);
|
||||
|
||||
firstStationItem.setStationArrowBg(0);
|
||||
if (isArrived){
|
||||
secondStationItem.setStationArrowBg(0);
|
||||
}else {
|
||||
secondStationItem.setStationArrowBg(1);
|
||||
}
|
||||
|
||||
}else {
|
||||
firstStationItem.setStationNameColor(ResourcesUtils.getColor(R.color.bus_station_tag_txt_un_color));
|
||||
secondStationItem.setStationNameColor(ResourcesUtils.getColor(R.color.bus_line_station_color_selected));
|
||||
thirdStationItem.setStationNameColor(ResourcesUtils.getColor(R.color.bus_arrived_station_name_text_color));
|
||||
|
||||
firstStationItem.setStationName(stationList.get(arrivingOrArrivedIndex -1).getName());
|
||||
secondStationItem.setStationName(stationList.get(arrivingOrArrivedIndex).getName());
|
||||
thirdStationItem.setStationName(stationList.get(arrivingOrArrivedIndex + 1).getName());
|
||||
|
||||
firstStationItem.setStationPointBg(0);
|
||||
secondStationItem.setStationPointBg(1);
|
||||
thirdStationItem.setStationPointBg(2);
|
||||
|
||||
secondStationItem.setStationArrowBg(2);
|
||||
if (isArrived){
|
||||
firstStationItem.setStationArrowBg(0);
|
||||
}else {
|
||||
firstStationItem.setStationArrowBg(1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 只有两个站点的路线
|
||||
* @param stationList
|
||||
* @param arrivingOrArrivedIndex
|
||||
* @param isArrived
|
||||
*/
|
||||
private void updateTwoStationsUI(List<BusStationBean> stationList,
|
||||
int arrivingOrArrivedIndex,
|
||||
boolean isArrived) {
|
||||
|
||||
secondStationItem.setVisibility(View.GONE);
|
||||
secondStationItem.showOrHideStationArrowBg(false);
|
||||
thirdStationItem.showOrHideStationArrowBg(false);
|
||||
|
||||
firstStationItem.setStationTag(ResourcesUtils.getString(R.string.bus_station_txt_tag_start));
|
||||
thirdStationItem.setStationTag(ResourcesUtils.getString(R.string.bus_station_txt_tag_end));
|
||||
|
||||
firstStationItem.setStationName(stationList.get(0).getName());
|
||||
thirdStationItem.setStationName(stationList.get(1).getName());
|
||||
|
||||
//圆点: 0:灰色 过站 1:绿色 到站或者即将到站 2:蓝色:未到站
|
||||
if (arrivingOrArrivedIndex == 0 && isArrived){//到站
|
||||
firstStationItem.setStationNameColor(ResourcesUtils.getColor(R.color.bus_line_station_color_selected));
|
||||
thirdStationItem.setStationNameColor(ResourcesUtils.getColor(R.color.bus_arrived_station_name_text_color));
|
||||
firstStationItem.setStationPointBg(1);
|
||||
firstStationItem.setStationArrowBg(2);
|
||||
thirdStationItem.setStationPointBg(0);
|
||||
|
||||
}else {
|
||||
firstStationItem.setStationNameColor(ResourcesUtils.getColor(R.color.bus_station_tag_txt_un_color));
|
||||
thirdStationItem.setStationNameColor(ResourcesUtils.getColor(R.color.bus_line_station_color_selected));
|
||||
if (isArrived){ //到终点
|
||||
firstStationItem.setStationPointBg(0);
|
||||
firstStationItem.setStationArrowBg(0);
|
||||
thirdStationItem.setStationPointBg(1);
|
||||
|
||||
}else { //到终点途中
|
||||
firstStationItem.setStationPointBg(0);
|
||||
firstStationItem.setStationArrowBg(1);
|
||||
thirdStationItem.setStationPointBg(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void showOrHideSwitchLineBtn(boolean isShow) {
|
||||
if (isShow){//显示切换路线
|
||||
mSwitchLine.setTag(0);
|
||||
mSwitchLine.setText(ResourcesUtils.getString(R.string.bus_switch_line_btn));
|
||||
}else {//显示结束路线
|
||||
mSwitchLine.setTag(1);
|
||||
mSwitchLine.setText(ResourcesUtils.getString(R.string.bus_close_line_btn));
|
||||
}
|
||||
}
|
||||
|
||||
public void hideOchBus() {
|
||||
// tvNotice.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStationPanelViewId() {
|
||||
return R.layout.bug_fragment_och;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restartAutopilot() {
|
||||
if (!isAnimateRunning) {
|
||||
mPresenter.restartAutopilot();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SlidePanelView.OnSlidePanelMoveToEndListener getSlidePanelOnEndListener() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moveToEnd() {
|
||||
// 开启自动驾驶到下一站
|
||||
if (isAnimateRunning){
|
||||
stopAutopilotAnimation();
|
||||
}
|
||||
mPresenter.autoDriveToNextStation();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置自动驾驶可用状态
|
||||
*/
|
||||
public void onAutopilotEnableChange(boolean isEnable) {
|
||||
if (isEnable) {
|
||||
showAutopilotBiz();
|
||||
} else {
|
||||
hideAutopilotBiz();
|
||||
}
|
||||
}
|
||||
|
||||
public void clearBusStationsMarkers(){
|
||||
CallerLogger.d(M_BUS + TAG,"clearBusStationsMarkers()");
|
||||
if (null != startStation) {
|
||||
setOrRemoveMapMaker(false, BusConst.BUS_START_MAP_MAKER, startStation.getLat()
|
||||
, startStation.getLon(),R.raw.star_marker);
|
||||
}
|
||||
if (null != endStation) {
|
||||
setOrRemoveMapMaker(false, BusConst.BUS_END_MAP_MAKER, endStation.getLat()
|
||||
, endStation.getLon(),R.raw.end_marker);
|
||||
}
|
||||
|
||||
//清除鹰眼右下角小地图轨迹
|
||||
CallerLogger.d(SceneConstant.M_BUS, "clearBusStationsMarkers --------->");
|
||||
smallMapView.clearPolyline();
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制地图起点终点
|
||||
*
|
||||
* @param isAdd
|
||||
* @param uuid
|
||||
*/
|
||||
private void setOrRemoveMapMaker(boolean isAdd, String uuid, double lat, double longi,int resourceId) {
|
||||
if (isAdd) {
|
||||
Runnable setMapMarkerRunnable = () -> {
|
||||
CallerLogger.d(M_BUS + "setMapMaker= "+Thread.currentThread().getName(),
|
||||
uuid + "=latitude=" + lat + ",longitude=" + longi);
|
||||
|
||||
Point.Options.Builder builder = new Point.Options.Builder(BusConst.TYPE_MARKER_BUS_ORDER, Level.MAP_MARKER)
|
||||
.setId(uuid)
|
||||
.anchor(0.5f, 0.5f)
|
||||
.set3DMode(true)
|
||||
.isUseGps(true)
|
||||
.controlAngle(false)
|
||||
.icon3DRes(resourceId)
|
||||
.latitude(lat)
|
||||
.longitude(longi);
|
||||
IMoGoOverlayManager overlayManager = CallerMapUIServiceManager.INSTANCE.getOverlayManager();
|
||||
if (overlayManager != null) {
|
||||
overlayManager.showOrUpdatePoint(builder.build(), DEFAULT);
|
||||
}
|
||||
};
|
||||
|
||||
OCHThreadPoolManager.getsInstance().execute(setMapMarkerRunnable);
|
||||
|
||||
} else {
|
||||
Runnable removeMapMarkerRunnable = () -> {
|
||||
CallerLogger.d(M_BUS + "RemoveMapMaker="+Thread.currentThread().getName(),
|
||||
uuid+"=latitude="+lat+",longitude="+longi);
|
||||
IMoGoOverlayManager overlayManager = CallerMapUIServiceManager.INSTANCE.getOverlayManager();
|
||||
if (overlayManager != null) {
|
||||
overlayManager.removePoint(uuid);
|
||||
}
|
||||
};
|
||||
OCHThreadPoolManager.getsInstance().execute(removeMapMarkerRunnable);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debugAutoPilotStatus(int status) {
|
||||
mPresenter.debugAutoPilotStatus(status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v.getId() == R.id.switch_line_btn) {//切换路线条件: 自动驾驶过程中,点击则toast提示:自动驾驶中,不可切换路线
|
||||
//本次行程未结束,不支持切换路线。点击则toast提示:当前行程未完成,不可切换路线
|
||||
if (CallerAutoPilotStatusListenerManager.INSTANCE.getState()
|
||||
== IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) {
|
||||
ToastUtils.showLong(ResourcesUtils.getString(R.string.bus_switch_line_btn_warning1));
|
||||
return;
|
||||
}
|
||||
if ((int)mSwitchLine.getTag() == 0){//切换路线
|
||||
Intent intent = new Intent(getContext(), BusSwitchLineActivity.class);
|
||||
ActivityUtils.startActivity(intent);
|
||||
}else {//结束任务
|
||||
OCHCommitDialog.Builder builder = new OCHCommitDialog.Builder();
|
||||
OCHCommitDialog closeLineConfirmDialog = builder
|
||||
.title(ResourcesUtils.getString(R.string.bus_dialog_title))
|
||||
.tips(ResourcesUtils.getString(R.string.bus_dialog_tips))
|
||||
.confirmStr(ResourcesUtils.getString(R.string.bus_dialog_confirm))
|
||||
.cancelStr(ResourcesUtils.getString(R.string.bus_dialog_cancel))
|
||||
.build(getContext());
|
||||
closeLineConfirmDialog.setClickListener(new OCHCommitDialog.ClickListener() {
|
||||
@Override
|
||||
public void confirm() {
|
||||
mPresenter.abortTask();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
closeLineConfirmDialog.dismiss();
|
||||
}
|
||||
});
|
||||
closeLineConfirmDialog.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,512 @@
|
||||
package com.mogo.och.bus.fragment
|
||||
|
||||
import android.content.Intent
|
||||
import android.graphics.BitmapFactory
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import com.mogo.commons.storage.SharedPrefsMgr
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.data.temp.EventLogout
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager.getState
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager.getOverlayManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.eagle.core.utilcode.util.ActivityUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import com.mogo.map.MogoMap
|
||||
import com.mogo.map.overlay.core.Level
|
||||
import com.mogo.map.overlay.point.Point
|
||||
import com.mogo.och.bus.R
|
||||
import com.mogo.och.bus.bean.BusStationBean
|
||||
import com.mogo.och.bus.constant.BusConst
|
||||
import com.mogo.och.bus.presenter.BusPresenter
|
||||
import com.mogo.och.bus.ui.BusSwitchLineActivity
|
||||
import com.mogo.och.bus.view.SlidePanelView
|
||||
import com.mogo.och.common.module.utils.BlinkAnimationUtil
|
||||
import com.mogo.och.common.module.utils.OCHThreadPoolManager
|
||||
import com.mogo.och.common.module.utils.ResourcesUtils
|
||||
import com.mogo.och.common.module.utils.ResourcesUtils.getColor
|
||||
import com.mogo.och.common.module.utils.createQRCodeWithPicture
|
||||
import com.mogo.och.common.module.wigets.BindQRCodeDialog
|
||||
import com.mogo.och.common.module.wigets.OCHCommitDialog
|
||||
import kotlinx.android.synthetic.main.bug_fragment_och.bus_panel_first_station
|
||||
import kotlinx.android.synthetic.main.bug_fragment_och.bus_panel_second_station
|
||||
import kotlinx.android.synthetic.main.bug_fragment_och.bus_panel_third_station
|
||||
import kotlinx.android.synthetic.main.bug_fragment_och.bus_task_time_tv
|
||||
import kotlinx.android.synthetic.main.bug_fragment_och.group_stations_panel
|
||||
import kotlinx.android.synthetic.main.bug_fragment_och.module_och_bus_line_name
|
||||
import kotlinx.android.synthetic.main.bug_fragment_och.switch_line_btn
|
||||
import kotlinx.android.synthetic.main.bus_base_fragment.smallMapView
|
||||
import kotlinx.android.synthetic.main.bus_no_line_view.no_line_data_view
|
||||
import me.jessyan.autosize.utils.AutoSizeUtils
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
|
||||
/**
|
||||
* 网约车小巴界面
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
class BusFragment : BaseBusTabFragment<BusFragment?, BusPresenter?>(),
|
||||
SlidePanelView.OnSlidePanelMoveToEndListener, View.OnClickListener {
|
||||
private var startStation: BusStationBean? = null
|
||||
private var endStation: BusStationBean? = null
|
||||
override fun getTagName(): String {
|
||||
return "BusFragment"
|
||||
}
|
||||
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
if (mPresenter != null) {
|
||||
mPresenter!!.onDestroy(this)
|
||||
}
|
||||
val overlayManager = getOverlayManager()
|
||||
if (overlayManager != null) {
|
||||
overlayManager.removeAllLines()
|
||||
overlayManager.removeAllPoints()
|
||||
}
|
||||
super.onDestroyView()
|
||||
}
|
||||
|
||||
override fun initViews() {
|
||||
super.initViews()
|
||||
switch_line_btn!!.tag = 0
|
||||
d(SceneConstant.M_BUS + TAG, "initView: " + getState())
|
||||
// 初始化的时候设置 UI 按钮状态
|
||||
showAutopilotBiz()
|
||||
switch_line_btn!!.setOnClickListener(this)
|
||||
module_och_bus_line_name!!.setOnLongClickListener { v: View? ->
|
||||
showHideTestBar()
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun changeOverview(eventLogout: EventLogout) {
|
||||
if (eventLogout.messgae == EventLogout.LOGOUT_TYPE) {
|
||||
d(SceneConstant.M_BUS + TAG, "changeOverview Event消息去登出")
|
||||
mPresenter!!.logout()
|
||||
} else if (eventLogout.messgae == EventLogout.SHOW_QR_TYPE) { //显示二维码
|
||||
d(SceneConstant.M_BUS + TAG, "changeOverview Event qrcode")
|
||||
val qrUrl = String.format(
|
||||
FunctionBuildConfig.urlJson.bindDriverQRUrl,
|
||||
SharedPrefsMgr.getInstance().sn
|
||||
)
|
||||
val bmQr = createQRCodeWithPicture(
|
||||
BitmapFactory.decodeResource(resources, R.drawable.icon_qr_center_logo),
|
||||
qrUrl,
|
||||
AutoSizeUtils.dp2px(context, 340f),
|
||||
AutoSizeUtils.dp2px(context, 340f),
|
||||
true
|
||||
)
|
||||
if (bmQr != null) {
|
||||
context?.let {
|
||||
val builder = BindQRCodeDialog.Builder()
|
||||
builder.title(ResourcesUtils.getString(R.string.bind_driver_qr_title))
|
||||
.cancelStr(ResourcesUtils.getString(R.string.qr_cancel))
|
||||
.qrBm(bmQr).build(it)!!.show()
|
||||
}
|
||||
|
||||
} else {
|
||||
d(SceneConstant.M_BUS + TAG, "bmQr = null ")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onArriveStation() {
|
||||
mPresenter!!.arriveStation(null, "点击进站触发进站操作")
|
||||
}
|
||||
|
||||
override fun debugArrivedStation() {
|
||||
mPresenter!!.arriveStation(null, "点击debug进站按钮触发进站操作")
|
||||
}
|
||||
|
||||
override val stationPanelViewId: Int
|
||||
get() = R.layout.bug_fragment_och
|
||||
|
||||
override fun createPresenter(): BusPresenter {
|
||||
return BusPresenter(this)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
}
|
||||
|
||||
fun hideStationsPanel() {
|
||||
group_stations_panel!!.visibility = View.GONE
|
||||
no_line_data_view!!.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
fun showStationsPanel() {
|
||||
group_stations_panel!!.visibility = View.VISIBLE
|
||||
no_line_data_view!!.visibility = View.GONE
|
||||
}
|
||||
|
||||
fun updateLineEmptyUI() {
|
||||
setArrivedClickable(false)
|
||||
showOrHideSwitchLineBtn(true)
|
||||
hideStationsPanel()
|
||||
hideSlidePanel()
|
||||
resetStationBlinkAnim()
|
||||
}
|
||||
|
||||
private fun resetStationBlinkAnim() {
|
||||
BlinkAnimationUtil.clearAnimation(bus_panel_first_station!!.getCircleImageView())
|
||||
BlinkAnimationUtil.clearAnimation(bus_panel_second_station!!.getCircleImageView())
|
||||
BlinkAnimationUtil.clearAnimation(bus_panel_third_station!!.getCircleImageView())
|
||||
}
|
||||
|
||||
fun updateBusTaskStatus(
|
||||
lineName: String?, lineTime: String,
|
||||
stationList: List<BusStationBean>?,
|
||||
arrivingOrArrivedIndex: Int,
|
||||
isArrived: Boolean
|
||||
) {
|
||||
if (activity == null) {
|
||||
return
|
||||
}
|
||||
UiThreadHandler.post(Runnable {
|
||||
if (stationList == null) {
|
||||
// 获取小巴数据失败
|
||||
return@Runnable
|
||||
}
|
||||
showStationsPanel()
|
||||
showOrHideSwitchLineBtn(false)
|
||||
module_och_bus_line_name!!.text = lineName
|
||||
bus_task_time_tv!!.text = ResourcesUtils.getString(R.string.bus_line_time_tag) + lineTime
|
||||
// 渲染小巴路线数据
|
||||
updateBusStationStatus(stationList, arrivingOrArrivedIndex, isArrived)
|
||||
}, UiThreadHandler.MODE.QUEUE)
|
||||
}
|
||||
|
||||
private fun updateBusStationStatus(
|
||||
stationList: List<BusStationBean>,
|
||||
arrivingOrArrivedIndex: Int,
|
||||
isArrived: Boolean
|
||||
) {
|
||||
startStation = stationList[0]
|
||||
endStation = stationList[stationList.size - 1]
|
||||
if (arrivingOrArrivedIndex == stationList.size - 1 && isArrived) {
|
||||
//切换路线和结束路线按钮切换
|
||||
showSlidePanel("单程结束")
|
||||
setOrRemoveMapMaker(
|
||||
false,
|
||||
BusConst.BUS_END_MAP_MAKER,
|
||||
endStation!!.lat,
|
||||
endStation!!.lon,
|
||||
R.raw.end_marker
|
||||
)
|
||||
} else if (arrivingOrArrivedIndex == 0 && isArrived) {
|
||||
showSlidePanel("滑动出发")
|
||||
setOrRemoveMapMaker(
|
||||
true, BusConst.BUS_START_MAP_MAKER,
|
||||
startStation!!.lat, startStation!!.lon, R.raw.star_marker
|
||||
)
|
||||
setOrRemoveMapMaker(
|
||||
true, BusConst.BUS_END_MAP_MAKER,
|
||||
endStation!!.lat, endStation!!.lon, R.raw.end_marker
|
||||
)
|
||||
} else {
|
||||
if (isArrived) {
|
||||
// 重置滑动按钮文字
|
||||
showSlidePanel("滑动出发")
|
||||
}
|
||||
setOrRemoveMapMaker(
|
||||
false,
|
||||
BusConst.BUS_START_MAP_MAKER,
|
||||
startStation!!.lat,
|
||||
startStation!!.lon,
|
||||
R.raw.star_marker
|
||||
)
|
||||
setOrRemoveMapMaker(
|
||||
true,
|
||||
BusConst.BUS_END_MAP_MAKER,
|
||||
endStation!!.lat,
|
||||
endStation!!.lon,
|
||||
R.raw.end_marker
|
||||
)
|
||||
}
|
||||
if (stationList.size > 2) { //只有两个站点
|
||||
updateMoreThanTwoStationsUI(stationList, arrivingOrArrivedIndex, isArrived)
|
||||
} else {
|
||||
updateTwoStationsUI(stationList, arrivingOrArrivedIndex, isArrived)
|
||||
}
|
||||
updateBusTestBarInfo()
|
||||
}
|
||||
|
||||
/**
|
||||
* 有两个以上站点的路线
|
||||
* @param stationList
|
||||
* @param arrivingOrArrivedIndex
|
||||
* @param isArrived
|
||||
*/
|
||||
private fun updateMoreThanTwoStationsUI(
|
||||
stationList: List<BusStationBean>,
|
||||
arrivingOrArrivedIndex: Int,
|
||||
isArrived: Boolean
|
||||
) {
|
||||
bus_panel_second_station!!.setStationTag("")
|
||||
bus_panel_second_station!!.showOrHideStationArrowBg(true)
|
||||
bus_panel_third_station!!.setStationTag("")
|
||||
bus_panel_second_station!!.visibility = View.VISIBLE
|
||||
bus_panel_third_station!!.showOrHideStationArrowBg(false)
|
||||
if (arrivingOrArrivedIndex == 0 || arrivingOrArrivedIndex - 1 == 0 || arrivingOrArrivedIndex - 2 == 0 && stationList.size == 3) {
|
||||
bus_panel_first_station!!.setStationTag(ResourcesUtils.getString(R.string.bus_station_txt_tag_start))
|
||||
} else {
|
||||
bus_panel_first_station!!.setStationTag("")
|
||||
}
|
||||
if (arrivingOrArrivedIndex + 1 == stationList.size - 1 || arrivingOrArrivedIndex == stationList.size - 1 || arrivingOrArrivedIndex == 0 && arrivingOrArrivedIndex + 2 == stationList.size - 1) { //确认是否显示 "终"
|
||||
bus_panel_third_station!!.setStationTag(ResourcesUtils.getString(R.string.bus_station_txt_tag_end))
|
||||
} else {
|
||||
bus_panel_third_station!!.setStationTag("")
|
||||
}
|
||||
|
||||
//圆点: 0:灰色 过站 1:绿色 到站或者即将到站 2:蓝色:未到站
|
||||
if (arrivingOrArrivedIndex == 0 && isArrived) {
|
||||
bus_panel_first_station!!.setStationNameColor(getColor(R.color.bus_line_station_color_selected))
|
||||
bus_panel_second_station!!.setStationNameColor(getColor(R.color.bus_arrived_station_name_text_color))
|
||||
bus_panel_third_station!!.setStationNameColor(getColor(R.color.bus_arrived_station_name_text_color))
|
||||
bus_panel_first_station!!.setStationName(stationList[0].name)
|
||||
bus_panel_second_station!!.setStationName(stationList[1].name)
|
||||
bus_panel_third_station!!.setStationName(stationList[2].name)
|
||||
bus_panel_first_station!!.setStationPointBg(1)
|
||||
bus_panel_second_station!!.setStationPointBg(2)
|
||||
bus_panel_third_station!!.setStationPointBg(2)
|
||||
bus_panel_first_station!!.setStationArrowBg(2)
|
||||
bus_panel_second_station!!.setStationArrowBg(2)
|
||||
} else if (arrivingOrArrivedIndex == stationList.size - 1) {
|
||||
bus_panel_first_station!!.setStationNameColor(getColor(R.color.bus_station_tag_txt_un_color))
|
||||
bus_panel_second_station!!.setStationNameColor(getColor(R.color.bus_station_tag_txt_un_color))
|
||||
bus_panel_third_station!!.setStationNameColor(getColor(R.color.bus_line_station_color_selected))
|
||||
bus_panel_first_station!!.setStationName(stationList[arrivingOrArrivedIndex - 2].name)
|
||||
bus_panel_second_station!!.setStationName(stationList[arrivingOrArrivedIndex - 1].name)
|
||||
bus_panel_third_station!!.setStationName(stationList[arrivingOrArrivedIndex].name)
|
||||
bus_panel_first_station!!.setStationPointBg(0)
|
||||
bus_panel_second_station!!.setStationPointBg(0)
|
||||
bus_panel_third_station!!.setStationPointBg(1)
|
||||
bus_panel_first_station!!.setStationArrowBg(0)
|
||||
if (isArrived) {
|
||||
bus_panel_second_station!!.setStationArrowBg(0)
|
||||
} else {
|
||||
bus_panel_second_station!!.setStationArrowBg(1)
|
||||
}
|
||||
} else {
|
||||
bus_panel_first_station!!.setStationNameColor(getColor(R.color.bus_station_tag_txt_un_color))
|
||||
bus_panel_second_station!!.setStationNameColor(getColor(R.color.bus_line_station_color_selected))
|
||||
bus_panel_third_station!!.setStationNameColor(getColor(R.color.bus_arrived_station_name_text_color))
|
||||
bus_panel_first_station!!.setStationName(stationList[arrivingOrArrivedIndex - 1].name)
|
||||
bus_panel_second_station!!.setStationName(stationList[arrivingOrArrivedIndex].name)
|
||||
bus_panel_third_station!!.setStationName(stationList[arrivingOrArrivedIndex + 1].name)
|
||||
bus_panel_first_station!!.setStationPointBg(0)
|
||||
bus_panel_second_station!!.setStationPointBg(1)
|
||||
bus_panel_third_station!!.setStationPointBg(2)
|
||||
bus_panel_second_station!!.setStationArrowBg(2)
|
||||
if (isArrived) {
|
||||
bus_panel_first_station!!.setStationArrowBg(0)
|
||||
} else {
|
||||
bus_panel_first_station!!.setStationArrowBg(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 只有两个站点的路线
|
||||
* @param stationList
|
||||
* @param arrivingOrArrivedIndex
|
||||
* @param isArrived
|
||||
*/
|
||||
private fun updateTwoStationsUI(
|
||||
stationList: List<BusStationBean>,
|
||||
arrivingOrArrivedIndex: Int,
|
||||
isArrived: Boolean
|
||||
) {
|
||||
bus_panel_second_station!!.visibility = View.GONE
|
||||
bus_panel_second_station!!.showOrHideStationArrowBg(false)
|
||||
bus_panel_third_station!!.showOrHideStationArrowBg(false)
|
||||
bus_panel_first_station!!.setStationTag(ResourcesUtils.getString(R.string.bus_station_txt_tag_start))
|
||||
bus_panel_third_station!!.setStationTag(ResourcesUtils.getString(R.string.bus_station_txt_tag_end))
|
||||
bus_panel_first_station!!.setStationName(stationList[0].name)
|
||||
bus_panel_third_station!!.setStationName(stationList[1].name)
|
||||
|
||||
//圆点: 0:灰色 过站 1:绿色 到站或者即将到站 2:蓝色:未到站
|
||||
if (arrivingOrArrivedIndex == 0 && isArrived) { //到站
|
||||
bus_panel_first_station!!.setStationNameColor(getColor(R.color.bus_line_station_color_selected))
|
||||
bus_panel_third_station!!.setStationNameColor(getColor(R.color.bus_arrived_station_name_text_color))
|
||||
bus_panel_first_station!!.setStationPointBg(1)
|
||||
bus_panel_first_station!!.setStationArrowBg(2)
|
||||
bus_panel_third_station!!.setStationPointBg(0)
|
||||
} else {
|
||||
bus_panel_first_station!!.setStationNameColor(getColor(R.color.bus_station_tag_txt_un_color))
|
||||
bus_panel_third_station!!.setStationNameColor(getColor(R.color.bus_line_station_color_selected))
|
||||
if (isArrived) { //到终点
|
||||
bus_panel_first_station!!.setStationPointBg(0)
|
||||
bus_panel_first_station!!.setStationArrowBg(0)
|
||||
bus_panel_third_station!!.setStationPointBg(1)
|
||||
} else { //到终点途中
|
||||
bus_panel_first_station!!.setStationPointBg(0)
|
||||
bus_panel_first_station!!.setStationArrowBg(1)
|
||||
bus_panel_third_station!!.setStationPointBg(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showOrHideSwitchLineBtn(isShow: Boolean) {
|
||||
if (isShow) { //显示切换路线
|
||||
switch_line_btn!!.tag = 0
|
||||
switch_line_btn!!.text = ResourcesUtils.getString(R.string.bus_switch_line_btn)
|
||||
} else { //显示结束路线
|
||||
switch_line_btn!!.tag = 1
|
||||
switch_line_btn!!.text = ResourcesUtils.getString(R.string.bus_close_line_btn)
|
||||
}
|
||||
}
|
||||
|
||||
override fun restartAutopilot() {
|
||||
if (!isAnimateRunning) {
|
||||
mPresenter!!.restartAutopilot()
|
||||
}
|
||||
}
|
||||
|
||||
override fun moveToEnd() {
|
||||
// 开启自动驾驶到下一站
|
||||
if (isAnimateRunning) {
|
||||
stopAutopilotAnimation()
|
||||
}
|
||||
mPresenter!!.autoDriveToNextStation()
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置自动驾驶可用状态
|
||||
*/
|
||||
fun onAutopilotEnableChange(isEnable: Boolean) {
|
||||
if (isEnable) {
|
||||
showAutopilotBiz()
|
||||
} else {
|
||||
hideAutopilotBiz()
|
||||
}
|
||||
}
|
||||
|
||||
fun clearBusStationsMarkers() {
|
||||
d(SceneConstant.M_BUS + TAG, "clearBusStationsMarkers()")
|
||||
if (null != startStation) {
|
||||
setOrRemoveMapMaker(
|
||||
false,
|
||||
BusConst.BUS_START_MAP_MAKER,
|
||||
startStation!!.lat,
|
||||
startStation!!.lon,
|
||||
R.raw.star_marker
|
||||
)
|
||||
}
|
||||
if (null != endStation) {
|
||||
setOrRemoveMapMaker(
|
||||
false,
|
||||
BusConst.BUS_END_MAP_MAKER,
|
||||
endStation!!.lat,
|
||||
endStation!!.lon,
|
||||
R.raw.end_marker
|
||||
)
|
||||
}
|
||||
|
||||
//清除鹰眼右下角小地图轨迹
|
||||
d(SceneConstant.M_BUS, "clearBusStationsMarkers --------->")
|
||||
smallMapView.clearPolyline()
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制地图起点终点
|
||||
*
|
||||
* @param isAdd
|
||||
* @param uuid
|
||||
*/
|
||||
private fun setOrRemoveMapMaker(
|
||||
isAdd: Boolean,
|
||||
uuid: String,
|
||||
lat: Double,
|
||||
longi: Double,
|
||||
resourceId: Int
|
||||
) {
|
||||
if (isAdd) {
|
||||
val setMapMarkerRunnable = Runnable {
|
||||
d(
|
||||
SceneConstant.M_BUS + "setMapMaker= " + Thread.currentThread().name,
|
||||
"$uuid=latitude=$lat,longitude=$longi"
|
||||
)
|
||||
val builder =
|
||||
Point.Options.Builder(BusConst.TYPE_MARKER_BUS_ORDER, Level.MAP_MARKER)
|
||||
.setId(uuid)
|
||||
.anchor(0.5f, 0.5f)
|
||||
.set3DMode(true)
|
||||
.isUseGps(true)
|
||||
.controlAngle(false)
|
||||
.icon3DRes(resourceId)
|
||||
.latitude(lat)
|
||||
.longitude(longi)
|
||||
val overlayManager = getOverlayManager()
|
||||
overlayManager?.showOrUpdatePoint(builder.build(), MogoMap.DEFAULT)
|
||||
}
|
||||
OCHThreadPoolManager.getsInstance().execute(setMapMarkerRunnable)
|
||||
} else {
|
||||
val removeMapMarkerRunnable = Runnable {
|
||||
d(
|
||||
SceneConstant.M_BUS + "RemoveMapMaker=" + Thread.currentThread().name,
|
||||
"$uuid=latitude=$lat,longitude=$longi"
|
||||
)
|
||||
val overlayManager = getOverlayManager()
|
||||
overlayManager?.removePoint(uuid)
|
||||
}
|
||||
OCHThreadPoolManager.getsInstance().execute(removeMapMarkerRunnable)
|
||||
}
|
||||
}
|
||||
|
||||
override fun debugAutoPilotStatus(status: Int) {
|
||||
mPresenter!!.debugAutoPilotStatus(status)
|
||||
}
|
||||
|
||||
override fun onClick(v: View) {
|
||||
if (v.id == R.id.switch_line_btn) { //切换路线条件: 自动驾驶过程中,点击则toast提示:自动驾驶中,不可切换路线
|
||||
//本次行程未结束,不支持切换路线。点击则toast提示:当前行程未完成,不可切换路线
|
||||
if (getState()
|
||||
== IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING
|
||||
) {
|
||||
ToastUtils.showLong(ResourcesUtils.getString(R.string.bus_switch_line_btn_warning1))
|
||||
return
|
||||
}
|
||||
if (switch_line_btn!!.tag as Int == 0) { //切换路线
|
||||
val intent = Intent(context, BusSwitchLineActivity::class.java)
|
||||
ActivityUtils.startActivity(intent)
|
||||
} else { //结束任务
|
||||
context?.let {
|
||||
val builder = OCHCommitDialog.Builder()
|
||||
val closeLineConfirmDialog = builder
|
||||
.title(ResourcesUtils.getString(R.string.bus_dialog_title))
|
||||
.tips(ResourcesUtils.getString(R.string.bus_dialog_tips))
|
||||
.confirmStr(ResourcesUtils.getString(R.string.bus_dialog_confirm))
|
||||
.cancelStr(ResourcesUtils.getString(R.string.bus_dialog_cancel))
|
||||
.build(it)
|
||||
closeLineConfirmDialog!!.setClickListener(object : OCHCommitDialog.ClickListener {
|
||||
override fun confirm() {
|
||||
mPresenter!!.abortTask()
|
||||
}
|
||||
|
||||
override fun cancel() {
|
||||
closeLineConfirmDialog.dismiss()
|
||||
}
|
||||
})
|
||||
closeLineConfirmDialog.show()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override val slidePanelOnEndListener: SlidePanelView.OnSlidePanelMoveToEndListener
|
||||
get() = this
|
||||
|
||||
companion object {
|
||||
const val TAG = "BusFragment"
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -196,7 +196,7 @@
|
||||
android:id="@+id/module_mogo_och_station_panel_container"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/dp_13"
|
||||
android:layout_marginLeft="@dimen/dp_10"
|
||||
android:layout_marginTop="-24dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/module_mogo_och_autopilot_status"
|
||||
@@ -292,76 +292,6 @@
|
||||
app:textSize="@dimen/module_mogo_och_slide_panel_textSize"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnAutopilotDisable"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="#f00"
|
||||
android:text="Disable"
|
||||
android:textSize="@dimen/dp_60"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnAutopilotEnable"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="#0f0"
|
||||
android:text="Enable"
|
||||
android:textSize="@dimen/dp_60"
|
||||
app:layout_constraintRight_toRightOf="@id/btnAutopilotDisable"
|
||||
app:layout_constraintTop_toBottomOf="@id/btnAutopilotDisable" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnAutopilotRunning"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="#00f"
|
||||
android:text="Running"
|
||||
android:textSize="@dimen/dp_60"
|
||||
app:layout_constraintRight_toRightOf="@id/btnAutopilotDisable"
|
||||
app:layout_constraintTop_toBottomOf="@id/btnAutopilotEnable" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnAutopilotPingxing"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="#00f"
|
||||
android:text="pingxingjiashi"
|
||||
android:textSize="@dimen/dp_60"
|
||||
app:layout_constraintRight_toRightOf="@id/btnAutopilotDisable"
|
||||
app:layout_constraintTop_toBottomOf="@id/btnAutopilotRunning" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnAutopilotArrive"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="#f00"
|
||||
android:text="Arrived"
|
||||
android:textSize="@dimen/dp_60"
|
||||
app:layout_constraintRight_toRightOf="@id/btnAutopilotDisable"
|
||||
app:layout_constraintTop_toBottomOf="@id/btnAutopilotPingxing" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnAutopilotRoute"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="#023D35"
|
||||
android:text="上传全路径"
|
||||
android:textSize="@dimen/dp_60"
|
||||
app:layout_constraintRight_toRightOf="@id/btnAutopilotDisable"
|
||||
app:layout_constraintTop_toBottomOf="@id/btnAutopilotArrive"
|
||||
tools:ignore="TextContrastCheck" />
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/groupTestPanel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
app:constraint_referenced_ids="btnAutopilotArrive,btnAutopilotDisable,btnAutopilotEnable
|
||||
,btnAutopilotRunning,btnAutopilotRoute,btnAutopilotPingxing"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<com.mogo.eagle.core.function.smp.view.SmallMapView
|
||||
android:id="@+id/smallMapView"
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
Reference in New Issue
Block a user