优化启动时会闪一下的问题
This commit is contained in:
parent
c64e8678a0
commit
77b8d23940
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,7 +1,7 @@
|
|||||||
*.iml
|
*.iml
|
||||||
.gradle
|
.gradle
|
||||||
/local.properties
|
/local.properties
|
||||||
/.idea
|
/.idea/
|
||||||
/.idea/caches
|
/.idea/caches
|
||||||
/.idea/libraries
|
/.idea/libraries
|
||||||
/.idea/modules.xml
|
/.idea/modules.xml
|
||||||
@ -12,4 +12,4 @@
|
|||||||
/build
|
/build
|
||||||
/captures
|
/captures
|
||||||
.externalNativeBuild
|
.externalNativeBuild
|
||||||
.cxx
|
.cxx
|
@ -1,5 +1,6 @@
|
|||||||
package com.yutou.popdialog
|
package com.yutou.popdialog
|
||||||
|
|
||||||
|
import android.animation.Animator
|
||||||
import android.animation.ObjectAnimator
|
import android.animation.ObjectAnimator
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
@ -64,6 +65,7 @@ class POPDialog : Dialog {
|
|||||||
)
|
)
|
||||||
windowParams.gravity = Gravity.BOTTOM
|
windowParams.gravity = Gravity.BOTTOM
|
||||||
view.layoutParams = windowParams
|
view.layoutParams = windowParams
|
||||||
|
view.y=+POPDialogUtils.getDisplay(activityContext).mode.physicalHeight.toFloat()
|
||||||
mainView.addView(view)
|
mainView.addView(view)
|
||||||
super.setContentView(mainView)
|
super.setContentView(mainView)
|
||||||
}
|
}
|
||||||
@ -174,16 +176,35 @@ class POPDialog : Dialog {
|
|||||||
* @param expansion true 展开 false 拉下
|
* @param expansion true 展开 false 拉下
|
||||||
*/
|
*/
|
||||||
private fun expansion(expansion: Boolean) {
|
private fun expansion(expansion: Boolean) {
|
||||||
|
if (showModel == 0 && !expansion) {
|
||||||
|
finish()
|
||||||
|
return
|
||||||
|
}
|
||||||
val viewAnim = if (expansion) {
|
val viewAnim = if (expansion) {
|
||||||
ObjectAnimator.ofFloat(view, "translationY", 0f).setDuration(300L)
|
ObjectAnimator.ofFloat(view, "translationY", 0f).setDuration(300L)
|
||||||
} else {
|
} else {
|
||||||
ObjectAnimator.ofFloat(view, "translationY", expansionY).setDuration(300L)
|
ObjectAnimator.ofFloat(view, "translationY", expansionY).setDuration(300L)
|
||||||
}
|
}
|
||||||
showModel = if (expansion) {
|
|
||||||
1
|
viewAnim.addListener(object : Animator.AnimatorListener {
|
||||||
} else {
|
override fun onAnimationStart(p0: Animator?) {
|
||||||
0
|
}
|
||||||
}
|
|
||||||
|
override fun onAnimationEnd(p0: Animator?) {
|
||||||
|
showModel = if (expansion) {
|
||||||
|
1
|
||||||
|
} else {
|
||||||
|
0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onAnimationCancel(p0: Animator?) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onAnimationRepeat(p0: Animator?) {
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
viewAnim.start()
|
viewAnim.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,6 +288,10 @@ class POPDialog : Dialog {
|
|||||||
view.startAnimation(animation)
|
view.startAnimation(animation)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onTouchEvent(event: MotionEvent): Boolean {
|
||||||
|
return touch.onTouchEvent(event)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 触摸事件
|
* 触摸事件
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user