diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/ParallelDriveView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/ParallelDriveView.kt index 98e0ae30c6..b3c2b9de4c 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/ParallelDriveView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/ParallelDriveView.kt @@ -50,6 +50,8 @@ class ParallelDriveView @JvmOverloads constructor( //1:ready, 2:自动驾驶中, 7:平行驾驶中 @Volatile private var autopilotState: Int = 1 + @Volatile + private var isAutoDriving: Boolean = false // 初始状态为0 private var state: Int = 0 @@ -107,16 +109,25 @@ class ParallelDriveView @JvmOverloads constructor( when (state) { 7 -> { if (this.autopilotState != 7) { + isAutoDriving = false ThreadUtils.runOnUiThread({ updateUI(PARALLEL_DRIVING) }, ThreadUtils.MODE.QUEUE) } } + 2 -> { + if (this.autopilotState != state) { + isAutoDriving = true + } + } else -> { - if (this.autopilotState == 7 && this.autopilotState != state) { - ThreadUtils.runOnUiThread({ - checkAvailableAndUpdateUI() - }, ThreadUtils.MODE.QUEUE) + if (this.autopilotState != state) { + isAutoDriving = false + if (this.autopilotState == 7) { + ThreadUtils.runOnUiThread({ + checkAvailableAndUpdateUI() + }, ThreadUtils.MODE.QUEUE) + } } } } @@ -177,16 +188,6 @@ class ParallelDriveView @JvmOverloads constructor( } } - private fun isAvailable(unableAutopilotReasons: ArrayList?): Boolean { - var unavailable = false - unableAutopilotReasons?.forEach { - if (it.source.ordinal == SourceType.CHASSIS.ordinal) { - unavailable = true - } - } - return !unavailable - } - @SuppressLint("UseCompatLoadingForDrawables") private fun updateUI(state: Int) { when (state) { @@ -330,12 +331,17 @@ class ParallelDriveView @JvmOverloads constructor( } private fun checkAvailableAndUpdateUI() { - if (CallerParallelDrivingActionsListenerManager.isParallelDrivingAbility()) { + if (isAutoDriving) { state = 0 updateUI(0) } else { - state = UNAVAILABLE - updateUI(UNAVAILABLE) + if (CallerParallelDrivingActionsListenerManager.isParallelDrivingAbility()) { + state = 0 + updateUI(0) + } else { + state = UNAVAILABLE + updateUI(UNAVAILABLE) + } } }