修复弹窗与红边不同步消失现象

This commit is contained in:
董宏宇
2021-09-13 20:43:41 +08:00
parent 237f2633da
commit b290730fb8
2 changed files with 7 additions and 3 deletions

View File

@@ -34,6 +34,10 @@ internal class WarningFloatWindowHelper(
var frameLayout: ParentFrameLayout? = null
private var enterAnimator: Animator? = null
private val closeWarningTask: Runnable = Runnable {
exitAnim()
}
fun createWindow(): Boolean {
return if (context is Activity) {
initParams()
@@ -108,9 +112,7 @@ internal class WarningFloatWindowHelper(
// 设置倒计时指定秒数后自动关闭Window
if (config.countDownTime > 0) {
frameLayout?.postDelayed({
exitAnim()
}, config.countDownTime)
frameLayout?.postDelayed(closeWarningTask, config.countDownTime)
}
}
@@ -190,6 +192,7 @@ internal class WarningFloatWindowHelper(
* 退出动画执行结束/没有退出动画,进行回调、移除等操作
*/
fun remove(force: Boolean = false) = try {
frameLayout?.removeCallbacks(closeWarningTask)
config.isAnim = false
WarningFloatWindowManager.remove(config.floatTag)
// removeView是异步删除在Activity销毁的时候会导致窗口泄漏所以使用removeViewImmediate直接删除view

View File

@@ -23,6 +23,7 @@ class V2XWarningView @JvmOverloads constructor(
private val ALL_CLOSE_TIMER = 10000L
private val closeWarningTask: Runnable = Runnable {
Logger.d("V2XWarningView", "预警红边:倒计时结束")
showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
}