[8.0.0]PNCActions更改
This commit is contained in:
@@ -48,12 +48,12 @@ class AiView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : MotionLayout(context, attrs, defStyleAttr), AIViewModel.AiViewCallback,
|
||||
IMoGoAutopilotPlanningActionsListener{
|
||||
) : MotionLayout(context, attrs, defStyleAttr), AIViewModel.AiViewCallback{
|
||||
|
||||
|
||||
|
||||
private var viewModel:AIViewModel?=null
|
||||
private var pncActionsModel:PNCActionsViewModel ?= null
|
||||
|
||||
private var aiAnimator: BigFrameAnimatorContainer?=null
|
||||
private var aiAnimatorBg: BigFrameAnimatorContainer?=null
|
||||
@@ -226,7 +226,10 @@ class AiView @JvmOverloads constructor(
|
||||
ViewModelProvider(it).get(AIViewModel::class.java)
|
||||
}
|
||||
viewModel?.setViewCallback(this)
|
||||
CallerPlanningActionsListenerManager.addListener(TAG, this)
|
||||
pncActionsModel = findViewTreeViewModelStoreOwner()?.let {
|
||||
ViewModelProvider(it)[PNCActionsViewModel::class.java]
|
||||
}
|
||||
pncActionsModel?.init()
|
||||
}
|
||||
|
||||
private fun startListInfo(){
|
||||
@@ -337,47 +340,4 @@ class AiView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
override fun pncActions(planningActionMsg: MessagePad.PlanningActionMsg) {
|
||||
try {
|
||||
UiThreadHandler.post {
|
||||
//TODO !=
|
||||
if (CallerAutoPilotStatusListenerManager.getState() != STATUS_AUTOPILOT_RUNNING) {
|
||||
var actions: String? = null
|
||||
var isPlanningFromServer = false
|
||||
planningActionMsg.actionMsg?.let {
|
||||
try {
|
||||
if (it.drivingState.number == USING_RSI_LINK_VALUE) {
|
||||
isPlanningFromServer = true
|
||||
}
|
||||
actions = PncActionsHelper.getAction(
|
||||
it.drivingState.number,
|
||||
it.drivingAction.number
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
planningActionMsg.v2NActionMsgList?.forEach { v2nAction ->
|
||||
if (v2nAction.drivingState.number == USING_RSI_LINK_VALUE) {
|
||||
isPlanningFromServer = true
|
||||
}
|
||||
actions = PncActionsHelper.getAction(
|
||||
v2nAction.drivingState.number,
|
||||
v2nAction.drivingAction.number
|
||||
)
|
||||
}
|
||||
// update view
|
||||
if(actions?.isNotEmpty() == true){
|
||||
val action = AIMessage.PNCAction(actions!!,actions!!)
|
||||
AIMessageManager.post(action)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.mogo.och.unmanned.passenger.ui.aiview
|
||||
|
||||
import androidx.lifecycle.ViewModel
|
||||
import com.mogo.eagle.core.data.autopilot.pnc.PncActionsHelper
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotPlanningActionsListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningActionsListenerManager
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import com.mogo.och.unmanned.passenger.ui.aiview.bean.AIMessage
|
||||
import mogo.telematics.pad.MessagePad
|
||||
|
||||
class PNCActionsViewModel: ViewModel(), IMoGoAutopilotPlanningActionsListener {
|
||||
|
||||
companion object{
|
||||
private const val TAG = "PNCActionsViewModel"
|
||||
}
|
||||
|
||||
fun init(){
|
||||
CallerPlanningActionsListenerManager.addListener(TAG, this)
|
||||
}
|
||||
|
||||
override fun pncActions(planningActionMsg: MessagePad.PlanningActionMsg) {
|
||||
try {
|
||||
UiThreadHandler.post {
|
||||
if (CallerAutoPilotStatusListenerManager.getState() == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) {
|
||||
var actions: String? = null
|
||||
var isPlanningFromServer = false
|
||||
planningActionMsg.actionMsg?.let {
|
||||
try {
|
||||
if (it.drivingState.number == MessagePad.DrivingState.USING_RSI_LINK_VALUE) {
|
||||
isPlanningFromServer = true
|
||||
}
|
||||
actions = PncActionsHelper.getAction(
|
||||
it.drivingState.number,
|
||||
it.drivingAction.number
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
planningActionMsg.v2NActionMsgList?.forEach { v2nAction ->
|
||||
if (v2nAction.drivingState.number == MessagePad.DrivingState.USING_RSI_LINK_VALUE) {
|
||||
isPlanningFromServer = true
|
||||
}
|
||||
actions = PncActionsHelper.getAction(
|
||||
v2nAction.drivingState.number,
|
||||
v2nAction.drivingAction.number
|
||||
)
|
||||
}
|
||||
// update view
|
||||
if(actions?.isNotEmpty() == true){
|
||||
val action = AIMessage.PNCAction(actions!!,actions!!)
|
||||
AIMessageManager.post(action)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user