From c16b14f01dd2215fc276ac558cc7862c05b4bbfd Mon Sep 17 00:00:00 2001 From: xuxinchao Date: Wed, 2 Aug 2023 12:25:03 +0800 Subject: [PATCH] =?UTF-8?q?[3.4.0]=E7=BA=A2=E7=BB=BF=E7=81=AF=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=AE=9A=E6=97=B6=E5=99=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datacenter/v2x/TrafficLightDispatcher.kt | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) 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)