diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/modeswitch/SwtichBizeModel.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/modeswitch/SwtichBizeModel.kt new file mode 100644 index 0000000000..fd929e6cb3 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/modeswitch/SwtichBizeModel.kt @@ -0,0 +1,54 @@ +package com.mogo.och.unmanned.ui.modeswitch + +import androidx.lifecycle.ViewModel +import com.mogo.commons.module.status.IMogoStatusChangedListener +import com.mogo.commons.module.status.MogoStatusManager +import com.mogo.commons.module.status.StatusDescriptor +import com.mogo.eagle.core.utilcode.util.UiThreadHandler + +/** + * @author XuXinChao + * @description BadCase录包管理页面 + * @since: 2022/12/15 + */ +class SwtichBizeModel : ViewModel() { + + private val TAG = SwtichBizeModel::class.java.simpleName + + private var viewCallback: SwtichLineViewCallback? = null + + + override fun onCleared() { + + } + + fun setDistanceCallback(viewCallback: SwtichLineViewCallback) { + this.viewCallback = viewCallback + this.viewCallback?.showTaskView() + MogoStatusManager.getInstance() + .registerStatusChangedListener( + TAG, StatusDescriptor.TAXI_UNMANED_DRIVER_LINE_ROUTING_VERIFY_MODE, moFanglistener + ) + } + + private var moFanglistener: IMogoStatusChangedListener? = object : IMogoStatusChangedListener { + override fun onStatusChanged(descriptor: StatusDescriptor?, isTrue: Boolean) { + if (StatusDescriptor.TAXI_UNMANED_DRIVER_LINE_ROUTING_VERIFY_MODE == descriptor) { + UiThreadHandler.post { + if (isTrue) {// 展示算路 + viewCallback?.showRoutingView() + } else {// 展示任务 + viewCallback?.showTaskView() + } + } + } + } + + } + + interface SwtichLineViewCallback { + fun showTaskView() + fun showRoutingView() + } +} + diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/modeswitch/TopSwitchBizView.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/modeswitch/TopSwitchBizView.kt index dc76ee0753..d926a4383e 100644 --- a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/modeswitch/TopSwitchBizView.kt +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/modeswitch/TopSwitchBizView.kt @@ -3,10 +3,17 @@ package com.mogo.och.unmanned.ui.modeswitch import android.content.Context import android.util.AttributeSet import android.view.LayoutInflater +import android.view.ViewGroup +import androidx.lifecycle.ViewModelProvider +import androidx.lifecycle.findViewTreeViewModelStoreOwner +import com.mogo.och.common.module.biz.routing.RoutingManager +import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager import com.mogo.och.common.module.wigets.WindowRelativeLayout import com.mogo.och.shuttle.unmanned.R +import kotlinx.android.synthetic.main.shuttle_unmanned_biz.view.routingSwitchView +import kotlinx.android.synthetic.main.shuttle_unmanned_biz.view.switchUnmannedOchBiz -class TopSwitchBizView : WindowRelativeLayout { +class TopSwitchBizView : WindowRelativeLayout, SwtichBizeModel.SwtichLineViewCallback { constructor(context: Context?) : super(context) @@ -22,6 +29,9 @@ class TopSwitchBizView : WindowRelativeLayout { const val TAG = "TopSwitchBizView" } + private var viewModel: SwtichBizeModel?=null + + init { LayoutInflater.from(context).inflate(R.layout.shuttle_unmanned_biz, this, true) @@ -29,12 +39,41 @@ class TopSwitchBizView : WindowRelativeLayout { override fun onAttachedToWindow() { super.onAttachedToWindow() + viewModel = findViewTreeViewModelStoreOwner()?.let { + ViewModelProvider(it).get(SwtichBizeModel::class.java) + } + viewModel?.setDistanceCallback(this) } override fun onDetachedFromWindow() { super.onDetachedFromWindow() + RoutingManager.getRoutingView()?.let { + routingSwitchView.removeView(it) + } + } + override fun showTaskView() { + switchUnmannedOchBiz.visibility = VISIBLE + routingSwitchView.visibility = GONE + RoutingManager.getRoutingView()?.let { + routingSwitchView.removeView(it) + } + } + + override fun showRoutingView() { + switchUnmannedOchBiz.visibility = GONE + routingSwitchView.visibility = VISIBLE + RoutingManager.getRoutingView()?.let { + try { + if (it.parent!=null) { + (it.parent as ViewGroup).removeAllViews() + } + routingSwitchView.addView(it) + }catch (e:Exception){ + OchChainLogManager.writeChainLogError("添加routingview错误:TopSwitchBizView",e.message?:"") + } + } } } diff --git a/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_biz.xml b/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_biz.xml index aeeeb5b82e..118aa99d22 100644 --- a/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_biz.xml +++ b/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_biz.xml @@ -3,7 +3,8 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="1647dp" android:layout_height="1536dp" - android:background="@drawable/unmanned_bus_biz_bg"> + android:background="@drawable/unmanned_bus_biz_bg" + xmlns:tools="http://schemas.android.com/tools"> + + + + \ No newline at end of file