[2.13.0]优化视角切换逻辑
This commit is contained in:
@@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user