mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-16 01:45:05 +08:00
Remove unused Animator lambda parameter + small cleanup
This commit is contained in:
parent
e9e2e5011b
commit
c17b55b874
@ -96,31 +96,27 @@ class SwipeToDismissHandler(
|
|||||||
.setDuration(ANIMATION_DURATION)
|
.setDuration(ANIMATION_DURATION)
|
||||||
.setInterpolator(AccelerateInterpolator())
|
.setInterpolator(AccelerateInterpolator())
|
||||||
.setUpdateListener { onSwipeViewMove(swipeView.translationY, translationLimit) }
|
.setUpdateListener { onSwipeViewMove(swipeView.translationY, translationLimit) }
|
||||||
.setAnimatorListener(onAnimationEnd = {
|
.setAnimatorEndListener {
|
||||||
if (translationTo != 0f) {
|
if (translationTo != 0f) {
|
||||||
onDismiss()
|
onDismiss()
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove the update listener, otherwise it will be saved on the next animation execution:
|
// remove the update listener, otherwise it will be saved on the next animation execution:
|
||||||
swipeView.animate().setUpdateListener(null)
|
swipeView.animate().setUpdateListener(null)
|
||||||
})
|
}
|
||||||
.start()
|
.start()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun ViewPropertyAnimator.setAnimatorListener(
|
private fun ViewPropertyAnimator.setAnimatorEndListener(
|
||||||
onAnimationEnd: ((Animator?) -> Unit)? = null,
|
onAnimationEnd: () -> Unit,
|
||||||
onAnimationStart: ((Animator?) -> Unit)? = null
|
) = setListener(
|
||||||
) = this.setListener(
|
|
||||||
object : AnimatorListenerAdapter() {
|
object : AnimatorListenerAdapter() {
|
||||||
override fun onAnimationEnd(animation: Animator) {
|
override fun onAnimationEnd(animation: Animator) {
|
||||||
onAnimationEnd?.invoke(animation)
|
onAnimationEnd()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
override fun onAnimationStart(animation: Animator) {
|
private val View.hitRect: Rect
|
||||||
onAnimationStart?.invoke(animation)
|
get() = Rect().also { getHitRect(it) }
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
internal val View?.hitRect: Rect
|
|
||||||
get() = Rect().also { this?.getHitRect(it) }
|
|
||||||
|
Loading…
Reference in New Issue
Block a user