[3.4.0]红绿灯修复定时器问题

This commit is contained in:
xuxinchao
2023-08-02 12:25:03 +08:00
committed by zhongchao
parent f00cd752b0
commit fa76e9cbc2

View File

@@ -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)