From d1c951c2bf48181cb4001f4698e325401dd722ff Mon Sep 17 00:00:00 2001 From: yangyakun Date: Wed, 8 Nov 2023 16:23:50 +0800 Subject: [PATCH 1/3] =?UTF-8?q?[6.2.0]=20[charter=5Fp]=20[=E7=BE=8E?= =?UTF-8?q?=E5=8C=96=E6=A8=A1=E5=BC=8F]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../callback/IBeautifyModeCallback.kt | 7 + .../passenger/model/CharterPassengerModel.kt | 3 + .../presenter/BusPassengerPresenter.kt | 2 + .../passenger/ui/statusbar/StatusBarView.kt | 125 +++++++++++------- .../passenger/utils/BeautifyManager.kt | 61 +++++++++ 5 files changed, 151 insertions(+), 47 deletions(-) create mode 100644 OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/callback/IBeautifyModeCallback.kt create mode 100644 OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/utils/BeautifyManager.kt diff --git a/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/callback/IBeautifyModeCallback.kt b/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/callback/IBeautifyModeCallback.kt new file mode 100644 index 0000000000..8c8481f71d --- /dev/null +++ b/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/callback/IBeautifyModeCallback.kt @@ -0,0 +1,7 @@ +package com.mogo.och.charter.passenger.callback + +import com.mogo.och.charter.passenger.utils.BeautifyManager + +interface IBeautifyModeCallback { + fun dispatchStatus(typeEnum: BeautifyManager.ChangeTypeEnum) +} \ No newline at end of file diff --git a/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/model/CharterPassengerModel.kt b/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/model/CharterPassengerModel.kt index 7f7b84ffa4..9ecfcf55b4 100644 --- a/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/model/CharterPassengerModel.kt +++ b/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/model/CharterPassengerModel.kt @@ -30,6 +30,7 @@ import com.mogo.och.charter.passenger.callback.* import com.mogo.och.charter.passenger.constant.CharterPassengerConst import com.mogo.och.common.module.manager.loopmanager.BizLoopManager import com.mogo.och.charter.passenger.net.BusPassengerServiceManager +import com.mogo.och.charter.passenger.utils.BeautifyManager import com.mogo.och.common.module.wigets.toast.ToastCharterUtils import com.mogo.och.charter.passenger.utils.VoiceFocusManager import com.mogo.och.common.module.bean.dpmsg.BaseDPMsg @@ -736,6 +737,7 @@ object CharterPassengerModel { d(M_BUS_P + TAG, "${this.orderInfo?.orderNo}新的状态:$orderStatus") OchChainLogManager.writeChainLog(this.orderInfo.toString(),"新的状态:$orderStatus") this.orderStatus = orderStatus + BeautifyManager.notifyViewChange(BeautifyManager.ChangeTypeEnum.ORDER_STATU_CHANGE) for (callback in orderStatusChangeListeners.values) { callback.onStatusChange(this.orderStatus) } @@ -964,6 +966,7 @@ object CharterPassengerModel { if (order != null && lineId != null && siteId != null) { OchChainLogManager.writeChainLog(this.orderInfo.toString(),"到站成功:${order.siteName}") + BeautifyManager.notifyViewChange(BeautifyManager.ChangeTypeEnum.ARRIVED_DEST) VoiceManager.arrivedStation( order.siteName!!, order.siteNameKr ?: "", diff --git a/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/presenter/BusPassengerPresenter.kt b/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/presenter/BusPassengerPresenter.kt index 5cc59a047f..4162fb60b3 100644 --- a/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/presenter/BusPassengerPresenter.kt +++ b/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/presenter/BusPassengerPresenter.kt @@ -32,6 +32,7 @@ import com.mogo.och.charter.passenger.receive.DriverMessage import com.mogo.och.charter.passenger.ui.MainFragment import com.mogo.och.charter.passenger.ui.overmapview.MakerWithSiteName import com.mogo.och.charter.passenger.ui.overmapview.MakerWithSiteNamewithCheck +import com.mogo.och.charter.passenger.utils.BeautifyManager import com.mogo.och.common.module.biz.network.OchCommonServiceCallback import com.mogo.och.common.module.manager.autopilotmanager.OCHAdasAbilityManager import com.mogo.och.common.module.manager.stopsidemanager.StopSideManager @@ -208,6 +209,7 @@ class BusPassengerPresenter(view: MainFragment?) : } StopSideStatus.EndingSuccess -> { + BeautifyManager.notifyViewChange(BeautifyManager.ChangeTypeEnum.STOPSITE_SUCCESS) ToastCharterUtils.showToastShort("靠边停车成功") VoiceNotice.showNotice( context.getString(R.string.charter_p_stop_site_success), diff --git a/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/ui/statusbar/StatusBarView.kt b/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/ui/statusbar/StatusBarView.kt index 888bdb0c7a..2a1d837714 100644 --- a/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/ui/statusbar/StatusBarView.kt +++ b/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/ui/statusbar/StatusBarView.kt @@ -1,6 +1,5 @@ package com.mogo.och.charter.passenger.ui.statusbar -import android.annotation.SuppressLint import android.content.Context import android.os.SystemClock import android.util.AttributeSet @@ -14,22 +13,25 @@ import chassis.ChassisStatesOuterClass import com.mogo.eagle.core.data.config.FunctionBuildConfig import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener import com.mogo.eagle.core.function.api.autopilot.IMoGoBatteryManagementSystemListener -import com.mogo.eagle.core.function.api.hmi.view.IViewControlListener -import com.mogo.eagle.core.function.api.setting.IMoGoSkinModeChangeListener import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager import com.mogo.eagle.core.function.call.autopilot.CallerBatteryManagementSystemListenerManager +import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager -import com.mogo.eagle.core.function.call.hmi.CallerHmiViewControlListenerManager -import com.mogo.eagle.core.function.call.setting.CallerSkinModeListenerManager import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager -import com.mogo.eagle.core.function.hmi.ui.widget.DemoModeView import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger import com.mogo.eagle.core.utilcode.util.ClickUtils import com.mogo.eagle.core.utilcode.util.UiThreadHandler import com.mogo.och.charter.passenger.R +import com.mogo.och.charter.passenger.bean.response.OrderInfoResponse +import com.mogo.och.charter.passenger.callback.IBeautifyModeCallback +import com.mogo.och.charter.passenger.model.CharterPassengerModel +import com.mogo.och.charter.passenger.model.OrderStatusEnum import com.mogo.och.charter.passenger.ui.debugview.DebugEvent +import com.mogo.och.charter.passenger.utils.BeautifyManager import com.mogo.och.common.module.manager.loopmanager.BizLoopManager import com.mogo.och.common.module.manager.loopmanager.LoopInfo +import com.mogo.och.common.module.manager.stopsidemanager.StopSideManager +import com.mogo.och.common.module.manager.stopsidemanager.StopSideStatus import kotlinx.android.synthetic.main.charter_p_statusview_datetime.view.aciv_connect_driver_status import kotlinx.android.synthetic.main.charter_p_statusview_datetime.view.actv_auto_status import kotlinx.android.synthetic.main.charter_p_statusview_datetime.view.bizz_view @@ -44,7 +46,8 @@ class StatusBarView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 -) : ConstraintLayout(context, attrs, defStyleAttr), IMoGoSkinModeChangeListener, IViewControlListener, IMoGoBatteryManagementSystemListener, IMoGoAutopilotStatusListener { +) : ConstraintLayout(context, attrs, defStyleAttr), IMoGoBatteryManagementSystemListener, IMoGoAutopilotStatusListener, + IBeautifyModeCallback { companion object { const val TAG = "StatusBarView" @@ -85,17 +88,12 @@ class StatusBarView @JvmOverloads constructor( params.height = AutoSizeUtils.dp2px(context,47f) layoutParams = params } - //添加view控制 - CallerHmiViewControlListenerManager.addListener(TAG,this) - CallerHmiViewControlListenerManager.setListenerHz(TAG,5) - // 添加换肤监听 - CallerSkinModeListenerManager.addListener(TAG, this) - + //电池电量监听 CallerBatteryManagementSystemListenerManager.addListener(TAG,this) - + //自动驾驶状态监听 CallerAutoPilotStatusListenerManager.addListener(TAG, this) - updateStatusBarRightView(FunctionBuildConfig.isDemoMode, "demoMode", DemoModeView(this.context)) + BeautifyManager.setStatusChangeListener(TAG,this) bizz_view.setOnClickListener { continuousClick(bizz) } @@ -104,8 +102,7 @@ class StatusBarView @JvmOverloads constructor( progress.progress = 50 tv_power_cos.text = "50%" - val state = CallerAutoPilotStatusListenerManager.getState() - setAutoPilotStatusInfo(state) + setAutoPilotStatusInfo(CallerAutoPilotStatusListenerManager.getState()) BizLoopManager.setLoopFunction(TAG, LoopInfo(3, ::showConnectStatusWithDriver)) } @@ -122,27 +119,60 @@ class StatusBarView @JvmOverloads constructor( } private fun setAutoPilotStatusInfo(state: Int) { - when (state) { - IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE -> { - actv_auto_status.text = "安全接管中" + if (FunctionBuildConfig.isDemoMode) {// 美化模式 + val gnssSpeed = CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02().gnssSpeed + actv_auto_status.text = "自动驾驶中" + when (CharterPassengerModel.getCurrentOrderStatus()) { + OrderStatusEnum.Nothing -> {// 初始状态 + //是否强制绘制引导线 + FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = false + } + OrderStatusEnum.NoOrderUnuse -> {//无订单车闲置 + //是否强制绘制引导线 + FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = false + } + OrderStatusEnum.OrderNoLine -> {//有订单无线路 + //是否强制绘制引导线 + FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = false + } + OrderStatusEnum.OrdersWithLine -> {//有订单有线路 是否到站 + //是否强制绘制引导线 + FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = gnssSpeed>0.3 + CharterPassengerModel.getCurrentOrderInfo()?.let { + if(it.arriveStatus == OrderInfoResponse.ARRIVED){ + // 到站不绘制引导线 + FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = false + return + } + if (StopSideManager.stopSiteStatus== StopSideStatus.EndingSuccess) { + // 靠边停车成功不绘制引导线 + FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = false + return + } + FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = true + } + } + OrderStatusEnum.NoOrderUse -> {// 无订单车不闲置 + //是否强制绘制引导线 + FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = false + } } - IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE -> { - actv_auto_status.text = "安全接管中" + }else{ + when (state) { + IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE -> { + actv_auto_status.text = "安全接管中" + } + IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE -> { + actv_auto_status.text = "安全接管中" + } + IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING -> { + actv_auto_status.text = "自动驾驶中" + } + IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING -> { + actv_auto_status.text = "远程代驾中" + } + else -> {} } - IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING -> { - actv_auto_status.text = "自动驾驶中" - } - IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING -> { - actv_auto_status.text = "远程代驾中" - } - else -> {} - } - } - - override fun onSkinModeChange(skinMode: Int) { - when (skinMode) { - 0 -> setStatusBarDarkOrLight(false) - 1 -> setStatusBarDarkOrLight(true) } } @@ -152,21 +182,16 @@ class StatusBarView @JvmOverloads constructor( } } - override fun updateStatusBarLeftView(insert: Boolean, tag: String, viewGroup: ViewGroup) { - - } - - @SuppressLint("SetTextI18n") - override fun updateStatusBarDownloadView(insert: Boolean, tag: String, progress: Int) { - - } - override fun onDetachedFromWindow() { super.onDetachedFromWindow() - CallerHmiViewControlListenerManager.removeListener(TAG) - CallerSkinModeListenerManager.removeListener(TAG) CallerDevaToolsManager.hideStatusBar() + //定时任务 BizLoopManager.removeLoopFunction(TAG) + //电池电量监听 + CallerBatteryManagementSystemListenerManager.removeListener(TAG) + //自动驾驶状态监听 + CallerAutoPilotStatusListenerManager.removeListener(TAG) + BeautifyManager.setStatusChangeListener(TAG,null) } override fun onBatteryManagementSystemStates(states: ChassisStatesOuterClass.BMSSystemStates) { @@ -179,5 +204,11 @@ class StatusBarView @JvmOverloads constructor( tv_power_cos.text = "${bmsSoc.roundToInt()}%" } } + + override fun dispatchStatus(typeEnum: BeautifyManager.ChangeTypeEnum) { + UiThreadHandler.post( { + setAutoPilotStatusInfo(CallerAutoPilotStatusListenerManager.getState()) + },UiThreadHandler.MODE.QUEUE) + } } diff --git a/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/utils/BeautifyManager.kt b/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/utils/BeautifyManager.kt new file mode 100644 index 0000000000..071c5de7ab --- /dev/null +++ b/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/utils/BeautifyManager.kt @@ -0,0 +1,61 @@ +package com.mogo.och.charter.passenger.utils + +import com.mogo.eagle.core.data.config.FunctionBuildConfig +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.och.charter.passenger.callback.IBeautifyModeCallback +import com.mogo.och.charter.passenger.ui.statusbar.StatusBarView +import com.mogo.och.common.module.manager.loopmanager.BizLoopManager +import com.mogo.och.common.module.manager.loopmanager.LoopInfo +import java.util.concurrent.ConcurrentHashMap + +object BeautifyManager { + + private val TAG = BeautifyManager::class.java.simpleName + + enum class ChangeTypeEnum{ + BEAUTIFY_TYPE,// 美化模式变化 + ORDER_STATU_CHANGE,// 订单状态发生变化 + ARRIVED_DEST,// 到站 + STOPSITE_SUCCESS// 靠边停车成功 + } + + private val orderStatusChangeListeners = ConcurrentHashMap() + + @Volatile + @JvmField + var isBeautifyMode = false + + init { + isBeautifyMode = FunctionBuildConfig.isDemoMode + BizLoopManager.setLoopFunction(TAG, LoopInfo(3, ::checkDemoMode)) + } + + private fun checkDemoMode() { + if(isBeautifyMode!=FunctionBuildConfig.isDemoMode){ + isBeautifyMode = FunctionBuildConfig.isDemoMode + notifyViewChange(ChangeTypeEnum.BEAUTIFY_TYPE) + } + } + + + fun setStatusChangeListener( + tag: String, + orderStatusChangeListener: IBeautifyModeCallback? + ) { + if (tag.isBlank()) return + if (orderStatusChangeListener == null) { + orderStatusChangeListeners.remove(tag) + return + } + orderStatusChangeListeners[tag] = orderStatusChangeListener + } + + + fun notifyViewChange(typeEnum: ChangeTypeEnum){ + CallerLogger.d(StatusBarView.TAG,"美化模式变化原因:${typeEnum}") + orderStatusChangeListeners.forEach { + it.value.dispatchStatus(typeEnum) + } + } + +} \ No newline at end of file From 94354b75502c5947b0a6a4c1577100552b5b2a9a Mon Sep 17 00:00:00 2001 From: yangyakun Date: Thu, 9 Nov 2023 10:43:55 +0800 Subject: [PATCH 2/3] =?UTF-8?q?[6.2.0]=20[charter]=20[=E9=80=9F=E5=BA=A6?= =?UTF-8?q?=E3=80=81=E8=87=AA=E5=8A=A8=E9=A9=BE=E9=A9=B6=E7=8A=B6=E6=80=81?= =?UTF-8?q?]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../och/charter/base/CharterBaseFragment.kt | 169 +--------------- .../charter/callback/IBeautifyModeCallback.kt | 7 + .../och/charter/fragment/DriverM1Fragment.kt | 7 - .../och/charter/manager/BeautifyManager.kt | 60 ++++++ .../charter/presenter/DriverM1Presenter.kt | 30 +-- .../view/autopilot/AutopilotStatusView.kt | 189 ++++++++++++++++++ .../autopilot/AutopilotStatusViewModel.kt | 68 +++++++ .../charter/view/carstatus/CarStatusView.kt | 40 ++++ .../view/carstatus/CarStatusViewModel.kt | 48 +++++ .../res/layout/charter_autopilot_status.xml | 30 +++ .../main/res/layout/charter_base_fragment.xml | 43 +--- .../passenger/utils/BeautifyManager.kt | 2 +- 12 files changed, 461 insertions(+), 232 deletions(-) create mode 100644 OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/callback/IBeautifyModeCallback.kt create mode 100644 OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/manager/BeautifyManager.kt create mode 100644 OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/view/autopilot/AutopilotStatusView.kt create mode 100644 OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/view/autopilot/AutopilotStatusViewModel.kt create mode 100644 OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/view/carstatus/CarStatusView.kt create mode 100644 OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/view/carstatus/CarStatusViewModel.kt create mode 100644 OCH/charter/driver/src/main/res/layout/charter_autopilot_status.xml diff --git a/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/base/CharterBaseFragment.kt b/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/base/CharterBaseFragment.kt index 04355d8e1d..51c1dd5405 100644 --- a/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/base/CharterBaseFragment.kt +++ b/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/base/CharterBaseFragment.kt @@ -12,6 +12,7 @@ import androidx.constraintlayout.widget.Group import com.magic.mogo.och.charter.R import com.magic.mogo.och.charter.constant.CharterConst import com.magic.mogo.och.charter.view.SlidePanelView +import com.magic.mogo.och.charter.view.autopilot.AutopilotStatusView import com.mogo.commons.mvp.IView import com.mogo.commons.mvp.MvpFragment import com.mogo.commons.mvp.Presenter @@ -54,16 +55,13 @@ abstract class CharterBaseFragment?>() : private val TAG = "BaseBusTabFragment" - private var ctvAutopilotStatus: RelativeLayout? = null - private var ctvAutopilotStatusIv: ImageView? = null - private var ctvAutopilotStatusTv: TextView? = null + private var ctvAutopilotStatus: AutopilotStatusView? = null protected var mSettingBtn: RelativeLayout? = null protected var mBadcaseBtn: RelativeLayout? = null protected var mAICollectBtn: RelativeLayout? = null private var flStationPanelContainer: FrameLayout? = null private var mapBizView: MapBizView? = null private var groupTestPanel: Group? = null - private var mTrafficDataView: TrafficDataView? = null protected var slidePanelView: SlidePanelView? = null //远景和中景的切换 private var mSwitchMapModeImage: ImageView? = null @@ -87,16 +85,13 @@ abstract class CharterBaseFragment?>() : override fun initViews() { mapBizView = findViewById(R.id.mapBizView) groupTestPanel = findViewById(R.id.groupTestPanel) - 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) + ctvAutopilotStatus = findViewById(R.id.autopilot_status) flStationPanelContainer = findViewById(R.id.module_mogo_och_station_panel_container) slidePanelView = findViewById(R.id.charter_slide_panel) slidePanelView?.setText(resources.getString(R.string.charter_back_car)) slidePanelView?.setOnSlidePanelMoveToEndListener(onSlideToEndListener) - mTrafficDataView = findViewById(R.id.bus_arc) as TrafficDataView? LayoutInflater.from(context).inflate(getStationPanelViewId(), flStationPanelContainer) mSwitchMapModeLayout = findViewById(R.id.bus_switch_model_layout) mSwitchMapModeImage = findViewById(R.id.bus_switch_model_icon) @@ -122,12 +117,6 @@ abstract class CharterBaseFragment?>() : } }) initListener() - setAutopilotBtnStatus(getState()) - ctvAutopilotStatus!!.setOnClickListener(object : OnPreventFastClickListener() { - override fun onClickImpl(v: View) { - restartAutopilot() - } - }) // 模拟 不可自动驾驶,目前场景是刚开机,adas还未和工控机连接 findViewById(R.id.btnAutopilotDisable)!!.setOnClickListener { view: View? -> @@ -194,6 +183,11 @@ abstract class CharterBaseFragment?>() : } }) smallMapView = findViewById(R.id.smallMapView) + + ctvAutopilotStatus?.setOnLongClickListener { + debugTestBar() + true + } } override fun initViews(savedInstanceState: Bundle?) { @@ -308,90 +302,6 @@ abstract class CharterBaseFragment?>() : SoundPoolHelper.getSoundPoolHelper().playSoundWithRedId(context, R.raw.bus_di) } - /** - * 改变自动驾驶状态 - * - * @param autopilotStatus 0:不可用 1:可用状态 2:自动驾驶中 - */ - fun onAutopilotStatusChanged(autopilotStatus: Int) { - requireActivity().runOnUiThread { - changeAutopilotBtnView( - autopilotStatus, - isAnimateRunning - ) - } - } - - private fun setAutopilotBtnStatus(autopilotStatus: Int) { - if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE - == autopilotStatus - ) { //0不可用 - ctvAutopilotStatusTv!!.setTextColor(resources.getColor(R.color.charter_autopilot_text_color_disable)) - ctvAutopilotStatusTv!!.text = - resources.getString(R.string.charter_loading_autopilot_runnig_tv) - ctvAutopilotStatusIv!!.setImageResource(R.drawable.charter_disable_autopilot_icon) -// ctvAutopilotStatus!!.isSelected = false - ctvAutopilotStatus!!.isClickable = true - ctvAutopilotStatus!!.background = getDrawable(R.drawable.charter_autopilot_0_1_status_bg) - }else{ - ctvAutopilotStatusTv!!.setTextColor(resources.getColor(R.color.charter_autopilot_text_color_normal)) - ctvAutopilotStatusIv!!.setImageResource(R.drawable.charter_ic_autopilot) - ctvAutopilotStatusTv!!.text = - resources.getString(R.string.charter_loading_autopilot_runnig_tv) - ctvAutopilotStatus!!.isClickable = true - if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE == autopilotStatus) { //1可用 - ctvAutopilotStatus!!.background = getDrawable(R.drawable.charter_autopilot_0_1_status_bg) - } else if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING == autopilotStatus) { - ctvAutopilotStatus!!.background = getDrawable(R.drawable.charter_autopilot_2_status_bg) - } else if (IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING - == autopilotStatus){ - ctvAutopilotStatusTv!!.text = - resources.getString(R.string.charter_loading_autopilot_pingxing_tv) - ctvAutopilotStatus!!.isClickable = false - ctvAutopilotStatus!!.background = getDrawable(R.drawable.charter_pingxingjiashi) - } - } - } - - open fun updateAutopilotStatus(autopilotStatus: Int) { - if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING - == autopilotStatus - ) { //2 running - ctvAutopilotStatusIv!!.setImageResource(R.drawable.charter_right_autopilot_icon) - ctvAutopilotStatusTv!!.setTextColor(resources.getColor(R.color.charter_autopilot_text_color_normal)) - ctvAutopilotStatusTv!!.text = - resources.getString(R.string.charter_loading_autopilot_success_tv) -// ctvAutopilotStatus!!.isSelected = false - ctvAutopilotStatus!!.isClickable = false - } else { - ctvAutopilotStatusIv!!.setImageResource(R.drawable.charter_wrong_autopilot_icon) - ctvAutopilotStatusTv!!.setTextColor(resources.getColor(R.color.charter_autopilot_text_color_normal)) - ctvAutopilotStatusTv!!.text = - resources.getString(R.string.charter_loading_autopilot_failure_tv) - ctvAutopilotStatus!!.isClickable = false -// ctvAutopilotStatus!!.isSelected = false - } - UiThreadHandler.postDelayed({ setAutopilotBtnStatus(autopilotStatus) }, 1000) - } - - private fun changeAutopilotBtnView(autopilotStatus: Int, isAnimateRunning: Boolean) { - if (isAnimateRunning && IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING - != autopilotStatus - ) { - // 主动开启自动驾驶中,不为2(为0、1)则继续loading - return - } - if (isAnimateRunning) { - stopAnimAndUpdateBtnStatus() - } else { - setAutopilotBtnStatus(autopilotStatus) - } - } - - open fun stopAnimAndUpdateBtnStatus() { - stopAutopilotAnimation() - updateAutopilotStatus(getState()) - } /** @@ -408,74 +318,13 @@ abstract class CharterBaseFragment?>() : */ abstract fun getStationPanelViewId(): Int - /** - * 重新开启自动驾驶 - */ - abstract fun restartAutopilot() - /** * 模拟自动驾驶返回状态 * * @param status */ private fun debugAutoPilotStatus(status: Int){ - setAutopilotBtnStatus(status) - } - /** - * 开启自动驾驶中间动画 - */ - @SuppressLint("ObjectAnimatorBinding") - open fun startAutopilotAnimation() { - isAnimateRunning = true - ctvAutopilotStatusTv!!.text = resources.getString(R.string.charter_loading_autopilot_tv) - ctvAutopilotStatusTv!!.setTextColor(resources.getColor(R.color.charter_autopilot_text_color_normal)) -// ctvAutopilotStatus!!.isSelected = false - ctvAutopilotStatus!!.isClickable = true - ctvAutopilotStatusIv!!.setImageResource(R.drawable.charter_loading_autopilot_icon) - if (autopilotLoadingAnimator == null) { - autopilotLoadingAnimator = - ObjectAnimator.ofFloat(ctvAutopilotStatusIv, "rotation", 0f, 360f) - autopilotLoadingAnimator?.interpolator = LinearInterpolator() - autopilotLoadingAnimator?.repeatCount = -1 //无限循环 - autopilotLoadingAnimator?.duration = 1000 //设置持续时间 - } - autopilotLoadingAnimator!!.start() //动画开始 - startingAutoApilotCountDown() - } - - private fun startingAutoApilotCountDown() { - //10s 若自动驾驶没有开启,则结束动画 - UiThreadHandler.postDelayed({ - //未启动成功做处理 - if (isAnimateRunning) { // 只判断动画是否在进行,根据自动驾驶当前状态去设置自动驾驶状态 - stopAutopilotAnimation() - updateAutopilotStatus(getState()) - } - }, CharterConst.TIMER_START_AUTOPILOT_INTERVAL) - } - - /** - * 停止自动驾驶中间动画 - */ - protected open fun stopAutopilotAnimation() { - if (autopilotLoadingAnimator != null) { - autopilotLoadingAnimator!!.end() - ctvAutopilotStatusIv!!.clearAnimation() - autopilotLoadingAnimator = null - isAnimateRunning = false - } - } - - /** - * 迈速表实时更新 - * - * @param newSpeed - */ - open fun updateSpeedView(newSpeed: Float) { - val speed = (abs(newSpeed) * 3.6f).toInt() // 倒车时工控机反馈定位信息中speed为负值 - if (mTrafficDataView != null) { - mTrafficDataView!!.updateSpeedWithValue(speed) - } + ctvAutopilotStatus?.setAutopilotBtnStatus(status) } override fun onDestroy() { diff --git a/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/callback/IBeautifyModeCallback.kt b/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/callback/IBeautifyModeCallback.kt new file mode 100644 index 0000000000..2670f4c73b --- /dev/null +++ b/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/callback/IBeautifyModeCallback.kt @@ -0,0 +1,7 @@ +package com.magic.mogo.och.charter.callback + +import com.magic.mogo.och.charter.manager.BeautifyManager + +interface IBeautifyModeCallback { + fun dispatchStatus(typeEnum: BeautifyManager.ChangeTypeEnum) +} \ No newline at end of file diff --git a/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/fragment/DriverM1Fragment.kt b/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/fragment/DriverM1Fragment.kt index ecf8215f7a..c670bad905 100644 --- a/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/fragment/DriverM1Fragment.kt +++ b/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/fragment/DriverM1Fragment.kt @@ -168,13 +168,6 @@ class DriverM1Fragment : CharterBaseFragment() + + @Volatile + @JvmField + var isBeautifyMode = false + + init { + isBeautifyMode = FunctionBuildConfig.isDemoMode + BizLoopManager.setLoopFunction(TAG, LoopInfo(3, ::checkDemoMode)) + } + + private fun checkDemoMode() { + if(isBeautifyMode!=FunctionBuildConfig.isDemoMode){ + isBeautifyMode = FunctionBuildConfig.isDemoMode + notifyViewChange(ChangeTypeEnum.BEAUTIFY_TYPE) + } + } + + + fun setStatusChangeListener( + tag: String, + orderStatusChangeListener: IBeautifyModeCallback? + ) { + if (tag.isBlank()) return + if (orderStatusChangeListener == null) { + orderStatusChangeListeners.remove(tag) + return + } + orderStatusChangeListeners[tag] = orderStatusChangeListener + } + + + fun notifyViewChange(typeEnum: ChangeTypeEnum){ + CallerLogger.d(TAG,"美化模式变化原因:${typeEnum}") + orderStatusChangeListeners.forEach { + it.value.dispatchStatus(typeEnum) + } + } + +} \ No newline at end of file diff --git a/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/presenter/DriverM1Presenter.kt b/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/presenter/DriverM1Presenter.kt index ab5996a55f..6d8131217c 100644 --- a/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/presenter/DriverM1Presenter.kt +++ b/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/presenter/DriverM1Presenter.kt @@ -36,8 +36,7 @@ import mogo_msg.MogoReportMsg */ class DriverM1Presenter(view: DriverM1Fragment?) : Presenter(view),ILoginCallback, DriverM1OrderCallback, ChangeDestCallback, - IMoGoAutopilotStatusListener, OCHPlanningActionsCallback, - IDriverM1ControllerStatusCallback { + IMoGoAutopilotStatusListener, OCHPlanningActionsCallback{ companion object{ private const val TAG = "DriverM1Presenter" @@ -55,7 +54,6 @@ class DriverM1Presenter(view: DriverM1Fragment?) : StopSideManager.addListener(TAG,this) DriverM1Model.get().setDriverM1OrderCallback(this) DriverM1Model.get().setChangeDestCallback(this) - DriverM1Model.get().setControllerStatusCallback(this) } private fun releaseListener() { @@ -63,7 +61,6 @@ class DriverM1Presenter(view: DriverM1Fragment?) : CallerAutoPilotStatusListenerManager.removeListener(TAG) DriverM1Model.get().setDriverM1OrderCallback(null) DriverM1Model.get().setChangeDestCallback(null) - DriverM1Model.get().setControllerStatusCallback(null) } override fun onDestroy(owner: LifecycleOwner) { @@ -92,13 +89,6 @@ class DriverM1Presenter(view: DriverM1Fragment?) : DriverM1Model.get().logout() } - fun restartAutopilot() { - // todo 启动自驾必须有订单路线 - if (DriverM1Model.get().isHaveOrder()) { - DriverM1Model.get().restartAutopilot() - } - } - fun driverEndLease() { DriverM1Model.get().driverEndLease() } @@ -145,7 +135,6 @@ class DriverM1Presenter(view: DriverM1Fragment?) : } override fun onAutopilotStatusResponse(state: Int) { - mView?.onAutopilotStatusChanged(state) when(state){ // IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE -> { // // @@ -193,21 +182,4 @@ class DriverM1Presenter(view: DriverM1Fragment?) : } } - override fun startOpenAutopilot() { - ThreadUtils.runOnUiThread { - mView?.startAutopilotAnimation() - } - } - - override fun onStartAdasFailure() { - ThreadUtils.runOnUiThread { - mView?.stopAnimAndUpdateBtnStatus() - } - } - - override fun updateSpeed(gnssInfo: MogoLocation) { - ThreadUtils.runOnUiThread { - mView?.updateSpeedView(gnssInfo.gnssSpeed) - } - } } diff --git a/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/view/autopilot/AutopilotStatusView.kt b/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/view/autopilot/AutopilotStatusView.kt new file mode 100644 index 0000000000..3575f1593e --- /dev/null +++ b/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/view/autopilot/AutopilotStatusView.kt @@ -0,0 +1,189 @@ +package com.magic.mogo.och.charter.view.autopilot + +import android.animation.ObjectAnimator +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import android.view.animation.LinearInterpolator +import android.widget.RelativeLayout +import androidx.lifecycle.ViewModelProvider +import androidx.lifecycle.findViewTreeViewModelStoreOwner +import com.magic.mogo.och.charter.R +import com.magic.mogo.och.charter.constant.CharterConst +import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener +import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager +import com.mogo.eagle.core.utilcode.kotlin.onClick +import com.mogo.eagle.core.utilcode.util.ResourceUtils +import com.mogo.eagle.core.utilcode.util.UiThreadHandler +import kotlinx.android.synthetic.main.charter_autopilot_status.view.bus_autopilot_btn_iv +import kotlinx.android.synthetic.main.charter_autopilot_status.view.bus_autopolot_btn_tv + +/** + * 剩余时间和结束订单入口 + */ +class AutopilotStatusView : RelativeLayout,AutopilotStatusViewModel.IAutopilotStatusCallback { + + private val TAG = "AutopilotStatusView" + + constructor(context: Context) : super(context) + + constructor(context: Context, attributeSet: AttributeSet) : super(context, attributeSet) + + constructor(context: Context, attributeSet: AttributeSet, defStyleAttr: Int) : super( + context, + attributeSet, + defStyleAttr + ) + + var viewModel:AutopilotStatusViewModel?=null + + var isAnimateRunning = false + + private var autopilotLoadingAnimator: ObjectAnimator? = null + + private fun initView() { + LayoutInflater.from(context).inflate(R.layout.charter_autopilot_status, this, true) + onClick { + if (!isAnimateRunning) { + viewModel?.restartAutopilot() + } + } + } + + override fun startAutopilotAnimation() { + isAnimateRunning = true + bus_autopolot_btn_tv!!.text = resources.getString(R.string.charter_loading_autopilot_tv) + bus_autopolot_btn_tv!!.setTextColor(resources.getColor(R.color.charter_autopilot_text_color_normal)) +// ctvAutopilotStatus!!.isSelected = false + isClickable = true + bus_autopilot_btn_iv!!.setImageResource(R.drawable.charter_loading_autopilot_icon) + if (autopilotLoadingAnimator == null) { + autopilotLoadingAnimator = + ObjectAnimator.ofFloat(bus_autopilot_btn_iv, "rotation", 0f, 360f) + autopilotLoadingAnimator?.interpolator = LinearInterpolator() + autopilotLoadingAnimator?.repeatCount = -1 //无限循环 + autopilotLoadingAnimator?.duration = 1000 //设置持续时间 + } + autopilotLoadingAnimator!!.start() //动画开始 + startingAutoApilotCountDown() + } + + override fun stopAnimAndUpdateBtnStatus() { + stopAutopilotAnimation() + updateAutopilotStatus(CallerAutoPilotStatusListenerManager.getState()) + } + + override fun onAutopilotStatusChanged(autopilotStatus: Int) { + if (isAnimateRunning && IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING + != autopilotStatus + ) { + // 主动开启自动驾驶中,不为2(为0、1)则继续loading + return + } + if (isAnimateRunning) { + stopAnimAndUpdateBtnStatus() + } else { + setAutopilotBtnStatus(autopilotStatus) + } + } + + private fun startingAutoApilotCountDown() { + //10s 若自动驾驶没有开启,则结束动画 + UiThreadHandler.postDelayed({ + //未启动成功做处理 + if (isAnimateRunning) { // 只判断动画是否在进行,根据自动驾驶当前状态去设置自动驾驶状态 + stopAutopilotAnimation() + updateAutopilotStatus(CallerAutoPilotStatusListenerManager.getState()) + } + }, CharterConst.TIMER_START_AUTOPILOT_INTERVAL) + } + + fun updateAutopilotStatus(autopilotStatus: Int) { + if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING + == autopilotStatus + ) { //2 running + bus_autopilot_btn_iv!!.setImageResource(R.drawable.charter_right_autopilot_icon) + bus_autopolot_btn_tv!!.setTextColor(resources.getColor(R.color.charter_autopilot_text_color_normal)) + bus_autopolot_btn_tv!!.text = + resources.getString(R.string.charter_loading_autopilot_success_tv) +// ctvAutopilotStatus!!.isSelected = false + isClickable = false + } else { + bus_autopilot_btn_iv!!.setImageResource(R.drawable.charter_wrong_autopilot_icon) + bus_autopolot_btn_tv!!.setTextColor(resources.getColor(R.color.charter_autopilot_text_color_normal)) + bus_autopolot_btn_tv!!.text = + resources.getString(R.string.charter_loading_autopilot_failure_tv) + isClickable = false +// ctvAutopilotStatus!!.isSelected = false + } + UiThreadHandler.postDelayed({ setAutopilotBtnStatus(autopilotStatus) }, 1000) + } + + fun setAutopilotBtnStatus(autopilotStatus: Int) { + if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE + == autopilotStatus + ) { //0不可用 + bus_autopolot_btn_tv!!.setTextColor(resources.getColor(R.color.charter_autopilot_text_color_disable)) + bus_autopolot_btn_tv!!.text = + resources.getString(R.string.charter_loading_autopilot_runnig_tv) + bus_autopilot_btn_iv!!.setImageResource(R.drawable.charter_disable_autopilot_icon) +// ctvAutopilotStatus!!.isSelected = false + isClickable = true + background = ResourceUtils.getDrawable(R.drawable.charter_autopilot_0_1_status_bg) + }else{ + bus_autopolot_btn_tv!!.setTextColor(resources.getColor(R.color.charter_autopilot_text_color_normal)) + bus_autopilot_btn_iv!!.setImageResource(R.drawable.charter_ic_autopilot) + bus_autopolot_btn_tv!!.text = + resources.getString(R.string.charter_loading_autopilot_runnig_tv) + isClickable = true + if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE == autopilotStatus) { //1可用 + background = + ResourceUtils.getDrawable(R.drawable.charter_autopilot_0_1_status_bg) + } else if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING == autopilotStatus) { + background = + ResourceUtils.getDrawable(R.drawable.charter_autopilot_2_status_bg) + } else if (IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING == autopilotStatus){ + bus_autopolot_btn_tv!!.text = + resources.getString(R.string.charter_loading_autopilot_pingxing_tv) + isClickable = false + background = ResourceUtils.getDrawable(R.drawable.charter_pingxingjiashi) + } + } + } + + /** + * 停止自动驾驶中间动画 + */ + protected open fun stopAutopilotAnimation() { + if (autopilotLoadingAnimator != null) { + autopilotLoadingAnimator!!.end() + bus_autopilot_btn_iv!!.clearAnimation() + autopilotLoadingAnimator = null + isAnimateRunning = false + } + } + + override fun onAttachedToWindow() { + super.onAttachedToWindow() + viewModel = findViewTreeViewModelStoreOwner()?.let { + ViewModelProvider(it).get(AutopilotStatusViewModel::class.java) + } + viewModel?.setAutopilotStatusCallback(this) + setAutopilotBtnStatus(CallerAutoPilotStatusListenerManager.getState()) + } + + override fun onDetachedFromWindow() { + super.onDetachedFromWindow() + } + + + init { + try { + initView() + } catch (e: Exception) { + e.printStackTrace() + } + } + + +} \ No newline at end of file diff --git a/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/view/autopilot/AutopilotStatusViewModel.kt b/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/view/autopilot/AutopilotStatusViewModel.kt new file mode 100644 index 0000000000..8e398b6b57 --- /dev/null +++ b/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/view/autopilot/AutopilotStatusViewModel.kt @@ -0,0 +1,68 @@ +package com.magic.mogo.och.charter.view.autopilot + +import androidx.lifecycle.ViewModel +import com.magic.mogo.och.charter.callback.IDriverM1ControllerStatusCallback +import com.magic.mogo.och.charter.model.DriverM1Model +import com.mogo.eagle.core.data.map.MogoLocation +import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener +import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager +import com.mogo.eagle.core.utilcode.util.ThreadUtils + +class AutopilotStatusViewModel: ViewModel(), IDriverM1ControllerStatusCallback, + IMoGoAutopilotStatusListener { + + private val TAG = AutopilotStatusViewModel::class.java.simpleName + + private var viewCallback:IAutopilotStatusCallback?=null + + + init { + DriverM1Model.get().setControllerStatusCallback(this) + } + + override fun onCleared() { + super.onCleared() + this.viewCallback = null + CallerAutoPilotStatusListenerManager.removeListener(TAG) + } + + fun setAutopilotStatusCallback(viewCallback:IAutopilotStatusCallback){ + this.viewCallback = viewCallback + CallerAutoPilotStatusListenerManager.addListener(TAG, this) + } + + fun restartAutopilot() { + // todo 启动自驾必须有订单路线 + if (DriverM1Model.get().isHaveOrder()) { + DriverM1Model.get().restartAutopilot() + } + } + + interface IAutopilotStatusCallback{ + fun startAutopilotAnimation() + fun stopAnimAndUpdateBtnStatus() + fun onAutopilotStatusChanged(state: Int) + } + + override fun startOpenAutopilot() { + ThreadUtils.runOnUiThread( { + this.viewCallback?.startAutopilotAnimation() + },ThreadUtils.MODE.QUEUE) + } + + override fun onStartAdasFailure() { + ThreadUtils.runOnUiThread( { + this.viewCallback?.stopAnimAndUpdateBtnStatus() + },ThreadUtils.MODE.QUEUE) + } + + override fun updateSpeed(gnssInfo: MogoLocation) { + } + + override fun onAutopilotStatusResponse(state: Int) { + ThreadUtils.runOnUiThread( { + this.viewCallback?.onAutopilotStatusChanged(state) + },ThreadUtils.MODE.QUEUE) + } + +} \ No newline at end of file diff --git a/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/view/carstatus/CarStatusView.kt b/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/view/carstatus/CarStatusView.kt new file mode 100644 index 0000000000..3ea6d0e068 --- /dev/null +++ b/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/view/carstatus/CarStatusView.kt @@ -0,0 +1,40 @@ +package com.magic.mogo.och.charter.view.carstatus + +import android.content.Context +import android.util.AttributeSet +import androidx.lifecycle.ViewModelProvider +import androidx.lifecycle.findViewTreeViewModelStoreOwner +import com.mogo.eagle.core.function.hmi.ui.widget.TrafficDataView + +class CarStatusView : TrafficDataView, CarStatusViewModel.ICarStatusCallback { + + private val TAG = "CarStatusView" + + constructor(context: Context) : super(context) + + constructor(context: Context, attributeSet: AttributeSet) : super(context, attributeSet) + + constructor(context: Context, attributeSet: AttributeSet, defStyleAttr: Int) : super( + context, + attributeSet, + defStyleAttr + ) + + var viewModel:CarStatusViewModel?=null + + override fun onAttachedToWindow() { + super.onAttachedToWindow() + viewModel = findViewTreeViewModelStoreOwner()?.let { + ViewModelProvider(it).get(CarStatusViewModel::class.java) + } + viewModel?.setAutopilotStatusCallback(this) + } + + override fun onDetachedFromWindow() { + super.onDetachedFromWindow() + } + + override fun updateSpeedWithCurrentValue(speed: Int) { + updateSpeedWithValue(speed) + } +} \ No newline at end of file diff --git a/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/view/carstatus/CarStatusViewModel.kt b/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/view/carstatus/CarStatusViewModel.kt new file mode 100644 index 0000000000..c64e42e8b9 --- /dev/null +++ b/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/view/carstatus/CarStatusViewModel.kt @@ -0,0 +1,48 @@ +package com.magic.mogo.och.charter.view.carstatus + +import androidx.lifecycle.ViewModel +import com.magic.mogo.och.charter.model.DriverM1Model +import com.mogo.eagle.core.data.map.MogoLocation +import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener +import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener +import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager +import com.mogo.eagle.core.utilcode.util.ThreadUtils +import kotlin.math.abs + +class CarStatusViewModel: ViewModel(), IMoGoAutopilotStatusListener, + IMoGoChassisLocationGCJ02Listener { + + private val TAG = CarStatusViewModel::class.java.simpleName + + private var viewCallback:ICarStatusCallback?=null + + + init { + + } + + override fun onCleared() { + super.onCleared() + this.viewCallback = null + CallerChassisLocationGCJ02ListenerManager.removeListener(DriverM1Model.TAG) + } + + fun setAutopilotStatusCallback(viewCallback:ICarStatusCallback){ + this.viewCallback = viewCallback + CallerChassisLocationGCJ02ListenerManager.addListener(DriverM1Model.TAG, 10, this) + } + + interface ICarStatusCallback{ + fun updateSpeedWithCurrentValue(speed:Int) + } + + override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) { + mogoLocation?.let { + val speed = (abs(it.gnssSpeed) * 3.6f).toInt() // 倒车时工控机反馈定位信息中speed为负值 + ThreadUtils.runOnUiThread( { + viewCallback?.updateSpeedWithCurrentValue(speed) + },ThreadUtils.MODE.QUEUE) + } + } + +} \ No newline at end of file diff --git a/OCH/charter/driver/src/main/res/layout/charter_autopilot_status.xml b/OCH/charter/driver/src/main/res/layout/charter_autopilot_status.xml new file mode 100644 index 0000000000..ae9faef3d4 --- /dev/null +++ b/OCH/charter/driver/src/main/res/layout/charter_autopilot_status.xml @@ -0,0 +1,30 @@ + + + + + + + \ No newline at end of file diff --git a/OCH/charter/driver/src/main/res/layout/charter_base_fragment.xml b/OCH/charter/driver/src/main/res/layout/charter_base_fragment.xml index 8497b888f8..b34a7b46ba 100644 --- a/OCH/charter/driver/src/main/res/layout/charter_base_fragment.xml +++ b/OCH/charter/driver/src/main/res/layout/charter_base_fragment.xml @@ -29,7 +29,7 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" /> - + app:layout_constraintTop_toTopOf="parent"/> - - - - - + tools:visibility="visible" + android:layout_marginLeft="@dimen/dp_13"/> - - - - - diff --git a/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/utils/BeautifyManager.kt b/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/utils/BeautifyManager.kt index 071c5de7ab..aab0b204bb 100644 --- a/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/utils/BeautifyManager.kt +++ b/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/utils/BeautifyManager.kt @@ -52,7 +52,7 @@ object BeautifyManager { fun notifyViewChange(typeEnum: ChangeTypeEnum){ - CallerLogger.d(StatusBarView.TAG,"美化模式变化原因:${typeEnum}") + CallerLogger.d(TAG,"美化模式变化原因:${typeEnum}") orderStatusChangeListeners.forEach { it.value.dispatchStatus(typeEnum) } From 3aaa7fbbb30fa4b0866664d250ebc6b88d75fb6c Mon Sep 17 00:00:00 2001 From: yangyakun Date: Thu, 9 Nov 2023 11:21:27 +0800 Subject: [PATCH 3/3] =?UTF-8?q?[6.2.0]=20[shuttle]=20[=E8=A7=86=E8=A7=92?= =?UTF-8?q?=E4=BF=AE=E6=94=B9]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OCH/shuttle/passenger/src/m2/res/layout/p_m2_hpmap_fragment.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OCH/shuttle/passenger/src/m2/res/layout/p_m2_hpmap_fragment.xml b/OCH/shuttle/passenger/src/m2/res/layout/p_m2_hpmap_fragment.xml index 3efa0675a3..5c9a902baa 100644 --- a/OCH/shuttle/passenger/src/m2/res/layout/p_m2_hpmap_fragment.xml +++ b/OCH/shuttle/passenger/src/m2/res/layout/p_m2_hpmap_fragment.xml @@ -8,7 +8,7 @@