优化启动时会闪一下的问题

This commit is contained in:
Yutousama 2022-05-26 12:22:33 +08:00
parent c64e8678a0
commit 77b8d23940
2 changed files with 32 additions and 7 deletions

2
.gitignore vendored
View File

@ -1,7 +1,7 @@
*.iml
.gradle
/local.properties
/.idea
/.idea/
/.idea/caches
/.idea/libraries
/.idea/modules.xml

View File

@ -1,5 +1,6 @@
package com.yutou.popdialog
import android.animation.Animator
import android.animation.ObjectAnimator
import android.annotation.SuppressLint
import android.app.Activity
@ -64,6 +65,7 @@ class POPDialog : Dialog {
)
windowParams.gravity = Gravity.BOTTOM
view.layoutParams = windowParams
view.y=+POPDialogUtils.getDisplay(activityContext).mode.physicalHeight.toFloat()
mainView.addView(view)
super.setContentView(mainView)
}
@ -174,16 +176,35 @@ class POPDialog : Dialog {
* @param expansion true 展开 false 拉下
*/
private fun expansion(expansion: Boolean) {
if (showModel == 0 && !expansion) {
finish()
return
}
val viewAnim = if (expansion) {
ObjectAnimator.ofFloat(view, "translationY", 0f).setDuration(300L)
} else {
ObjectAnimator.ofFloat(view, "translationY", expansionY).setDuration(300L)
}
viewAnim.addListener(object : Animator.AnimatorListener {
override fun onAnimationStart(p0: Animator?) {
}
override fun onAnimationEnd(p0: Animator?) {
showModel = if (expansion) {
1
} else {
0
}
}
override fun onAnimationCancel(p0: Animator?) {
}
override fun onAnimationRepeat(p0: Animator?) {
}
})
viewAnim.start()
}
@ -267,6 +288,10 @@ class POPDialog : Dialog {
view.startAnimation(animation)
}
override fun onTouchEvent(event: MotionEvent): Boolean {
return touch.onTouchEvent(event)
}
/**
* 触摸事件
*/