From 74b70b53871dae2fe49a060bafedd858fa097a8e Mon Sep 17 00:00:00 2001 From: renwj Date: Sat, 24 Dec 2022 11:24:02 +0800 Subject: [PATCH] =?UTF-8?q?[2.13.0]=E4=BC=98=E5=8C=96=E8=A7=86=E8=A7=92?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../call/map/CallerVisualAngleManager.kt | 70 ++++++++++++------- 1 file changed, 43 insertions(+), 27 deletions(-) diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/map/CallerVisualAngleManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/map/CallerVisualAngleManager.kt index 79233a269d..19904a4bc2 100644 --- a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/map/CallerVisualAngleManager.kt +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/map/CallerVisualAngleManager.kt @@ -9,7 +9,6 @@ import androidx.lifecycle.Lifecycle.Event import androidx.lifecycle.Lifecycle.Event.ON_DESTROY import androidx.lifecycle.LifecycleEventObserver import androidx.lifecycle.LifecycleOwner -import com.mogo.cloud.commons.utils.CoordinateUtils import com.mogo.eagle.core.data.config.FunctionBuildConfig import com.mogo.eagle.core.data.map.* import com.mogo.eagle.core.data.map.MapRoadInfo.StopLine @@ -254,7 +253,19 @@ object CallerVisualAngleManager { val displayed = getDisplayed() if (displayed == null) { Log.d("${M_DEVA}${TAG}", "--- 2 ---") - doChangeAngle(Record(current, triggerTime = triggerTime)) + if (current is Turning) { + if (!current.open) { + changeVisualAngle(Default()) + return@launch + } + } + if (current is CrossRoad) { + if (!current.open) { + changeVisualAngle(Default()) + return@launch + } + } + doRealVisualAngleChange(triggerTime, current, null) } else { val prev = displayed.target Log.d("${M_DEVA}${TAG}", "--- 3 --- old: $prev -> cur: $current") @@ -290,34 +301,39 @@ object CallerVisualAngleManager { Log.d("${M_DEVA}${TAG}", "--- 6 --- 场景[$prev]正在展示,尚未收到关闭,场景,依然展示当前场景,直接return") return@launch } + doRealVisualAngleChange(triggerTime, current, displayed) + } + } + } - if (current is Default) { - Log.d("${M_DEVA}${TAG}", "--- 9 ---") - defaultDelayJob?.safeCancel() - launch { - val delay = current.unit.toMillis(current.delay) - Log.d("${M_DEVA}${TAG}", "--- 10 ---") - delay(delay) - queue -= displayed - Log.d("${M_DEVA}${TAG}", "--- 11 ---") - doChangeAngle(Record(current, triggerTime = triggerTime)) - }.also { itx -> - itx.invokeOnCompletion { - if (it is CancellationException) { - Log.d("${M_DEVA}${TAG}", "--- 12 ---") - } - } - defaultDelayJob = itx - } - } else { - Log.d("${M_DEVA}${TAG}", "--- 13 ---") - defaultDelayJob?.safeCancel() - if (displayed.target.priority < current.priority) { - Log.d("${M_DEVA}${TAG}", "--- 14 ---") - queue -= displayed - doChangeAngle(Record(current, triggerTime = triggerTime)) + private fun CoroutineScope.doRealVisualAngleChange(triggerTime: Long, target: Scene, displayed: Record? = null) { + if (target is Default) { + Log.d("${M_DEVA}${TAG}", "--- doRealVisualAngleChange --- 1 ---") + defaultDelayJob?.safeCancel() + launch { + val delay = target.unit.toMillis(target.delay) + Log.d("${M_DEVA}${TAG}", "--- doRealVisualAngleChange --- 2 ---") + delay(delay) + displayed?.also { + queue -= it + } + Log.d("${M_DEVA}${TAG}", "--- doRealVisualAngleChange --- 3 ---") + doChangeAngle(Record(target, triggerTime = triggerTime)) + }.also { itx -> + itx.invokeOnCompletion { + if (it is CancellationException) { + Log.d("${M_DEVA}${TAG}", "--- doRealVisualAngleChange --- 4 ---") } } + defaultDelayJob = itx + } + } else { + Log.d("${M_DEVA}${TAG}", "--- doRealVisualAngleChange --- 5 ---") + defaultDelayJob?.safeCancel() + if (displayed == null || displayed.target.priority < target.priority) { + Log.d("${M_DEVA}${TAG}", "--- doRealVisualAngleChange --- 6 ---") + queue -= displayed + doChangeAngle(Record(target, triggerTime = triggerTime)) } } }