diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/v2x/TrafficLightDispatcher.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/v2x/TrafficLightDispatcher.kt index cbc8fceac5..89ce762699 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/v2x/TrafficLightDispatcher.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/v2x/TrafficLightDispatcher.kt @@ -18,6 +18,7 @@ import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant import com.mogo.eagle.core.utilcode.util.GsonUtils +import com.mogo.eagle.core.utilcode.util.UiThreadHandler import com.zhjt.service.chain.ChainLog import perception.TrafficLightOuterClass import perception.TrafficLightOuterClass.TrafficLight @@ -65,7 +66,8 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight //obu数据 @Volatile private var hasObuLightStatus: Boolean = false - + //红绿灯定时器,超时未更新隐藏红绿灯 + @Volatile private var lightCountDownTimer: CountDownTimer? = null private var lastLightTime: Long = System.currentTimeMillis() @@ -235,25 +237,27 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight //倒计时,超时还未更新数据则隐藏红绿灯 lastLightTime = System.currentTimeMillis() if (lightCountDownTimer == null) { - lightCountDownTimer = object : CountDownTimer(300000, 1000) { - override fun onTick(millisUntilFinished: Long) { - if ((System.currentTimeMillis() - lastLightTime) > 1500) { + UiThreadHandler.post{ + lightCountDownTimer = object : CountDownTimer(300000, 1000) { + override fun onTick(millisUntilFinished: Long) { + if ((System.currentTimeMillis() - lastLightTime) > 1500) { + //隐藏红绿灯显示 + hide("倒计时结束隐藏", lightSource) + lightCountDownTimer?.cancel() + lightCountDownTimer = null + } + } + + override fun onFinish() { //隐藏红绿灯显示 hide("倒计时结束隐藏", lightSource) lightCountDownTimer?.cancel() lightCountDownTimer = null } - } - override fun onFinish() { - //隐藏红绿灯显示 - hide("倒计时结束隐藏", lightSource) - lightCountDownTimer?.cancel() - lightCountDownTimer = null } - + lightCountDownTimer?.start() } - lightCountDownTimer?.start() } CallerTrafficLightListenerManager.showTrafficLight(light, lightSource)