[Fix]彻底修复弹窗从左边飘入问题

Signed-off-by: donghongyu <donghongyu@zhidaoauto.com>
This commit is contained in:
donghongyu
2021-11-18 12:19:55 +08:00
parent ec5aee8725
commit 210f79c471

View File

@@ -12,6 +12,7 @@ import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.view.WindowManager
import com.mogo.eagle.core.function.hmi.R
import com.mogo.eagle.core.function.hmi.notification.anim.AnimatorManager
import com.mogo.eagle.core.function.hmi.notification.enums.ShowPattern
import com.mogo.eagle.core.function.hmi.notification.widget.ParentFrameLayout
@@ -94,15 +95,15 @@ internal class WarningFloatWindowHelper(
// 在浮窗绘制完成的时候,设置初始坐标、执行入场动画
frameLayout?.layoutListener = object : ParentFrameLayout.OnLayoutListener {
override fun onLayout() {
setGravity(frameLayout)
frameLayout?.postDelayed({
setGravity(frameLayout)
config.apply {
enterAnim(floatingView)
// 设置callbacks
layoutView = floatingView
callbacks?.createdResult(true, null, floatingView)
}
}, 700)
}, 100)
}
}
@@ -143,7 +144,7 @@ internal class WarningFloatWindowHelper(
.enterAnim()?.apply {
// 可以延伸到屏幕外,动画结束按需去除该属性,不然旋转屏幕可能置于屏幕外部
params.flags =
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL or WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL or WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
addListener(object : Animator.AnimatorListener {
override fun onAnimationRepeat(animation: Animator?) {}
@@ -188,7 +189,7 @@ internal class WarningFloatWindowHelper(
if (config.isAnim) return
config.isAnim = true
params.flags =
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL or WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL or WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
animator.addListener(object : Animator.AnimatorListener {
override fun onAnimationRepeat(animation: Animator?) {}
@@ -252,8 +253,10 @@ internal class WarningFloatWindowHelper(
params.y = (parentBottom - view.height).shr(1)
}
// 上中
Gravity.CENTER_HORIZONTAL, Gravity.TOP or Gravity.CENTER_HORIZONTAL ->
Gravity.CENTER_HORIZONTAL, Gravity.TOP or Gravity.CENTER_HORIZONTAL -> {
params.x = (parentRect.right - view.width).shr(1)
Log.d(TAG, "layoutParams:${params.x},${params.y}")
}
// 下中
Gravity.BOTTOM or Gravity.CENTER_HORIZONTAL -> {
params.x = (parentRect.right - view.width).shr(1)
@@ -267,8 +270,9 @@ internal class WarningFloatWindowHelper(
params.x = parentRect.right - view.width
params.y = (parentBottom - view.height).shr(1)
}
// 其他情况,均视为
// 其他情况,均视为上
else -> {
params.x = (parentRect.right - view.width).shr(1)
}
}