From c995645c69e2586f29096385368f37f27fbb0d39 Mon Sep 17 00:00:00 2001 From: yangyakun Date: Sat, 14 Sep 2024 16:12:11 +0800 Subject: [PATCH] [6.7.0] [fea] [runningtask] --- .../module/manager/loop/BizLoopManager.kt | 11 + .../mogo/och/weaknet/ShuttleDriverProvider.kt | 2 +- .../callback/IBusADASStatusCallback.java | 4 - .../weaknet/callback/IBusLinesCallback.java | 8 + .../fragment/BaseShuttleTabFragment.kt | 511 ------------- .../och/weaknet/fragment/ShuttleFragment.kt | 671 ++++++++---------- .../mogo/och/weaknet/model/BusLineModel.kt | 41 +- .../com/mogo/och/weaknet/model/OrderModel.kt | 105 +-- .../mogo/och/weaknet/model/ThirdDeviceData.kt | 87 +++ .../och/weaknet/presenter/BusPresenter.kt | 26 +- .../weaknet/ui/bizswitch/SwtichBizeModel.kt | 8 + .../ui/taskrunned/RunningTaskManager.kt | 8 - .../ui/taskrunning/TaskRunningAdapter.kt | 35 +- .../ui/taskrunning/TaskRunningModel.kt | 38 +- .../weaknet/ui/taskrunning/TaskRunningView.kt | 57 +- .../och/weaknet/ui/writeoff/WriteOffView.kt | 35 +- .../weaknet/ui/writeoff/WriteOffViewModel.kt | 2 +- .../och/weaknet/view/BizLeaveStationView.kt | 5 + ...s_running_task_arrive_station_selector.xml | 8 + .../bus_running_task_complete_selector.xml | 8 + .../res/layout/shuttle_weak_base_fragment.xml | 163 ----- ...shuttle_weak_running_station_list_item.xml | 2 +- .../res/layout/shuttle_weak_task_running.xml | 28 + .../layout/shuttle_weak_wirte_off_view.xml | 10 +- .../src/main/res/values/strings.xml | 4 +- 25 files changed, 611 insertions(+), 1266 deletions(-) delete mode 100644 OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/fragment/BaseShuttleTabFragment.kt create mode 100644 OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/model/ThirdDeviceData.kt create mode 100644 OCH/shuttle/driver_weaknet/src/main/res/drawable/bus_running_task_arrive_station_selector.xml create mode 100644 OCH/shuttle/driver_weaknet/src/main/res/drawable/bus_running_task_complete_selector.xml diff --git a/OCH/common/common/src/main/java/com/mogo/och/common/module/manager/loop/BizLoopManager.kt b/OCH/common/common/src/main/java/com/mogo/och/common/module/manager/loop/BizLoopManager.kt index 19184579d7..375ed9880a 100644 --- a/OCH/common/common/src/main/java/com/mogo/och/common/module/manager/loop/BizLoopManager.kt +++ b/OCH/common/common/src/main/java/com/mogo/och/common/module/manager/loop/BizLoopManager.kt @@ -7,6 +7,7 @@ import android.os.Message 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.mogo.logger.scene.SceneConstant.Companion.M_BUS_P +import com.mogo.eagle.core.utilcode.util.ThreadUtils import com.mogo.och.common.module.utils.RxUtils import io.reactivex.Observable import io.reactivex.Observer @@ -130,4 +131,14 @@ object BizLoopManager { handler.removeCallbacks(function) } + fun runInMainThread(function: Runnable){ + if (ThreadUtils.isMainThread()) { + function.run() + }else{ + ThreadUtils.runOnUiThread({ + function.run() + },ThreadUtils.MODE.QUEUE) + } + } + } \ No newline at end of file diff --git a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ShuttleDriverProvider.kt b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ShuttleDriverProvider.kt index 2a947f54a6..d86abf8bd9 100644 --- a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ShuttleDriverProvider.kt +++ b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ShuttleDriverProvider.kt @@ -6,7 +6,6 @@ import com.alibaba.android.arouter.facade.annotation.Route 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.ThreadUtils -import com.mogo.och.weaknet.fragment.ShuttleFragment import com.mogo.och.common.module.constant.OchCommonConst import com.mogo.och.common.module.biz.provider.CommonServiceImpl import com.mogo.och.common.module.manager.autopilot.autopilot.OchAutopilotAnalytics @@ -14,6 +13,7 @@ import com.mogo.och.weaknet.database.repository.EventRepository import com.mogo.och.weaknet.database.repository.LineRepository import com.mogo.och.weaknet.database.repository.TaskRepository import com.mogo.och.weaknet.database.repository.TaskSiteRepository +import com.mogo.och.weaknet.fragment.ShuttleFragment import com.mogo.och.weaknet.model.BusLineModel import com.mogo.och.weaknet.util.BusAnalyticsManager diff --git a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/callback/IBusADASStatusCallback.java b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/callback/IBusADASStatusCallback.java index 61baba1ffc..5b64118b83 100644 --- a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/callback/IBusADASStatusCallback.java +++ b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/callback/IBusADASStatusCallback.java @@ -25,8 +25,4 @@ public interface IBusADASStatusCallback { * 结束清理一遍、选择任务后清理一遍 */ void clearBusStationsMarkers(); - - void updateEmptyUi(); - - void hideSlidePanel(); } diff --git a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/callback/IBusLinesCallback.java b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/callback/IBusLinesCallback.java index 68d9afcd74..7c8303e725 100644 --- a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/callback/IBusLinesCallback.java +++ b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/callback/IBusLinesCallback.java @@ -26,4 +26,12 @@ public interface IBusLinesCallback { default void onNoRunningTask(){} default void onRunningTask(){} + + default void onLeaveStaionSuccess(){} + + default void onLeaveStaionFail(){} + + default void onArriveStationSuccess(){} + + default void onCompleteTask(){} } diff --git a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/fragment/BaseShuttleTabFragment.kt b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/fragment/BaseShuttleTabFragment.kt deleted file mode 100644 index 72ac73b75d..0000000000 --- a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/fragment/BaseShuttleTabFragment.kt +++ /dev/null @@ -1,511 +0,0 @@ -package com.mogo.och.weaknet.fragment - -import android.animation.ObjectAnimator -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.constraintlayout.widget.Group -import androidx.core.content.ContextCompat -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.data.config.FunctionBuildConfig -import com.mogo.eagle.core.data.config.HdMapBuildConfig -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.autopilot.CallerAutopilotRecordListenerManager -import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager.attachAutopilotBeforeLaunchView -import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager.getMapUIController -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.AppIdentityModeUtils.isB1 -import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils.isB2 -import com.mogo.eagle.core.utilcode.mogo.view.OnPreventFastClickListener -import com.mogo.eagle.core.utilcode.util.UiThreadHandler -import com.mogo.map.MogoMap -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 com.mogo.och.common.module.wigets.SlidePanelView -import com.mogo.och.shuttle.weaknet.R -import com.mogo.och.weaknet.constant.BusConst -import com.mogo.och.weaknet.view.BizMapView -import org.greenrobot.eventbus.EventBus - -/** - * 网约车基础Fragment,主要负责布局通用界面,处理站点面板和通话面板互斥情况 - * - * - * 部分业务放在了此处处理 - * - * @author tongchenfei - */ -abstract class BaseShuttleTabFragment?> : MvpFragment() { - protected var slidePanelView: SlidePanelView? = null - private var ctvAutopilotStatus: RelativeLayout? = null - private var ctvAutopilotStatusIv: ImageView? = null - private var ctvAutopilotStatusTv: TextView? = null - protected var tvArrived: TextView? = null - private var flStationPanelContainer: FrameLayout? = null - private var mapBizView: BizMapView? = null - private var groupTestPanel: Group? = null - - protected var smallMapView: SmallMapView? = null - - //消息盒子 - private var viewDriverMsgBoxButton: DriverMsgBoxButtonView? = null - private var viewDriverMsgBoxList: DriverMsgBoxListView? = null - private var viewDriverMsgBoxBubble: DriverMsgBoxBubbleView? = null - - private var autopilotLoadingAnimator: ObjectAnimator? = null - - var isAnimateRunning: Boolean = false - - /** - * 滑动按钮触发的事件 - */ - private val onSlideToEndListener = SlidePanelView.OnSlidePanelMoveToEndListener { - // 此处做一个代理,处理一下共有情况 - if (slidePanelOnEndListener() != null) { - slidePanelOnEndListener()!!.moveToEnd() - } - } - - override fun getLayoutId(): Int { - return R.layout.shuttle_weak_base_fragment - } - - override fun 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) - - val flSpeed = findViewById(R.id.fl_speed) - if (flSpeed != null) { - attachAutopilotBeforeLaunchView(flSpeed.context, flSpeed) - } - - LayoutInflater.from(context).inflate(stationPanelViewId(), flStationPanelContainer) - slidePanelView!!.setOnSlidePanelMoveToEndListener(onSlideToEndListener) - - updateSwitchMapIcon() - - initListener() - setAutopilotBtnStatus( - getState(), - isCanStartAutopilot(false, 0) - ) - ctvAutopilotStatus!!.setOnClickListener(object : OnPreventFastClickListener() { - override fun onClickImpl(v: View) { - restartAutopilot() - } - }) - - // 模拟 不可自动驾驶,目前场景是刚开机,adas还未和工控机连接 - findViewById(R.id.btnAutopilotDisable)!!.setOnClickListener { view: View? -> - debugAutoPilotStatus( - IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE - ) - } - - // 模拟 可自动驾驶,工控机连接正常,且处于人工干预状态 - findViewById(R.id.btnAutopilotEnable)!!.setOnClickListener { view: View? -> - debugAutoPilotStatus( - IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE - ) - } - - // 模拟 自动驾驶能力,自动驾驶中,可能是停车,可能是行进,但是是机器在处理车的前进后退,不是人 - findViewById(R.id.btnAutopilotRunning)!!.setOnClickListener { view: View? -> - debugAutoPilotStatus( - IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING - ) - } - - findViewById(R.id.btnAutopilotPingxing)!!.setOnClickListener { view: View? -> - debugAutoPilotStatus( - IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING - ) - } - - // 模拟 自动驾驶网约车回调数据 - findViewById(R.id.btnAutopilotArrive)!!.setOnClickListener { view: View? -> debugArrivedStation() } - - tvArrived!!.setOnClickListener { view: View? -> - onArriveStation() - } - - //消息盒子 - viewDriverMsgBoxButton = findViewById(R.id.viewDriverMsgBoxButton) - viewDriverMsgBoxList = findViewById(R.id.viewDriverMsgBoxList) - viewDriverMsgBoxBubble = findViewById(R.id.viewDriverMsgBoxBubble) - 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) - } - } - }) - - smallMapView = findViewById(R.id.smallMapView) - } - - 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() - - private fun updateSwitchMapIcon() { - val mapUIController = getMapUIController(MogoMap.DEFAULT) - if (mapUIController != null) { - if (isB2(FunctionBuildConfig.appIdentityMode)) { - mapUIController.changeCurrentIcon(R.raw.m2) - HdMapBuildConfig.currentCarVrIconRes = R.raw.m2 - } else if (isB1(FunctionBuildConfig.appIdentityMode)) { - mapUIController.changeCurrentIcon(R.raw.xiaoba) - HdMapBuildConfig.currentCarVrIconRes = R.raw.xiaoba - } - } - } - - 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() - } - super.onDestroyView() - CallerAutopilotRecordListenerManager.removeListener(TAG) - EventBus.getDefault().unregister(this) - } - - /** - * 测试到站 - */ - protected abstract fun debugArrivedStation() - - private fun initListener() { - } - - /** - * 展示滑动按钮 - * - * @param text 指定的文字 - */ - fun showSlidePanel(text: String?) { - UiThreadHandler.post({ - slidePanelView!!.setText(text) - slidePanelView!!.visibility = View.VISIBLE - }, UiThreadHandler.MODE.QUEUE) - setArrivedClikable(false) - } - - /** - * 设置进站按钮状态 - * - * @param isClickable - */ - fun setArrivedClikable(isClickable: Boolean) { - UiThreadHandler.post({ - tvArrived!!.isEnabled = isClickable - if (isClickable) { - tvArrived!!.setTextColor( - ContextCompat.getColor( - AbsMogoApplication.getApp(), - R.color.bus_white - ) - ) - } else { - tvArrived!!.setTextColor( - ContextCompat.getColor( - AbsMogoApplication.getApp(), - R.color.bus_arrived_btn_un_clickable_color - ) - ) - } - }, UiThreadHandler.MODE.QUEUE) - } - - /** - * 隐藏滑动按钮 - */ - fun hideSlidePanel() { - UiThreadHandler.post( - { slidePanelView!!.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, canStartAuto: Boolean) { - UiThreadHandler.post({ - changeAutopilotBtnView( - autopilotStatus, - isAnimateRunning, - canStartAuto - ) - }, UiThreadHandler.MODE.QUEUE) - } - - fun setAutopilotBtnStatus(autopilotStatus: Int, canStartAuto: Boolean) { - if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE == autopilotStatus) { //0不可用 - ctvAutopilotStatusTv!!.setTextColor(getColor(R.color.bus_autopilot_text_color_disable)) - ctvAutopilotStatusTv!!.text = - ResourcesUtils.getString(R.string.bus_loading_autopilot_runnig_tv) - ctvAutopilotStatusIv!!.setImageResource(R.drawable.bus_disable_autopilot_icon) - ctvAutopilotStatus!!.isClickable = true - ctvAutopilotStatus!!.setBackgroundResource(R.drawable.common_autopilot_start_fail) - } 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!!.text = - ResourcesUtils.getString(R.string.bus_loading_autopilot_runnig_tv) - if (canStartAuto) { - ctvAutopilotStatus!!.isClickable = true - ctvAutopilotStatus!!.setBackgroundResource(R.drawable.common_autopilot_press) - } else { - ctvAutopilotStatusTv!!.setTextColor(getColor(R.color.bus_autopilot_text_color_disable)) - ctvAutopilotStatusIv!!.setImageResource(R.drawable.bus_disable_autopilot_icon) - ctvAutopilotStatus!!.isClickable = true - ctvAutopilotStatus!!.setBackgroundResource(R.drawable.common_autopilot_start_fail) - } - } else if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING == autopilotStatus) { - ctvAutopilotStatusTv!!.setText(R.string.bus_loading_autopilot_runnig_tv) - ctvAutopilotStatus!!.isClickable = true - ctvAutopilotStatus!!.setBackgroundResource(R.drawable.common_autopilot_in_autopilot) - } else if (IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING - == autopilotStatus - ) { - ctvAutopilotStatusTv!!.setText(R.string.bus_pingxing_driver) - ctvAutopilotStatus!!.isClickable = false - ctvAutopilotStatus!!.setBackgroundResource(R.drawable.common_autopilot_pxjs) - } - } - } - - fun updateAutopilotStatus(autopilotStatus: Int) { - if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING - == autopilotStatus - ) { //2 running - ctvAutopilotStatusIv!!.setImageResource(R.drawable.bus_right_autopilot_icon) - ctvAutopilotStatusTv!!.setTextColor(getColor(R.color.bus_autopilot_text_color_normal)) - ctvAutopilotStatusTv!!.text = - ResourcesUtils.getString(R.string.bus_loading_autopilot_success_tv) - // ctvAutopilotStatus.setSelected(false); - ctvAutopilotStatus!!.isClickable = false - } else { - ctvAutopilotStatusIv!!.setImageResource(R.drawable.bus_wrong_autopilot_icon) - ctvAutopilotStatusTv!!.setTextColor(getColor(R.color.bus_autopilot_text_color_normal)) - ctvAutopilotStatusTv!!.text = - ResourcesUtils.getString(R.string.bus_loading_autopilot_failure_tv) - ctvAutopilotStatus!!.isClickable = false - // ctvAutopilotStatus.setSelected(false); - } - UiThreadHandler.postDelayed({ - setAutopilotBtnStatus( - autopilotStatus, - isCanStartAutopilot(false, 0) - ) - }, 1000) - } - - private fun changeAutopilotBtnView( - autopilotStatus: Int, - isAnimateRunning: Boolean, - canStartAuto: Boolean - ) { - if (isAnimateRunning && (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING - != autopilotStatus) - ) { - // 主动开启自动驾驶中,不为2(为0、1)则继续loading - return - } - if (isAnimateRunning) { - stopAnimAndUpdateBtnStatus() - } else { - setAutopilotBtnStatus(autopilotStatus, canStartAuto) - } - } - - fun stopAnimAndUpdateBtnStatus() { - stopAutopilotAnimation() - updateAutopilotStatus(getState()) - } - - /** - * 隐藏【自动驾驶】按钮 - */ - fun hideAutopilotBiz() { - } - - /** - * 展示【自动驾驶】按钮 - */ - fun showAutopilotBiz() { - } - - abstract fun slidePanelOnEndListener(): SlidePanelView.OnSlidePanelMoveToEndListener? - - /** - * 获取站点面板view,在[.initViews]时候添加到container中 - * - * @return 站点面板view - */ - abstract fun stationPanelViewId(): Int - - /** - * 重新开启自动驾驶 - */ - abstract fun restartAutopilot() - - /** - * 模拟自动驾驶返回状态 - * - * @param status - */ - abstract fun debugAutoPilotStatus(status: Int) - - /** - * 开启自动驾驶中间动画 - */ - fun startAutopilotAnimation() { - isAnimateRunning = true - ctvAutopilotStatusTv!!.text = - ResourcesUtils.getString(R.string.bus_loading_autopilot_tv) - ctvAutopilotStatusTv!!.setTextColor(getColor(R.color.bus_autopilot_text_color_normal)) - ctvAutopilotStatus!!.isClickable = true - ctvAutopilotStatusIv!!.setImageResource(R.drawable.bus_loading_autopilot_icon) - if (autopilotLoadingAnimator == null) { - autopilotLoadingAnimator = ObjectAnimator.ofFloat(ctvAutopilotStatusIv!!, "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() - ctvAutopilotStatusIv!!.clearAnimation() - autopilotLoadingAnimator = null - isAnimateRunning = false - } - } - - // /** - // * 迈速表实时更新 - // * - // * @param newSpeed - // */ - // public void updateSpeedView(float newSpeed) { - // int speed = (int) (Math.abs(newSpeed) * 3.6F); // 倒车时工控机反馈定位信息中speed为负值 - // if (mTrafficDataView != null) { - // mTrafficDataView.updateSpeedWithValue(speed); - // } - // } - override fun onDestroy() { - super.onDestroy() - } - - /** - * bus调试面板打开关闭 - */ - fun debugTestBar() { - if (groupTestPanel!!.visibility == View.VISIBLE) { - groupTestPanel!!.visibility = View.GONE - } else { - groupTestPanel!!.visibility = View.VISIBLE - } - } - - - /** - * END - */ - companion object { - private const val TAG = "BaseBusTabFragment" - } -} diff --git a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/fragment/ShuttleFragment.kt b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/fragment/ShuttleFragment.kt index 32f913d235..842c037818 100644 --- a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/fragment/ShuttleFragment.kt +++ b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/fragment/ShuttleFragment.kt @@ -1,104 +1,323 @@ package com.mogo.och.weaknet.fragment +import android.animation.ObjectAnimator import android.graphics.BitmapFactory +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.constraintlayout.widget.ConstraintLayout -import androidx.constraintlayout.widget.Group import com.mogo.commons.AbsMogoApplication +import com.mogo.commons.mvp.MvpFragment import com.mogo.commons.storage.SharedPrefsMgr import com.mogo.eagle.core.data.config.FunctionBuildConfig +import com.mogo.eagle.core.data.config.HdMapBuildConfig 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.CallerAutoPilotControlManager.isCanStartAutopilot import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager.getState +import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotRecordListenerManager +import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager.attachAutopilotBeforeLaunchView +import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager.getMapUIController import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager.getOverlayManager +import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils.isB1 +import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils.isB2 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.mogo.view.OnPreventFastClickListener 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.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.MarqueeTextView -import com.mogo.och.common.module.wigets.OCHCommitDialog -import com.mogo.och.common.module.wigets.SlidePanelView -import com.mogo.och.data.bean.BusStationBean import com.mogo.och.shuttle.weaknet.R import com.mogo.och.weaknet.constant.BusConst import com.mogo.och.weaknet.presenter.BusPresenter -import com.mogo.och.weaknet.ui.BusStationCommonItem import com.mogo.och.weaknet.ui.taskrunned.RunningTaskManager +import com.mogo.och.weaknet.view.BizMapView import me.jessyan.autosize.utils.AutoSizeUtils +import org.greenrobot.eventbus.EventBus import org.greenrobot.eventbus.Subscribe import org.greenrobot.eventbus.ThreadMode /** - * 网约车小巴界面 + * 网约车基础Fragment,主要负责布局通用界面,处理站点面板和通话面板互斥情况 + * + * + * 部分业务放在了此处处理 * * @author tongchenfei */ -class ShuttleFragment : BaseShuttleTabFragment(), - SlidePanelView.OnSlidePanelMoveToEndListener, View.OnClickListener { +class ShuttleFragment : MvpFragment(), View.OnClickListener { + private var ctvAutopilotStatus: RelativeLayout? = null + private var ctvAutopilotStatusIv: ImageView? = null + private var ctvAutopilotStatusTv: TextView? = null + private var flStationPanelContainer: FrameLayout? = null + private var mapBizView: BizMapView? = null - private val TAG = "BusFragment" + private var autopilotLoadingAnimator: ObjectAnimator? = null - private var mSwitchLine: TextView? = null //切换路线 - private var mLineName: MarqueeTextView? = null - private var mTaskTime: TextView? = null - private var groupStationsPanel: Group? = null - private var noDataView: ConstraintLayout? = null - - private var startStation: BusStationBean? = null - private var endStation: BusStationBean? = null - private var firstStationItem: BusStationCommonItem? = null - private var secondStationItem: BusStationCommonItem? = null - private var thirdStationItem: BusStationCommonItem? = null + var isAnimateRunning: Boolean = false + override fun getLayoutId(): Int { + return R.layout.shuttle_weak_base_fragment + } override fun getTagName(): String { return "BusFragment" } + override fun initViews() { + mapBizView = findViewById(R.id.mapBizView) + 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) + + val flSpeed = findViewById(R.id.fl_speed) + if (flSpeed != null) { + attachAutopilotBeforeLaunchView(flSpeed.context, flSpeed) + } + + updateSwitchMapIcon() + + initListener() + setAutopilotBtnStatus( + getState(), + isCanStartAutopilot(false, 0) + ) + ctvAutopilotStatus!!.setOnClickListener(object : OnPreventFastClickListener() { + override fun onClickImpl(v: View) { + + } + }) + + } + + override fun initViews(savedInstanceState: Bundle?) { + super.initViews(savedInstanceState) + mapBizView!!.onCreate(savedInstanceState) + } + + override fun createPresenter(): BusPresenter { + return BusPresenter(this) + } + + override fun onResume() { + super.onResume() + mapBizView!!.onResume() + } + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + EventBus.getDefault().register(this) + return super.onCreateView(inflater, container, savedInstanceState) + } + + private fun updateSwitchMapIcon() { + val mapUIController = getMapUIController(MogoMap.DEFAULT) + if (mapUIController != null) { + if (isB2(FunctionBuildConfig.appIdentityMode)) { + mapUIController.changeCurrentIcon(R.raw.m2) + HdMapBuildConfig.currentCarVrIconRes = R.raw.m2 + } else if (isB1(FunctionBuildConfig.appIdentityMode)) { + mapUIController.changeCurrentIcon(R.raw.xiaoba) + HdMapBuildConfig.currentCarVrIconRes = R.raw.xiaoba + } + } + } + + 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() + } + override fun onDestroyView() { + mapBizView!!.onDestroy() if (mPresenter != null) { mPresenter!!.onDestroy(this) } - val overlayManager = getOverlayManager() - if (overlayManager != null) { - overlayManager.removeAllLines() - overlayManager.removeAllPoints() - } super.onDestroyView() + CallerAutopilotRecordListenerManager.removeListener(TAG) + EventBus.getDefault().unregister(this) } - override fun initViews() { - super.initViews() - - mSwitchLine = findViewById(R.id.switch_line_btn) - mSwitchLine!!.tag = 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) - - d(SceneConstant.M_BUS + TAG, "initView: " + getState()) - // 初始化的时候设置 UI 按钮状态 - showAutopilotBiz() - - mSwitchLine!!.setOnClickListener(this) - + private fun initListener() { } + /** + * 改变自动驾驶状态 + * + * @param autopilotStatus 0:不可用 1:可用状态 2:自动驾驶中 + */ + fun onAutopilotStatusChanged(autopilotStatus: Int, canStartAuto: Boolean) { + UiThreadHandler.post({ + changeAutopilotBtnView( + autopilotStatus, + isAnimateRunning, + canStartAuto + ) + }, UiThreadHandler.MODE.QUEUE) + } + + fun setAutopilotBtnStatus(autopilotStatus: Int, canStartAuto: Boolean) { + if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE == autopilotStatus) { //0不可用 + ctvAutopilotStatusTv!!.setTextColor(getColor(R.color.bus_autopilot_text_color_disable)) + ctvAutopilotStatusTv!!.text = + ResourcesUtils.getString(R.string.bus_loading_autopilot_runnig_tv) + ctvAutopilotStatusIv!!.setImageResource(R.drawable.bus_disable_autopilot_icon) + ctvAutopilotStatus!!.isClickable = true + ctvAutopilotStatus!!.setBackgroundResource(R.drawable.common_autopilot_start_fail) + } 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!!.text = + ResourcesUtils.getString(R.string.bus_loading_autopilot_runnig_tv) + if (canStartAuto) { + ctvAutopilotStatus!!.isClickable = true + ctvAutopilotStatus!!.setBackgroundResource(R.drawable.common_autopilot_press) + } else { + ctvAutopilotStatusTv!!.setTextColor(getColor(R.color.bus_autopilot_text_color_disable)) + ctvAutopilotStatusIv!!.setImageResource(R.drawable.bus_disable_autopilot_icon) + ctvAutopilotStatus!!.isClickable = true + ctvAutopilotStatus!!.setBackgroundResource(R.drawable.common_autopilot_start_fail) + } + } else if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING == autopilotStatus) { + ctvAutopilotStatusTv!!.setText(R.string.bus_loading_autopilot_runnig_tv) + ctvAutopilotStatus!!.isClickable = true + ctvAutopilotStatus!!.setBackgroundResource(R.drawable.common_autopilot_in_autopilot) + } else if (IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING + == autopilotStatus + ) { + ctvAutopilotStatusTv!!.setText(R.string.bus_pingxing_driver) + ctvAutopilotStatus!!.isClickable = false + ctvAutopilotStatus!!.setBackgroundResource(R.drawable.common_autopilot_pxjs) + } + } + } + + fun updateAutopilotStatus(autopilotStatus: Int) { + if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING + == autopilotStatus + ) { //2 running + ctvAutopilotStatusIv!!.setImageResource(R.drawable.bus_right_autopilot_icon) + ctvAutopilotStatusTv!!.setTextColor(getColor(R.color.bus_autopilot_text_color_normal)) + ctvAutopilotStatusTv!!.text = + ResourcesUtils.getString(R.string.bus_loading_autopilot_success_tv) + // ctvAutopilotStatus.setSelected(false); + ctvAutopilotStatus!!.isClickable = false + } else { + ctvAutopilotStatusIv!!.setImageResource(R.drawable.bus_wrong_autopilot_icon) + ctvAutopilotStatusTv!!.setTextColor(getColor(R.color.bus_autopilot_text_color_normal)) + ctvAutopilotStatusTv!!.text = + ResourcesUtils.getString(R.string.bus_loading_autopilot_failure_tv) + ctvAutopilotStatus!!.isClickable = false + // ctvAutopilotStatus.setSelected(false); + } + UiThreadHandler.postDelayed({ + setAutopilotBtnStatus( + autopilotStatus, + isCanStartAutopilot(false, 0) + ) + }, 1000) + } + + private fun changeAutopilotBtnView( + autopilotStatus: Int, + isAnimateRunning: Boolean, + canStartAuto: Boolean + ) { + if (isAnimateRunning && (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING + != autopilotStatus) + ) { + // 主动开启自动驾驶中,不为2(为0、1)则继续loading + return + } + if (isAnimateRunning) { + stopAnimAndUpdateBtnStatus() + } else { + setAutopilotBtnStatus(autopilotStatus, canStartAuto) + } + } + + fun stopAnimAndUpdateBtnStatus() { + stopAutopilotAnimation() + updateAutopilotStatus(getState()) + } + + /** + * 开启自动驾驶中间动画 + */ + fun startAutopilotAnimation() { + isAnimateRunning = true + ctvAutopilotStatusTv!!.text = + ResourcesUtils.getString(R.string.bus_loading_autopilot_tv) + ctvAutopilotStatusTv!!.setTextColor(getColor(R.color.bus_autopilot_text_color_normal)) + ctvAutopilotStatus!!.isClickable = true + ctvAutopilotStatusIv!!.setImageResource(R.drawable.bus_loading_autopilot_icon) + if (autopilotLoadingAnimator == null) { + autopilotLoadingAnimator = ObjectAnimator.ofFloat(ctvAutopilotStatusIv!!, "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() + ctvAutopilotStatusIv!!.clearAnimation() + autopilotLoadingAnimator = null + isAnimateRunning = false + } + } + + override fun onDestroy() { + super.onDestroy() + } + + @Subscribe(threadMode = ThreadMode.MAIN) fun changeOverview(eventLogout: EventLogout) { when (eventLogout.messgae) { @@ -138,317 +357,20 @@ class ShuttleFragment : BaseShuttleTabFragment( } } - override fun onArriveStation() { - mPresenter!!.onAutopilotArriveAtStation(null) - mPresenter!!.arriveStation(null, "点击进站触发进站操作") - } - - override fun debugArrivedStation() { - mPresenter!!.onAutopilotArriveAtStation(null) - mPresenter!!.arriveStation(null, "点击debug进站按钮触发进站操作") - } - - override fun createPresenter(): BusPresenter { - return BusPresenter(this) - } - - - private fun hideStationsPanel() { - groupStationsPanel!!.visibility = View.GONE - noDataView!!.visibility = View.VISIBLE - } - - private fun showStationsPanel() { - groupStationsPanel!!.visibility = View.VISIBLE - noDataView!!.visibility = View.GONE - } - - fun updateLineEmptyUI() { - setArrivedClikable(false) - showOrHideSwitchLineBtn(true) - hideStationsPanel() - hideSlidePanel() - resetStationBlinkAnim() - } - - private fun resetStationBlinkAnim() { - BlinkAnimationUtil.clearAnimation(firstStationItem!!.getCircleImageView()) - BlinkAnimationUtil.clearAnimation(secondStationItem!!.getCircleImageView()) - BlinkAnimationUtil.clearAnimation(thirdStationItem!!.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) - - mLineName?.text = lineName - mTaskTime?.text = ResourcesUtils.getString(R.string.shuttle_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) - } - - } - - /** - * 有两个以上站点的路线 - * @param stationList - * @param arrivingOrArrivedIndex - * @param isArrived - */ - private fun updateMoreThanTwoStationsUI( - stationList: List, - arrivingOrArrivedIndex: Int, - isArrived: Boolean - ) { - secondStationItem!!.setStationTag("") - secondStationItem!!.showOrHideStationArrowBg(true) - thirdStationItem!!.setStationTag("") - secondStationItem!!.visibility = 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(getColor(R.color.bus_line_station_color_selected)) - secondStationItem!!.setStationNameColor(getColor(R.color.bus_arrived_station_name_text_color)) - thirdStationItem!!.setStationNameColor(getColor(R.color.bus_arrived_station_name_text_color)) - - firstStationItem!!.setStationName(stationList[0].name) - secondStationItem!!.setStationName(stationList[1].name) - thirdStationItem!!.setStationName(stationList[2].name) - - firstStationItem!!.setStationPointBg(1) - secondStationItem!!.setStationPointBg(2) - thirdStationItem!!.setStationPointBg(2) - - firstStationItem!!.setStationArrowBg(2) - secondStationItem!!.setStationArrowBg(2) - } else if (arrivingOrArrivedIndex == stationList.size - 1) { - firstStationItem!!.setStationNameColor(getColor(R.color.bus_station_tag_txt_un_color)) - secondStationItem!!.setStationNameColor(getColor(R.color.bus_station_tag_txt_un_color)) - thirdStationItem!!.setStationNameColor(getColor(R.color.bus_line_station_color_selected)) - - firstStationItem!!.setStationName(stationList[arrivingOrArrivedIndex - 2].name) - secondStationItem!!.setStationName(stationList[arrivingOrArrivedIndex - 1].name) - thirdStationItem!!.setStationName(stationList[arrivingOrArrivedIndex].name) - - firstStationItem!!.setStationPointBg(0) - secondStationItem!!.setStationPointBg(0) - thirdStationItem!!.setStationPointBg(1) - - firstStationItem!!.setStationArrowBg(0) - if (isArrived) { - secondStationItem!!.setStationArrowBg(0) - } else { - secondStationItem!!.setStationArrowBg(1) - } - } else { - firstStationItem!!.setStationNameColor(getColor(R.color.bus_station_tag_txt_un_color)) - secondStationItem!!.setStationNameColor(getColor(R.color.bus_line_station_color_selected)) - thirdStationItem!!.setStationNameColor(getColor(R.color.bus_arrived_station_name_text_color)) - - firstStationItem!!.setStationName(stationList[arrivingOrArrivedIndex - 1].name) - secondStationItem!!.setStationName(stationList[arrivingOrArrivedIndex].name) - thirdStationItem!!.setStationName(stationList[arrivingOrArrivedIndex + 1].name) - - 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 fun updateTwoStationsUI( - stationList: List, - arrivingOrArrivedIndex: Int, - isArrived: Boolean - ) { - secondStationItem!!.visibility = 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[0].name) - thirdStationItem!!.setStationName(stationList[1].name) - - //圆点: 0:灰色 过站 1:绿色 到站或者即将到站 2:蓝色:未到站 - if (arrivingOrArrivedIndex == 0 && isArrived) { //到站 - firstStationItem!!.setStationNameColor(getColor(R.color.bus_line_station_color_selected)) - thirdStationItem!!.setStationNameColor(getColor(R.color.bus_arrived_station_name_text_color)) - firstStationItem!!.setStationPointBg(1) - firstStationItem!!.setStationArrowBg(2) - thirdStationItem!!.setStationPointBg(0) - } else { - firstStationItem!!.setStationNameColor(getColor(R.color.bus_station_tag_txt_un_color)) - thirdStationItem!!.setStationNameColor(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 fun showOrHideSwitchLineBtn(isShow: Boolean) { - if (isShow) { //显示切换路线 - mSwitchLine!!.tag = 0 - mSwitchLine!!.text = - ResourcesUtils.getString(R.string.bus_switch_line_btn) - } else { //显示结束路线 - mSwitchLine!!.tag = 1 - mSwitchLine!!.text = - ResourcesUtils.getString(R.string.bus_close_line_btn) - } - } - - fun hideOchBus() { -// tvNotice.setVisibility(View.GONE); - } - - override fun stationPanelViewId(): Int { - return R.layout.shuttle_weak_fragment_och - } - - override fun restartAutopilot() { - if (!isAnimateRunning) { - mPresenter!!.restartAutopilot() - } - } - - override fun slidePanelOnEndListener(): SlidePanelView.OnSlidePanelMoveToEndListener { - return this - } - - 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() +// 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 +// ) +// } } /** @@ -497,10 +419,6 @@ class ShuttleFragment : BaseShuttleTabFragment( } } - override fun debugAutoPilotStatus(status: Int) { - mPresenter!!.debugAutoPilotStatus(status) - } - override fun onClick(v: View) { if (v.id == R.id.switch_line_btn) { //切换路线条件: 自动驾驶过程中,点击则toast提示:自动驾驶中,不可切换路线 //本次行程未结束,不支持切换路线。点击则toast提示:当前行程未完成,不可切换路线 @@ -510,30 +428,13 @@ class ShuttleFragment : BaseShuttleTabFragment( ToastUtils.showLong(ResourcesUtils.getString(R.string.bus_switch_line_btn_warning1)) return } - if (mSwitchLine!!.tag as Int == 0) { //切换路线 - context?.let { - RunningTaskManager.showSwitchLineWindow(it) - } - } else { //结束任务 - val builder = OCHCommitDialog.Builder() - val closeLineConfirmDialog = builder - .title(getString(R.string.bus_dialog_title)) - .tips(getString(R.string.bus_dialog_tips)) - .confirmStr(getString(R.string.bus_dialog_confirm)) - .cancelStr(getString(R.string.bus_dialog_cancel)) - .build(AbsMogoApplication.getApp()) - closeLineConfirmDialog!!.setClickListener(object : OCHCommitDialog.ClickListener { - override fun confirm() { - mPresenter!!.abortTask() - } - - override fun cancel() { - closeLineConfirmDialog.dismiss() - } - }) - closeLineConfirmDialog.show() - } } } + /** + * END + */ + companion object { + private const val TAG = "BaseBusTabFragment" + } } diff --git a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/model/BusLineModel.kt b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/model/BusLineModel.kt index 53e5d70ba4..ac989146d8 100644 --- a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/model/BusLineModel.kt +++ b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/model/BusLineModel.kt @@ -77,9 +77,6 @@ object BusLineModel { // 当前任务的站点列表 var stationList:MutableList? = mutableListOf() - @JvmStatic - val busRoutesResult: BusRoutesResult = BusRoutesResult() - private val isRequesting = AtomicBoolean(false) private val loopQueryInfo = object :Runnable{ @@ -424,12 +421,15 @@ object BusLineModel { fun leaveStation(){ //开始站点: leaving false->true LineManager.getStartStation { - it.drivingStatus = TaskSiteDataBean.drivingStatusCurrent - it.isLeaving = true if (currentTask != null && currentTask!!.taskId != null) { currentTask?.let { task -> if (task.taskId!=null&&task.lineId!=null) { + it.drivingStatus = TaskSiteDataBean.drivingStatusCurrent + it.isLeaving = true TaskSiteRepository.updateLeave(task.taskId!!, it.siteId.toLong(), true) + mBusLinesCallbackMap.forEach {map-> + map.value.onLeaveStaionSuccess() + } OchChainLogManager.writeChainLogDb("滑动出发", "task:${currentTask}__taskId:${currentTask?.taskId}") // 设置滑动出发任务 LineManager.lineInfos?.lineName?.let { lineName-> @@ -445,6 +445,9 @@ object BusLineModel { } } } else { + mBusLinesCallbackMap.forEach {map-> + map.value.onLeaveStaionFail() + } OchChainLogManager.writeChainLog( "滑动出发_数据更新_error", "task:${currentTask}__taskId:${currentTask?.taskId}" @@ -490,6 +493,9 @@ object BusLineModel { stationList?.let { startStationIndex+=1 + mBusLinesCallbackMap.forEach { + it.value.onArriveStationSuccess() + } val startStation = LineManager.endStation if(startStationIndex+1< it.size){ val endStation = it[startStationIndex+1] @@ -509,7 +515,7 @@ object BusLineModel { fun getTaskTime():String { return DateTimeUtil.formatLongToString( - currentTask!!.taskStartTime!!, + currentTask?.taskStartTime?:System.currentTimeMillis(), DateTimeUtil.HH_mm ) } @@ -531,6 +537,9 @@ object BusLineModel { LineManager.setStartAndEndStation(null,null) stationList = mutableListOf() startStationIndex = 0 + mBusLinesCallbackMap.forEach { + it.value.onCompleteTask() + } } fun startTaskMessage():Boolean { @@ -558,24 +567,4 @@ object BusLineModel { } } - fun sendTaskDetailsToClients() { - if (LineManager.lineInfos==null||currentTask==null||stationList.isNullOrEmpty()) { - val data = BusTransferData(if (LoginStatusManager.isLogin()) 1 else 0, null) - val msg = TaskDetailsMsg(GsonUtils.toJson(data), BusinessType.shuttle) - d(M_BUS + TAG, "sendTaskDetailsToClients = " + GsonUtils.toJson(msg)) - LanSocketManager.sendMsgToClient(msg) - }else{ - busRoutesResult.setSite(stationList) - busRoutesResult.lineId = LineManager.lineInfos!!.lineId.toInt() - busRoutesResult.name = LineManager.lineInfos!!.lineName - busRoutesResult.taskId = currentTask!!.taskId!!.toInt() - busRoutesResult.taskTime = currentTask!!.taskStartTime!! - val data = BusTransferData(if (LoginStatusManager.isLogin()) 1 else 0, busRoutesResult) - val msg = TaskDetailsMsg(GsonUtils.toJson(data), BusinessType.shuttle) - d(M_BUS + TAG, "sendTaskDetailsToClients = " + GsonUtils.toJson(msg)) - LanSocketManager.sendMsgToClient(msg) - } - - } - } diff --git a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/model/OrderModel.kt b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/model/OrderModel.kt index 8bb51c8630..3e4d2e5c9c 100644 --- a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/model/OrderModel.kt +++ b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/model/OrderModel.kt @@ -140,7 +140,7 @@ object OrderModel { // 乘客屏请求线路信息 private val taskDetailsMsgListener = object : ILanMessageListener { override fun targetLan(): Class = TaskDetailsMsg::class.java - override fun onLanMsgReceived(taskDetailsMsg: TaskDetailsMsg?) = BusLineModel.sendTaskDetailsToClients() + override fun onLanMsgReceived(taskDetailsMsg: TaskDetailsMsg?) = ThirdDeviceData.sendTaskDetailsToClients() } @JvmStatic @@ -211,7 +211,6 @@ object OrderModel { BusLineModel.loadStartedTaskAndDefaultInfo() if(BusLineModel.stationList.isNullOrEmpty()){ d(M_BUS + TAG, "获取到小巴路线数据:空 ") - mADASStatusCallback?.updateEmptyUi() LineManager.setLineInfo(null); updateBusStatus() clearAutopilotControlParameters() @@ -288,9 +287,12 @@ object OrderModel { OCHThreadPoolManager.getsInstance().execute { d(M_BUS + TAG, "结束当前路线abortTask") - endOrAbortTaskSuccess() - clearBusStationDatas() - queryBusRoutes() + isGoingToNextStation = false + + ThirdDeviceData.endTask() + BusLineModel.endTask() + ThirdDeviceData.sendTaskDetailsToClients() + mADASStatusCallback?.clearBusStationsMarkers() removeTipRunnables() ShuttleVoiceManager.endOrderBus() // 取消自驾 @@ -299,27 +301,6 @@ object OrderModel { } } - /** - * 中断或者正常结束任务后的处理 - */ - private fun endOrAbortTaskSuccess() { - - isGoingToNextStation = false - - LineManager.lineInfos?.let { - LedScreenManager.sendTripInfo2Led( - LedScreenManager.END_TRIP, - it.lineName, - "", - "", - false - ) - } - BusLineModel.endTask() - - BusLineModel.sendTaskDetailsToClients() - } - private fun onStartAutopilot() { //开启自动驾驶 2.10.0: 如果自动驾驶状态下开启, 非自动驾驶状态下不开启,需手动点击自动驾驶按钮开启 isGoingToNextStation = true @@ -337,8 +318,6 @@ object OrderModel { * @param isRestart */ private fun startAutopilot(isRestart: Boolean) { - - val temp = initAutopilotControlParameters() /** * 存在Session */ @@ -412,45 +391,6 @@ object OrderModel { mADASStatusCallback?.startOpenAutopilot() } - /** - * 到站后重置站点状态 - */ - private fun arriveSiteStation(changeInfo: String) { - OchChainLogManager.writeChainLog("触发进站", changeInfo) - if (LineManager.endStation==null) { - e(M_BUS + TAG, "未设置终点坐标") - OchChainLogManager.writeChainLog("shuttle弱网","围栏距离判断 未设置终点坐标") - return - } - isArrivedStation = true - isGoingToNextStation = false - - arriveStationSuccess() - } - - private fun arriveStationSuccess() { - LineManager.getStations { start, end -> - ShuttleVoiceManager.arrivedStationBus(end.name, end.nameKr) - //给bus外屏发送 - LedScreenManager.sendTripInfo2Led( - LedScreenManager.ARRIVE_STATION, - LineManager.lineInfos!!.lineName, - start.name, - end.name, - BusLineModel.isLastStation()==true - ) - } - BusLineModel.arrivedStation() - updateBusStatus() - } - - //车站10s后播报 - private fun leaveTTSTips(nextStation: String?, nextStationKr: String?) { - UiThreadHandler.postDelayed({ //延迟10s播报 - ShuttleVoiceManager.leaveStationBus(nextStation, nextStationKr) - }, BusConst.DELAY_10S) - } - @JvmStatic fun startBeautificationMode() { FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = true @@ -488,17 +428,8 @@ object OrderModel { } isArrivedStation = false onStartAutopilot() - LineManager.getStations { start, end -> - leaveTTSTips(end.name, end.nameKr) - //给bus外屏发送 - LedScreenManager.sendTripInfo2Led( - LedScreenManager.LEAVE_STATION, - LineManager.lineInfos!!.lineName, - start.name, - end.name, - BusLineModel.isLastStation()==true - ) - } + + ThirdDeviceData.leaveStation() BusLineModel.leaveStation() @@ -532,14 +463,13 @@ object OrderModel { LineManager.getStartStation { if (it.isLeaving) { - mADASStatusCallback?.hideSlidePanel() isGoingToNextStation = true }else{ isGoingToNextStation = false } } - BusLineModel.sendTaskDetailsToClients() + ThirdDeviceData.sendTaskDetailsToClients() //更新bus路线面板 updateBusTaskStatus() @@ -605,13 +535,6 @@ object OrderModel { firstStartAutopilot = 0 } - - - @JvmStatic - fun clearBusStationDatas() { - mADASStatusCallback?.clearBusStationsMarkers() - } - /** * 在踩刹车、控制方向盘等操作后,会停止自动驾驶,重启自动驾驶的话相当于重新设置自动驾驶目的地 */ @@ -657,7 +580,13 @@ object OrderModel { if (isArrivedStation) return - arriveSiteStation(type) + OchChainLogManager.writeChainLog("触发进站", type) + isArrivedStation = true + isGoingToNextStation = false + + ThirdDeviceData.arriveStation() + BusLineModel.arrivedStation() + updateBusStatus() } // 登出 diff --git a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/model/ThirdDeviceData.kt b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/model/ThirdDeviceData.kt new file mode 100644 index 0000000000..3274f272c3 --- /dev/null +++ b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/model/ThirdDeviceData.kt @@ -0,0 +1,87 @@ +package com.mogo.och.weaknet.model + +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS +import com.mogo.eagle.core.utilcode.util.GsonUtils +import com.mogo.eagle.core.utilcode.util.UiThreadHandler +import com.mogo.och.common.module.biz.login.LoginStatusManager +import com.mogo.och.common.module.manager.autopilot.line.LineManager +import com.mogo.och.common.module.manager.socket.lan.LanSocketManager +import com.mogo.och.common.module.manager.socket.lan.LedScreenManager +import com.mogo.och.common.module.manager.socket.lan.bean.BusinessType +import com.mogo.och.common.module.manager.socket.lan.bean.TaskDetailsMsg +import com.mogo.och.data.bean.BusRoutesResult +import com.mogo.och.data.bean.BusTransferData +import com.mogo.och.weaknet.constant.BusConst +import com.mogo.och.weaknet.util.ShuttleVoiceManager + +object ThirdDeviceData { + + const val TAG = "ThirdDeviceData" + + @JvmStatic + val busRoutesResult: BusRoutesResult = BusRoutesResult() + + fun leaveStation(){ + LineManager.getStations { start, end -> + UiThreadHandler.postDelayed({ //延迟10s播报 + ShuttleVoiceManager.leaveStationBus(end.name, end.nameKr) + }, BusConst.DELAY_10S) + //给bus外屏发送 + LedScreenManager.sendTripInfo2Led( + LedScreenManager.LEAVE_STATION, + LineManager.lineInfos!!.lineName, + start.name, + end.name, + BusLineModel.isLastStation()==true + ) + } + } + + fun arriveStation(){ + LineManager.getStations { start, end -> + ShuttleVoiceManager.arrivedStationBus(end.name, end.nameKr) + //给bus外屏发送 + LedScreenManager.sendTripInfo2Led( + LedScreenManager.ARRIVE_STATION, + LineManager.lineInfos!!.lineName, + start.name, + end.name, + BusLineModel.isLastStation()==true + ) + } + } + + fun endTask(){ + LineManager.lineInfos?.let { + LedScreenManager.sendTripInfo2Led( + LedScreenManager.END_TRIP, + it.lineName, + "", + "", + false + ) + } + } + + fun sendTaskDetailsToClients() { + if (LineManager.lineInfos==null|| BusLineModel.currentTask ==null|| BusLineModel.stationList.isNullOrEmpty()) { + val data = BusTransferData(if (LoginStatusManager.isLogin()) 1 else 0, null) + val msg = TaskDetailsMsg(GsonUtils.toJson(data), BusinessType.shuttle) + d(M_BUS + TAG, "sendTaskDetailsToClients = " + GsonUtils.toJson(msg)) + LanSocketManager.sendMsgToClient(msg) + }else{ + busRoutesResult.setSite(BusLineModel.stationList) + busRoutesResult.lineId = LineManager.lineInfos!!.lineId.toInt() + busRoutesResult.name = LineManager.lineInfos!!.lineName + busRoutesResult.taskId = BusLineModel.currentTask!!.taskId!!.toInt() + busRoutesResult.taskTime = BusLineModel.currentTask!!.taskStartTime!! + val data = BusTransferData(if (LoginStatusManager.isLogin()) 1 else 0, busRoutesResult) + val msg = TaskDetailsMsg(GsonUtils.toJson(data), BusinessType.shuttle) + d(M_BUS + TAG, "sendTaskDetailsToClients = " + GsonUtils.toJson(msg)) + LanSocketManager.sendMsgToClient(msg) + } + + } + +} \ No newline at end of file diff --git a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/presenter/BusPresenter.kt b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/presenter/BusPresenter.kt index 7805905fbd..1da0c7a2c1 100644 --- a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/presenter/BusPresenter.kt +++ b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/presenter/BusPresenter.kt @@ -99,21 +99,11 @@ class BusPresenter(view: ShuttleFragment?) : Presenter(view), arrivingOrArrivedIndex - 1 } d(SceneConstant.M_BUS + "BusOrderModel =", " mCurrentStation =$mCurrentStation") - mView?.updateBusTaskStatus( - lineName, lineTime, - stationList, arrivingOrArrivedIndex, isArrived - ) } - override fun updateEmptyUi() { - UiThreadHandler.post({ - if (mView != null) { - mView!!.updateLineEmptyUI() - } - }, UiThreadHandler.MODE.QUEUE) - } override fun clearBusStationsMarkers() { + // TODO: 清理或展示地图 UiThreadHandler.post({ if (mView != null) { mView!!.clearBusStationsMarkers() @@ -121,13 +111,6 @@ class BusPresenter(view: ShuttleFragment?) : Presenter(view), }, UiThreadHandler.MODE.QUEUE) } - override fun hideSlidePanel() { - if (mView != null) { - mView!!.hideSlidePanel() - mView!!.setArrivedClikable(true) - } - } - override fun onAutopilotArriveAtStation(arrivedStation: ArrivedStation?) { e(SceneConstant.M_BUS + TAG, "行程日志-onAutopilotArriveAtStation arrive") arriveStation(arrivedStation, "底盘触发进站") @@ -165,9 +148,7 @@ class BusPresenter(view: ShuttleFragment?) : Presenter(view), } else -> UiThreadHandler.post({ - if (mView != null) { - mView!!.onAutopilotEnableChange(false) - } + }, UiThreadHandler.MODE.QUEUE) } } @@ -219,9 +200,6 @@ class BusPresenter(view: ShuttleFragment?) : Presenter(view), BusTrajectoryManager.getInstance().stopTrajReqLoop() BusTrajectoryManager.getInstance().stopTrajReqLoop() clearBusStationsMarkers() - if (mView != null) { - mView!!.hideSlidePanel() - } OrderModel.closeBeautificationMode() } } diff --git a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/bizswitch/SwtichBizeModel.kt b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/bizswitch/SwtichBizeModel.kt index e7a16205f9..373f0a2b50 100644 --- a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/bizswitch/SwtichBizeModel.kt +++ b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/bizswitch/SwtichBizeModel.kt @@ -74,5 +74,13 @@ class SwtichBizeModel : ViewModel(), IBusLinesCallback { this.viewCallback?.loadRunningTask() CallerLogger.d(TAG,"有任务去加载正在执行的任务") } + + + override fun onCompleteTask() { + super.onCompleteTask() + ThreadUtils.getIoPool().execute { + BusLineModel.loadStartedTaskAndDefaultInfo() + } + } } diff --git a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/taskrunned/RunningTaskManager.kt b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/taskrunned/RunningTaskManager.kt index e406f74abc..70c09b3a07 100644 --- a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/taskrunned/RunningTaskManager.kt +++ b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/taskrunned/RunningTaskManager.kt @@ -59,14 +59,6 @@ object RunningTaskManager : LifecycleEventObserver{ } } - /** - * 展示BadCase配置页面 - */ - fun showSwitchLineWindow(context: Context) { - val badCaseConfigView = SwitchBizView(context) - - } - override fun onStateChanged(source: LifecycleOwner, event: Event) { } diff --git a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/taskrunning/TaskRunningAdapter.kt b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/taskrunning/TaskRunningAdapter.kt index 2047f23ef4..1acb2e7f2a 100644 --- a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/taskrunning/TaskRunningAdapter.kt +++ b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/taskrunning/TaskRunningAdapter.kt @@ -16,6 +16,7 @@ import com.mogo.och.data.bean.BusStationBean import com.mogo.och.weaknet.bean.BusQueryLinesResponse import com.mogo.och.shuttle.weaknet.R import com.mogo.och.weaknet.bean.BusQueryLineTaskResponse +import com.mogo.och.weaknet.ui.writeoff.WriteOffView import me.jessyan.autosize.utils.AutoSizeUtils /** @@ -31,9 +32,9 @@ class TaskRunningAdapter( } private var startStationIndex:Int = -1 - @SuppressLint("NotifyDataSetChanged") fun setDataList(dataList: List, startStationIndex:Int) { this.startStationIndex = startStationIndex + val tempData = this.mData this.mData.clear() this.mData.addAll(dataList) notifyDataSetChanged() @@ -58,14 +59,17 @@ class TaskRunningAdapter( holder.actvStationName.setTextSize(TypedValue.COMPLEX_UNIT_PX, AutoSizeUtils.dp2px(mContext,40f).toFloat()) holder.actvStationName.setTextColor(ResourcesUtils.getColor(R.color.bus_color_4dffffff)) holder.itemView.background = null + holder.actvWriteOffCount.visibility = View.GONE }else if(currentPosition==startStationIndex){ holder.actvStationName.setTextSize(TypedValue.COMPLEX_UNIT_PX, AutoSizeUtils.dp2px(mContext,45f).toFloat()) holder.actvStationName.setTextColor(ResourcesUtils.getColor(R.color.bus_color_2EACFF)) holder.itemView.setBackgroundResource(R.drawable.bus_task_current_station_bg) + holder.actvWriteOffCount.visibility = View.VISIBLE }else{ holder.actvStationName.setTextColor(ResourcesUtils.getColor(R.color.white)) holder.actvStationName.setTextSize(TypedValue.COMPLEX_UNIT_PX, AutoSizeUtils.dp2px(mContext,40f).toFloat()) holder.itemView.background = null + holder.actvWriteOffCount.visibility = View.GONE } when (currentPosition) { @@ -96,34 +100,7 @@ class TaskRunningAdapter( val actvStationName: AppCompatTextView = itemView.findViewById(R.id.actv_station_name)//站点名称 val acivStationHead: AppCompatImageView = itemView.findViewById(R.id.aciv_station_head)//线路标识 val acivStationHeadBig: AppCompatImageView = itemView.findViewById(R.id.aciv_station_head_big)//线路标识 - val actvWriteOffCount: AppCompatTextView = itemView.findViewById(R.id.actv_write_off_count) //此战核销的人数 + val actvWriteOffCount: WriteOffView = itemView.findViewById(R.id.actv_write_off_count) //此战核销的人数 } - interface LineItemClickListener { - fun onItemClick(position: Int,close:Boolean) - } - - inner class MyDiffCallback(private val oldData:List, private val newData:List): - Callback(){ - override fun getOldListSize(): Int { - return oldData.size - } - - override fun getNewListSize(): Int { - return newData.size - } - - override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean { - val oldItem = oldData[oldItemPosition] - val newItem = newData[newItemPosition] - return oldItem == newItem - } - - override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean { - val oldItem = oldData[oldItemPosition] - val newItem = newData[newItemPosition] - return oldItem == newItem - } - - } } \ No newline at end of file diff --git a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/taskrunning/TaskRunningModel.kt b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/taskrunning/TaskRunningModel.kt index 6961eabe2d..57fdf43f32 100644 --- a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/taskrunning/TaskRunningModel.kt +++ b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/taskrunning/TaskRunningModel.kt @@ -3,6 +3,7 @@ package com.mogo.och.weaknet.ui.taskrunning import androidx.lifecycle.ViewModel import com.mogo.commons.storage.SharedPrefsMgr import com.mogo.eagle.core.utilcode.util.ThreadUtils +import com.mogo.och.common.module.manager.loop.BizLoopManager import com.mogo.och.common.module.utils.DateTimeUtil import com.mogo.och.weaknet.bean.BusQueryLinesResponse import com.mogo.och.weaknet.callback.IBusLinesCallback @@ -15,7 +16,7 @@ import com.mogo.och.weaknet.model.OrderModel * @description BadCase录包管理页面 * @since: 2022/12/15 */ -class TaskRunningModel : ViewModel() { +class TaskRunningModel : ViewModel(), IBusLinesCallback { private val TAG = TaskRunningModel::class.java.simpleName @@ -27,6 +28,7 @@ class TaskRunningModel : ViewModel() { fun setDistanceCallback(viewCallback:SwtichLineViewCallback){ this.viewCallback = viewCallback + BusLineModel.setBusLinesCallback(TAG,this) } fun leaveStation() { @@ -34,7 +36,41 @@ class TaskRunningModel : ViewModel() { } interface SwtichLineViewCallback{ + fun showRunningTaskInfo() + } + override fun onLeaveStaionSuccess() { + BizLoopManager.runInMainThread{ + viewCallback?.showRunningTaskInfo() + } + + } + + override fun onLeaveStaionFail() { + BizLoopManager.runInMainThread{ + viewCallback?.showRunningTaskInfo() + } + + } + + fun arriveStation() { + OrderModel.onArriveAt(null, "页面触发到站") + } + + override fun onArriveStationSuccess() { + BizLoopManager.runInMainThread{ + viewCallback?.showRunningTaskInfo() + } + } + + override fun onCompleteTask() { + BizLoopManager.runInMainThread{ + viewCallback?.showRunningTaskInfo() + } + } + + fun completeTask() { + OrderModel.abortTask() } } diff --git a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/taskrunning/TaskRunningView.kt b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/taskrunning/TaskRunningView.kt index 55ef1e14af..2cf1e04050 100644 --- a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/taskrunning/TaskRunningView.kt +++ b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/taskrunning/TaskRunningView.kt @@ -8,8 +8,13 @@ import androidx.constraintlayout.widget.ConstraintLayout import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.findViewTreeViewModelStoreOwner import androidx.recyclerview.widget.LinearLayoutManager +import com.mogo.commons.AbsMogoApplication +import com.mogo.eagle.core.utilcode.kotlin.onClick +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger import com.mogo.eagle.core.utilcode.mogo.view.SpacesItemDecoration import com.mogo.och.common.module.manager.autopilot.line.LineManager +import com.mogo.och.common.module.utils.ResourcesUtils +import com.mogo.och.common.module.wigets.OCHCommitDialog import com.mogo.och.shuttle.weaknet.R import com.mogo.och.weaknet.model.BusLineModel import com.mogo.och.weaknet.ui.bizswitch.SwtichBizeModel @@ -17,6 +22,8 @@ import com.mogo.och.weaknet.ui.switchline.SwitchLineAdapter import com.mogo.och.weaknet.view.BizLeaveStationView.SlideListener import kotlinx.android.synthetic.main.shuttle_weak_switch_line.view.switch_line_rv import kotlinx.android.synthetic.main.shuttle_weak_task_running.view.aciv_task_leave_station_slide_bg +import kotlinx.android.synthetic.main.shuttle_weak_task_running.view.actv_arriver_station +import kotlinx.android.synthetic.main.shuttle_weak_task_running.view.actv_complete_task import kotlinx.android.synthetic.main.shuttle_weak_task_running.view.actv_running_task_last_station import kotlinx.android.synthetic.main.shuttle_weak_task_running.view.actv_running_task_time import kotlinx.android.synthetic.main.shuttle_weak_task_running.view.bus_task_running_line_name @@ -45,9 +52,6 @@ class TaskRunningView: ConstraintLayout, TaskRunningModel.SwtichLineViewCallback private lateinit var mAdapter: TaskRunningAdapter - private var animator:ObjectAnimator?=null - - private lateinit var linearLayoutManager:LinearLayoutManager init { @@ -70,6 +74,28 @@ class TaskRunningView: ConstraintLayout, TaskRunningModel.SwtichLineViewCallback viewModel?.leaveStation() } }) + actv_arriver_station.onClick { + viewModel?.arriveStation() + } + actv_complete_task.onClick { + 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(AbsMogoApplication.getApp()) + closeLineConfirmDialog!!.setClickListener(object : OCHCommitDialog.ClickListener { + override fun confirm() { + viewModel?.completeTask() + } + + override fun cancel() { + closeLineConfirmDialog.dismiss() + } + }) + closeLineConfirmDialog.show() + } } override fun onAttachedToWindow() { @@ -84,13 +110,36 @@ class TaskRunningView: ConstraintLayout, TaskRunningModel.SwtichLineViewCallback viewModel?.setDistanceCallback(this) } - fun showRunningTaskInfo() { + override fun showRunningTaskInfo() { bus_task_running_line_name.text = LineManager.lineInfos?.lineName?:"" actv_running_task_time.text = BusLineModel.getTaskTime() BusLineModel.stationList?.takeIf { it.size>2 }?.let { actv_running_task_last_station.text = "往${it.last().name ?: ""}" mAdapter.setDataList(it,BusLineModel.startStationIndex) + CallerLogger.d(TAG,"BusLineModel.startStationIndex:${BusLineModel.startStationIndex}___$it") + val currentStation = it.get(BusLineModel.startStationIndex) + if(currentStation.isLeaving){ + showArriverStationAndCompleteTask() + }else{ + showLeaveStationView() + } + if(BusLineModel.startStationIndex==it.size-1){ + aciv_task_leave_station_slide_bg.setTextValue("单程结束") + }else{ + aciv_task_leave_station_slide_bg.setTextValue("滑动出发") + } } + } + fun showLeaveStationView(){ + aciv_task_leave_station_slide_bg.visibility = VISIBLE + actv_arriver_station.visibility = GONE + actv_complete_task.visibility = GONE + } + + fun showArriverStationAndCompleteTask(){ + aciv_task_leave_station_slide_bg.visibility = INVISIBLE + actv_arriver_station.visibility = VISIBLE + actv_complete_task.visibility = VISIBLE } } diff --git a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/writeoff/WriteOffView.kt b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/writeoff/WriteOffView.kt index 3660c95d5d..f81be538fb 100644 --- a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/writeoff/WriteOffView.kt +++ b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/writeoff/WriteOffView.kt @@ -3,13 +3,14 @@ package com.mogo.och.weaknet.ui.writeoff import android.content.Context import android.util.AttributeSet import android.view.LayoutInflater +import androidx.appcompat.widget.AppCompatTextView import androidx.constraintlayout.widget.ConstraintLayout import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.findViewTreeViewModelStoreOwner import com.mogo.och.shuttle.weaknet.R import kotlinx.android.synthetic.main.shuttle_weak_wirte_off_view.view.tv_write_off_count -class WriteOffView : ConstraintLayout, WriteOffViewModel.IwriteOffViewCallback { +class WriteOffView : AppCompatTextView, WriteOffViewModel.IwriteOffViewCallback { private val TAG = "ItineraryView" @@ -19,35 +20,45 @@ class WriteOffView : ConstraintLayout, WriteOffViewModel.IwriteOffViewCallback { constructor(context: Context, attributeSet: AttributeSet, defStyleAttr: Int) : super(context, attributeSet, defStyleAttr) - constructor(context: Context, attributeSet: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attributeSet, defStyleAttr, defStyleRes) - - private fun initView() { - LayoutInflater.from(context).inflate(R.layout.shuttle_weak_wirte_off_view, this, true) - } - + private var viewModel:WriteOffViewModel? = null override fun onAttachedToWindow() { super.onAttachedToWindow() - val viewModel = findViewTreeViewModelStoreOwner()?.let { + viewModel = findViewTreeViewModelStoreOwner()?.let { ViewModelProvider(it).get(WriteOffViewModel::class.java) } - - viewModel?.setWriteOffCallback(this) } + private fun startListenerWriteOff(){ + viewModel?.setWriteOffCallback(this) + visibility = VISIBLE + } + private fun stopListenerWriteOff(){ + viewModel?.setWriteOffCallback(null) + visibility = GONE + } + + override fun onVisibilityAggregated(isVisible: Boolean) { + super.onVisibilityAggregated(isVisible) + if(isVisible){ + startListenerWriteOff() + }else{ + stopListenerWriteOff() + } + } init { try { - initView() + } catch (e: Exception) { e.printStackTrace() } } override fun setWriteOffCount(showText: String) { - tv_write_off_count.text = showText + text = showText } diff --git a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/writeoff/WriteOffViewModel.kt b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/writeoff/WriteOffViewModel.kt index dce69c1fe9..4eafb93ba8 100644 --- a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/writeoff/WriteOffViewModel.kt +++ b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/writeoff/WriteOffViewModel.kt @@ -43,7 +43,7 @@ class WriteOffViewModel : ViewModel() { } - fun setWriteOffCallback(viewCallback: IwriteOffViewCallback) { + fun setWriteOffCallback(viewCallback: IwriteOffViewCallback?) { this.viewCallback = viewCallback TicketModel .getWriteOffCountObservable() diff --git a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/view/BizLeaveStationView.kt b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/view/BizLeaveStationView.kt index 32d0a3d972..72aa680c1f 100644 --- a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/view/BizLeaveStationView.kt +++ b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/view/BizLeaveStationView.kt @@ -10,6 +10,7 @@ import androidx.constraintlayout.widget.ConstraintLayout import androidx.constraintlayout.widget.ConstraintSet import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger import com.mogo.och.shuttle.weaknet.R +import kotlinx.android.synthetic.main.shuttle_weak_task_leave_station_view.view.actv_draggable class BizLeaveStationView @JvmOverloads constructor( context: Context, @@ -120,6 +121,10 @@ class BizLeaveStationView @JvmOverloads constructor( CallerLogger.d(TAG,"onDetachedFromWindow") } + fun setTextValue(value: String) { + actv_draggable.text = value + } + interface SlideListener{ fun slideEnd() } diff --git a/OCH/shuttle/driver_weaknet/src/main/res/drawable/bus_running_task_arrive_station_selector.xml b/OCH/shuttle/driver_weaknet/src/main/res/drawable/bus_running_task_arrive_station_selector.xml new file mode 100644 index 0000000000..67b7a651be --- /dev/null +++ b/OCH/shuttle/driver_weaknet/src/main/res/drawable/bus_running_task_arrive_station_selector.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/OCH/shuttle/driver_weaknet/src/main/res/drawable/bus_running_task_complete_selector.xml b/OCH/shuttle/driver_weaknet/src/main/res/drawable/bus_running_task_complete_selector.xml new file mode 100644 index 0000000000..67b7a651be --- /dev/null +++ b/OCH/shuttle/driver_weaknet/src/main/res/drawable/bus_running_task_complete_selector.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/OCH/shuttle/driver_weaknet/src/main/res/layout/shuttle_weak_base_fragment.xml b/OCH/shuttle/driver_weaknet/src/main/res/layout/shuttle_weak_base_fragment.xml index c2c46618e1..87828b1198 100644 --- a/OCH/shuttle/driver_weaknet/src/main/res/layout/shuttle_weak_base_fragment.xml +++ b/OCH/shuttle/driver_weaknet/src/main/res/layout/shuttle_weak_base_fragment.xml @@ -114,34 +114,6 @@ android:visibility="invisible" app:layout_constraintTop_toBottomOf="@+id/viewLimitingVelocity"/> - - - - - - - - - - - - - - - - - - -