diff --git a/README_shell.md b/README_shell.md index 7c590f74af..b060af0060 100644 --- a/README_shell.md +++ b/README_shell.md @@ -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" 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 040628e086..564e7b4aac 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 @@ -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) // 在浮窗绘制完成的时候,设置初始坐标、执行入场动画