[状态栏]代码逻辑优化

[状态栏]代码逻辑优化
This commit is contained in:
renwj
2022-09-15 15:02:33 +08:00
parent 885b1e8e79
commit 0309d160d5
2 changed files with 7 additions and 7 deletions

View File

@@ -200,12 +200,10 @@ class TracingStatus(var state: Tracing = UNKNOWN): Status() {
UNKNOWN;
fun isException(): Boolean {
val c1 = when (this) {
TRACK_FINDED, TRACK_NOT_EXIST, TRACK_LOAD_FAIL, ROUTE_FAILED, UNKNOWN -> true
else -> false
if (this == TRACK_LOADED || this == ROUTE_LOADED) {
return false
}
val c2 = CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().state != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING
return c1 and c2
return true
}
}

View File

@@ -1,7 +1,6 @@
package com.zhjt.mogo_core_function_devatools.status.flow.trace
import android.content.*
import android.util.*
import com.mogo.eagle.core.data.autopilot.*
import com.mogo.eagle.core.function.api.autopilot.*
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener.Companion.STATUS_AUTOPILOT_RUNNING
@@ -42,6 +41,7 @@ internal class TracingImpl(ctx: Context): IFlow<TracingStatus>(ctx), IMoGoAutopi
override fun onAutopilotIpcConnectStatusChanged(status: Int, reason: String?) {
super.onAutopilotIpcConnectStatusChanged(status, reason)
if (!CallerAutoPilotManager.isConnected()) {
old = UNKNOWN
send(TracingStatus(UNKNOWN))
}
}
@@ -49,10 +49,12 @@ internal class TracingImpl(ctx: Context): IFlow<TracingStatus>(ctx), IMoGoAutopi
override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) {
super.onAutopilotStatusResponse(autoPilotStatusInfo)
if (autoPilotStatusInfo.state != STATUS_AUTOPILOT_RUNNING) {
old = UNKNOWN
send(TracingStatus(UNKNOWN))
return
}
if (old.isException() && autoPilotStatusInfo.state == STATUS_AUTOPILOT_RUNNING) {
if (old.isException()) {
old = TRACK_LOADED
send(TracingStatus(TRACK_LOADED))
}
}