修复弹窗提示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

View File

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