|
@@ -349,9 +349,10 @@ class AnimationUtil private constructor() {
|
|
|
}
|
|
|
|
|
|
fun showViewAlpha(view: View?, duration: Long = 300) {
|
|
|
- if (view != null && view.visibility != View.VISIBLE) {
|
|
|
- val pvhA = PropertyValuesHolder.ofFloat("alpha", 0f, 1.0f)
|
|
|
- val animAlpha = ObjectAnimator.ofPropertyValuesHolder(view, pvhA)
|
|
|
+ if (view != null) {
|
|
|
+ val pvhA = PropertyValuesHolder.ofFloat("alpha", view.alpha, 1.0f)
|
|
|
+ val pvhV = PropertyValuesHolder.ofInt("visibility", view.visibility, View.VISIBLE)
|
|
|
+ val animAlpha = ObjectAnimator.ofPropertyValuesHolder(view, pvhA, pvhV)
|
|
|
animAlpha.interpolator = AccelerateInterpolator()
|
|
|
animAlpha.addListener(object : AnimatorListenerAdapter() {
|
|
|
override fun onAnimationStart(animation: Animator) {
|
|
@@ -364,14 +365,15 @@ class AnimationUtil private constructor() {
|
|
|
}
|
|
|
|
|
|
fun hideViewAlpha(view: View?, duration: Long = 300) {
|
|
|
- if (view != null && view.visibility == View.VISIBLE) {
|
|
|
- val pvhA = PropertyValuesHolder.ofFloat("alpha", 1.0f, 0f)
|
|
|
- val animAlpha = ObjectAnimator.ofPropertyValuesHolder(view, pvhA)
|
|
|
+ if (view != null) {
|
|
|
+ val pvhA = PropertyValuesHolder.ofFloat("alpha", view.alpha, 0f)
|
|
|
+ val pvhV = PropertyValuesHolder.ofInt("visibility", view.visibility, View.INVISIBLE)
|
|
|
+ val animAlpha = ObjectAnimator.ofPropertyValuesHolder(view, pvhA, pvhV)
|
|
|
animAlpha.interpolator = AccelerateInterpolator()
|
|
|
animAlpha.addListener(object : AnimatorListenerAdapter() {
|
|
|
override fun onAnimationEnd(animation: Animator) {
|
|
|
super.onAnimationEnd(animation)
|
|
|
- Handler(Looper.getMainLooper()).post { view.visibility = View.GONE }
|
|
|
+ Handler(Looper.getMainLooper()).post { view.visibility = View.INVISIBLE }
|
|
|
}
|
|
|
})
|
|
|
animAlpha.setDuration(duration).start()
|