修复弹窗提示bug
The specified child already has a parent. You must call removeView() on the child's parent first.

Signed-off-by: donghongyu <donghongyu@zhidaoauto.com>
This commit is contained in:
donghongyu
2022-03-24 17:08:19 +08:00
parent 58b9223dc6
commit 2dd75435a5
2 changed files with 18 additions and 2 deletions

16
TestHmiWarning.sh Executable file
View File

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

View File

@@ -90,7 +90,7 @@ internal class WarningFloatWindowHelper(
val floatingView = config.layoutView?.also { val floatingView = config.layoutView?.also {
try { try {
val parent = (it.parent as ViewGroup) val parent = (it.parent as ViewGroup)
parent.removeView(it) parent.removeAllViews()
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printStackTrace()
} }
@@ -220,12 +220,12 @@ internal class WarningFloatWindowHelper(
* 退出动画执行结束/没有退出动画,进行回调、移除等操作 * 退出动画执行结束/没有退出动画,进行回调、移除等操作
*/ */
fun remove(force: Boolean = false) = try { fun remove(force: Boolean = false) = try {
frameLayout?.removeAllViews()
frameLayout?.removeCallbacks(closeWarningTask) frameLayout?.removeCallbacks(closeWarningTask)
config.isAnim = false config.isAnim = false
WarningFloatWindowManager.remove(config.floatTag) WarningFloatWindowManager.remove(config.floatTag)
// removeView是异步删除在Activity销毁的时候会导致窗口泄漏所以使用removeViewImmediate直接删除view // removeView是异步删除在Activity销毁的时候会导致窗口泄漏所以使用removeViewImmediate直接删除view
windowManager.run { windowManager.run {
frameLayout?.removeAllViews()
if (force) { if (force) {
removeViewImmediate(frameLayout) removeViewImmediate(frameLayout)
} else { } else {