diff --git a/OCH/bus/driver/src/main/java/com/mogo/och/bus/fragment/BaseBusTabFragment.java b/OCH/bus/driver/src/main/java/com/mogo/och/bus/fragment/BaseBusTabFragment.java deleted file mode 100644 index 94c56e8132..0000000000 --- a/OCH/bus/driver/src/main/java/com/mogo/och/bus/fragment/BaseBusTabFragment.java +++ /dev/null @@ -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,主要负责布局通用界面,处理站点面板和通话面板互斥情况 - *

- * 部分业务放在了此处处理 - * - * @author tongchenfei - */ -public abstract class BaseBusTabFragment> extends MvpFragment { - - 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调试信息:线路、轨迹等信息 - *

- * 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)); - } - } - -} diff --git a/OCH/bus/driver/src/main/java/com/mogo/och/bus/fragment/BaseBusTabFragment.kt b/OCH/bus/driver/src/main/java/com/mogo/och/bus/fragment/BaseBusTabFragment.kt new file mode 100644 index 0000000000..ef616aec9d --- /dev/null +++ b/OCH/bus/driver/src/main/java/com/mogo/och/bus/fragment/BaseBusTabFragment.kt @@ -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?> : MvpFragment() { + + //启动自驾动画 + 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 + } + } +} diff --git a/OCH/bus/driver/src/main/java/com/mogo/och/bus/fragment/BusFragment.java b/OCH/bus/driver/src/main/java/com/mogo/och/bus/fragment/BusFragment.java deleted file mode 100644 index 90d50e2aee..0000000000 --- a/OCH/bus/driver/src/main/java/com/mogo/och/bus/fragment/BusFragment.java +++ /dev/null @@ -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 - 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 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 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 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 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(); - } - } - } -} diff --git a/OCH/bus/driver/src/main/java/com/mogo/och/bus/fragment/BusFragment.kt b/OCH/bus/driver/src/main/java/com/mogo/och/bus/fragment/BusFragment.kt new file mode 100644 index 0000000000..c7d68826bd --- /dev/null +++ b/OCH/bus/driver/src/main/java/com/mogo/och/bus/fragment/BusFragment.kt @@ -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(), + 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?, + 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, + 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, + 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, + 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" + } +} diff --git a/OCH/bus/driver/src/main/java/com/mogo/och/bus/util/BDRouteDataTestUtils.java b/OCH/bus/driver/src/main/java/com/mogo/och/bus/util/BDRouteDataTestUtils.java deleted file mode 100644 index 51e2992206..0000000000 --- a/OCH/bus/driver/src/main/java/com/mogo/och/bus/util/BDRouteDataTestUtils.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.mogo.och.bus.util; - -import com.mogo.och.bus.model.OrderModel; - -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; - -import java.util.ArrayList; -import java.util.List; - -import mogo.telematics.pad.MessagePad; - -/** - * @author: wangmingjun - * @date: 2022/4/13 - */ -public class BDRouteDataTestUtils { - - static String jsonStr ="{\n" + - " \"models\": [\n" + - " {\n" + - " \"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19927760268911,\"lon\":116.73512607061035,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19927736555187,\"lon\":116.73498243020299,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19927135941599,\"lon\":116.73482951462647,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199260672670036,\"lon\":116.73468429259535,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199251260349946,\"lon\":116.73453933465,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19924691997577,\"lon\":116.7343756435551,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199247953493625,\"lon\":116.73421240809087,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19924986849947,\"lon\":116.73400425509712,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199249431152175,\"lon\":116.73378579041055,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199248921305724,\"lon\":116.73357811807278,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19925012387371,\"lon\":116.73337650020184,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199252270195075,\"lon\":116.73318223781153,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.1992521615169,\"lon\":116.73298632625203,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19925202633083,\"lon\":116.73279582043983,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199261230205735,\"lon\":116.73263403473568,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199327991681926,\"lon\":116.73251962434813,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19944850496711,\"lon\":116.73249661840195,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199582026896415,\"lon\":116.73251038561487,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199743326352014,\"lon\":116.73253087453938,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199908347167394,\"lon\":116.73255070500186,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.200065950595445,\"lon\":116.7325720694418,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20022747460407,\"lon\":116.73259461416663,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.200384057310536,\"lon\":116.73261575018056,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20053849777916,\"lon\":116.73263451936387,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.200696919444624,\"lon\":116.7326540541723,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.2008524952796,\"lon\":116.7326743511824,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20101429705625,\"lon\":116.73269393580199,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20118279997041,\"lon\":116.73271564378308,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.201342388452076,\"lon\":116.73273653366076,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.201476063822355,\"lon\":116.73275292393079,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20163479199852,\"lon\":116.73277440686762,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20181243476041,\"lon\":116.7328052766508,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.201991767093304,\"lon\":116.7328453845644,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20215573733484,\"lon\":116.73287624009339,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202313648759784,\"lon\":116.73289887933315,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202434745374454,\"lon\":116.7329182210956,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20253164952098,\"lon\":116.73297539811277,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20258043275509,\"lon\":116.73312335324984,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20258233576585,\"lon\":116.73331077089557,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20257107560234,\"lon\":116.73351244039137,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202561578580514,\"lon\":116.73370176209845,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20256256788661,\"lon\":116.73391325024126,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20255633158834,\"lon\":116.73413195000244,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202543311179575,\"lon\":116.73436614303907,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20253067346457,\"lon\":116.73458032609663,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20251776111356,\"lon\":116.73477082198242,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202503997557805,\"lon\":116.73498624001282,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20249129260376,\"lon\":116.73518976336872,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20247877796589,\"lon\":116.73537786253135,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20246651610268,\"lon\":116.73559239130266,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20245754388014,\"lon\":116.73574239922202,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20244749208,\"lon\":116.73589674090469,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20243806550113,\"lon\":116.73607057284322,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20243550556816,\"lon\":116.73628106525871,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20243654127756,\"lon\":116.7364949950665,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20243738221016,\"lon\":116.7367061649993,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20243672476754,\"lon\":116.73691115930336,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20243590788176,\"lon\":116.73710722104272,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202436434375336,\"lon\":116.73730688607075,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20243749821501,\"lon\":116.73750140347998,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20243625962803,\"lon\":116.73771330926793,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202434515480725,\"lon\":116.73791895606205,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.2024326561388,\"lon\":116.73815206945737,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20243092086137,\"lon\":116.73838655528765,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202430876006126,\"lon\":116.73861890759498,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20242914053177,\"lon\":116.73882029918758,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20242843336561,\"lon\":116.73904465495175,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20242661219026,\"lon\":116.73922453252953,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202426462811076,\"lon\":116.7393708046956,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20242687134937,\"lon\":116.73954685547025,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20242694967377,\"lon\":116.73975021183773,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202424630601236,\"lon\":116.73999740812975,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202422502184625,\"lon\":116.74028266774337,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202419634158936,\"lon\":116.7405942561498,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20241975959762,\"lon\":116.7409069557092,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20241920524113,\"lon\":116.74120156191647,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20241765540262,\"lon\":116.74149288504978,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20241569149764,\"lon\":116.7418080096762,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202414529497084,\"lon\":116.74210262897205,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20241419532155,\"lon\":116.74241767661879,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202413879360954,\"lon\":116.7427571218185,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20241287045245,\"lon\":116.7431284691325,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20241214965105,\"lon\":116.74343354359334,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20241141271715,\"lon\":116.7437220210538,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.2024080520075,\"lon\":116.74399113498052,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202391714280026,\"lon\":116.74427625698272,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20238163805639,\"lon\":116.74452083315958,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202379293010274,\"lon\":116.74475703837204,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202379007817086,\"lon\":116.7449961645494,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20237814181231,\"lon\":116.7452036063558,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202375477619896,\"lon\":116.74539567654291,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.2023632396621,\"lon\":116.74555457589031,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20229396554444,\"lon\":116.7456716047369,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20217800547467,\"lon\":116.74574081942625,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202047498095304,\"lon\":116.74573659255675,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20188573786706,\"lon\":116.74571018281719,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.201738240263026,\"lon\":116.74568463148606,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20157507049073,\"lon\":116.74565525041498,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20137985142042,\"lon\":116.745619970576,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.201187335613575,\"lon\":116.74558631350607,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20098251429043,\"lon\":116.74555055587679,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.2007748533628,\"lon\":116.74551426934663,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20057082986032,\"lon\":116.74547749663195,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20036944224329,\"lon\":116.74544156175533,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20016365229035,\"lon\":116.74540577510051,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.1999958572445,\"lon\":116.74537505807076,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19984100521566,\"lon\":116.7453433678602,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.1996863960282,\"lon\":116.74529675648621,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19953919567943,\"lon\":116.74525916493474,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19940587189373,\"lon\":116.74523402869453,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19929047792381,\"lon\":116.74518617038383,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19922141745155,\"lon\":116.74506912884067,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19920798885308,\"lon\":116.744896716334,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19920912644279,\"lon\":116.74467216715483,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199209186509314,\"lon\":116.74448257515108,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19920910709997,\"lon\":116.74430613406223,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.1992100786082,\"lon\":116.74410888316238,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19921081961254,\"lon\":116.74391968819582,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19921040855518,\"lon\":116.7437082083402,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19921085053439,\"lon\":116.74346931155634,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19921197237373,\"lon\":116.74325149697013,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19921248248983,\"lon\":116.74301103786591,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.1992139724646,\"lon\":116.74277237066539,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199215818352386,\"lon\":116.74253219408898,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199216175018876,\"lon\":116.74228853120842,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199215970354246,\"lon\":116.74204663206451,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199216627492966,\"lon\":116.74183871233049,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19921789170398,\"lon\":116.74165788334192,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19922000138535,\"lon\":116.74144512197054,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199221559127494,\"lon\":116.741249370491,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19922287231889,\"lon\":116.7410525810756,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19922229019589,\"lon\":116.74085266662037,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.1992216995901,\"lon\":116.74061957723823,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19922263073874,\"lon\":116.74041638149129,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19922478093337,\"lon\":116.7402123910757,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199227066091595,\"lon\":116.74003419421553,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199228634241756,\"lon\":116.73985841944678,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19922951636012,\"lon\":116.7397079274105,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199252095329484,\"lon\":116.73956265582487,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199346162997905,\"lon\":116.73944690416265,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199470799628024,\"lon\":116.73941941053417,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19962513314346,\"lon\":116.7394280706812,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199780626058924,\"lon\":116.73944255215424,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199961525343376,\"lon\":116.73945856750177,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20016196947193,\"lon\":116.73947572081121,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.200384479551936,\"lon\":116.7394949225795,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.200595083817475,\"lon\":116.73951027963179,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.200792203321086,\"lon\":116.73952526850614,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.200985930701684,\"lon\":116.73954125209579,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20115978977055,\"lon\":116.73955610094161,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.201321019536124,\"lon\":116.7395695239138,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20147117943043,\"lon\":116.7395823299481,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20163699848565,\"lon\":116.73959633422596,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20178484338371,\"lon\":116.7396085776486,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.201962185646316,\"lon\":116.73962351991214,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.2021018923927,\"lon\":116.7396354059821,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.2022137620686,\"lon\":116.73964348380458,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20232600820075,\"lon\":116.73961190446633,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20241090270993,\"lon\":116.73951649703137,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20245777783807,\"lon\":116.73937664238166,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20246906634823,\"lon\":116.73920146119093,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202470916682884,\"lon\":116.73898763065634,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20247034830421,\"lon\":116.73878158418357,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20246978204673,\"lon\":116.73857680142473,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20247082638905,\"lon\":116.73834517890637,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202471943178196,\"lon\":116.7381047689514,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20247131648035,\"lon\":116.73787761484981,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202470799473765,\"lon\":116.73766230702478,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20247013054322,\"lon\":116.73743619407796,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20246999515433,\"lon\":116.73724916823292,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20247199652478,\"lon\":116.73704888970806,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202473960263525,\"lon\":116.73684083235807,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202474504753205,\"lon\":116.73665462440796,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20247501354581,\"lon\":116.73650710371837,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20246541231906,\"lon\":116.73635807696789,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.202426768984274,\"lon\":116.73622283382787,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20236638788854,\"lon\":116.73610589402243,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20227106919894,\"lon\":116.73600895001849,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.2021428343084,\"lon\":116.73596816020945,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20197815580698,\"lon\":116.73594623645097,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20181789535303,\"lon\":116.73593148707488,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.201667906886954,\"lon\":116.73591743008926,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.201505897730755,\"lon\":116.7359002912543,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20135083580946,\"lon\":116.73588579696379,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20118617904595,\"lon\":116.73586970398149,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20102374028594,\"lon\":116.73585314703226,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20085554043743,\"lon\":116.73583763953049,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20069451888229,\"lon\":116.73582073901778,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.200530837344964,\"lon\":116.73580314359012,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.2003608457064,\"lon\":116.73578183888779,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20021770046798,\"lon\":116.73575292592922,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.20003454701824,\"lon\":116.7357174959358,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19986125116602,\"lon\":116.73569499961796,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19969408518737,\"lon\":116.73567725223492,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19955533048882,\"lon\":116.73566375985422,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19943174810538,\"lon\":116.73564927714162,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19933167546824,\"lon\":116.735595995086,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.199280357603875,\"lon\":116.73546293260645,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19927848361656,\"lon\":116.73531579486274,\"speed\":0.0},{\"altitude\":0.0,\"angle\":0.0,\"duration\":0,\"lat\":40.19928127892504,\"lon\":116.73505848474375,\"speed\": 0.0\n" + - " }\n" + - " ]\n" + - "}"; - public static void converToRouteData(){ - List list = new ArrayList<>(); - - try { - JSONObject jsonObject = new JSONObject(jsonStr); - JSONArray jsonElements = jsonObject.getJSONArray("models"); - for (int i = 0; i < jsonElements.length(); i++) { - JSONObject s = jsonElements.getJSONObject(i); - MessagePad.Location.Builder builder = MessagePad.Location.newBuilder(); - builder.setLatitude(s.getDouble("lat")); - builder.setLongitude(s.getDouble("lon")); - list.add(builder.build()); - } - } catch (JSONException e) { - e.printStackTrace(); - } - } -} diff --git a/OCH/bus/driver/src/main/res/layout/bus_base_fragment.xml b/OCH/bus/driver/src/main/res/layout/bus_base_fragment.xml index 4d1d290128..ea34dac8d9 100644 --- a/OCH/bus/driver/src/main/res/layout/bus_base_fragment.xml +++ b/OCH/bus/driver/src/main/res/layout/bus_base_fragment.xml @@ -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" /> -