From 2dd75435a5432aa7a679f71df86ddb89fe9a9f1d Mon Sep 17 00:00:00 2001 From: donghongyu Date: Thu, 24 Mar 2022 17:08:19 +0800 Subject: [PATCH] =?UTF-8?q?[Change]=20=E4=BF=AE=E5=A4=8D=E5=BC=B9=E7=AA=97?= =?UTF-8?q?=E6=8F=90=E7=A4=BAbug=20The=20specified=20child=20already=20has?= =?UTF-8?q?=20a=20parent.=20You=20must=20call=20removeView()=20on=20the=20?= =?UTF-8?q?child's=20parent=20first.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: donghongyu --- TestHmiWarning.sh | 16 ++++++++++++++++ .../hmi/notification/WarningFloatWindowHelper.kt | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100755 TestHmiWarning.sh diff --git a/TestHmiWarning.sh b/TestHmiWarning.sh new file mode 100755 index 0000000000..1ab54760cc --- /dev/null +++ b/TestHmiWarning.sh @@ -0,0 +1,16 @@ +#!/bin/bash +for index in `seq 300`; +do + b=$(( $index % 2 )) + if [ $b = 0 ] + then + echo "200011" + adb shell am broadcast -a com.hmi.v2x.notification --ez v2xIsShow true --es tag "200011" --ei v2xType 20011 --es alertContent "测试外部传入数据1" --es ttsContent "测试TTS1" + else + echo "200012" + adb shell am broadcast -a com.hmi.v2x.notification --ez v2xIsShow true --es tag "200012" --ei v2xType 20012 --es alertContent "测试外部传入数据2" --es ttsContent "测试TTS2" + fi + sleep 0.5 +done + +echo -e "\033[32m 恭喜你完成了所有 测试脚本 \033[0m" \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/notification/WarningFloatWindowHelper.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/notification/WarningFloatWindowHelper.kt index 564e7b4aac..8df1a947ee 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/notification/WarningFloatWindowHelper.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/notification/WarningFloatWindowHelper.kt @@ -90,7 +90,7 @@ internal class WarningFloatWindowHelper( val floatingView = config.layoutView?.also { try { val parent = (it.parent as ViewGroup) - parent.removeView(it) + parent.removeAllViews() } catch (e: Exception) { e.printStackTrace() } @@ -220,12 +220,12 @@ internal class WarningFloatWindowHelper( * 退出动画执行结束/没有退出动画,进行回调、移除等操作 */ fun remove(force: Boolean = false) = try { + frameLayout?.removeAllViews() frameLayout?.removeCallbacks(closeWarningTask) config.isAnim = false WarningFloatWindowManager.remove(config.floatTag) // removeView是异步删除,在Activity销毁的时候会导致窗口泄漏,所以使用removeViewImmediate直接删除view windowManager.run { - frameLayout?.removeAllViews() if (force) { removeViewImmediate(frameLayout) } else {