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