[Change]
修复弹窗提示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:
@@ -19,7 +19,7 @@ adb pull /sdcard/Android/data/com.mogo.launcher.f/log/20211022
|
||||
|
||||
// (新的HMI)使用命令行触发 V2X 预警场景
|
||||
// 顶部弹窗场景,控制展示
|
||||
adb shell am broadcast -a com.hmi.v2x.notification --ez v2xIsShow true --es tag "200011" --ei v2xType 20011 --es alertContent "测试外部传入数据" --es ttsContent "测试TTS"
|
||||
adb shell am broadcast -a com.hmi.v2x.notification --ez v2xIsShow true --es tag "200012" --ei v2xType 20012 --es alertContent "测试外部传入数据2" --es ttsContent "测试TTS2"
|
||||
// 关闭顶部弹窗
|
||||
adb shell am broadcast -a com.hmi.v2x.notification --ez v2xIsShow false --es tag "200011"
|
||||
|
||||
|
||||
@@ -7,17 +7,15 @@ import android.app.Service
|
||||
import android.content.Context
|
||||
import android.graphics.PixelFormat
|
||||
import android.graphics.Rect
|
||||
import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import com.mogo.eagle.core.function.hmi.notification.anim.AnimatorManager
|
||||
import android.view.*
|
||||
import com.mogo.eagle.core.data.enums.ShowPattern
|
||||
import com.mogo.eagle.core.function.hmi.notification.anim.AnimatorManager
|
||||
import com.mogo.eagle.core.function.hmi.notification.widget.ParentFrameLayout
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_HMI
|
||||
import com.mogo.eagle.core.utilcode.util.WindowUtils
|
||||
|
||||
|
||||
/**
|
||||
* @author donghongyu
|
||||
* @date 2021/8/5 5:29 下午
|
||||
@@ -89,12 +87,18 @@ internal class WarningFloatWindowHelper(
|
||||
frameLayout = ParentFrameLayout(context, config)
|
||||
frameLayout?.tag = config.floatTag
|
||||
// 将浮窗布局文件添加到父容器frameLayout中,并返回该浮窗文件
|
||||
val floatingView = config.layoutView?.also { frameLayout?.addView(it) }
|
||||
?: LayoutInflater.from(context).inflate(config.layoutId!!, frameLayout, true)
|
||||
val floatingView = config.layoutView?.also {
|
||||
try {
|
||||
val parent = (it.parent as ViewGroup)
|
||||
parent.removeView(it)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
frameLayout?.addView(it)
|
||||
} ?: LayoutInflater.from(context).inflate(config.layoutId!!, frameLayout, true)
|
||||
// 为了避免创建的时候闪一下,我们先隐藏视图,不能直接设置GONE,否则定位会出现问题
|
||||
floatingView.visibility = View.INVISIBLE
|
||||
// 将frameLayout添加到系统windowManager中
|
||||
|
||||
windowManager.addView(frameLayout, params)
|
||||
|
||||
// 在浮窗绘制完成的时候,设置初始坐标、执行入场动画
|
||||
|
||||
Reference in New Issue
Block a user