From 7bd215e3dbf0170f048a66e5613e08fcfad42daf Mon Sep 17 00:00:00 2001 From: chenfufeng Date: Tue, 19 Sep 2023 11:46:31 +0800 Subject: [PATCH] =?UTF-8?q?[6.1.0][Fix]=E8=A7=A3=E5=86=B3=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E9=A9=BE=E9=A9=B6=E4=B8=AD=E4=B8=8D=E5=8F=AF=E4=BB=8B?= =?UTF-8?q?=E5=85=A5=E5=B9=B3=E8=A1=8C=E9=A9=BE=E9=A9=B6=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hmi/ui/widget/ParallelDriveView.kt | 40 +++++++++++-------- 1 file changed, 23 insertions(+), 17 deletions(-) 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) + } } }