Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
fun ViewPropertyAnimator.setListener(init: ViewPropertyAnimator.() -> Unit) {
this.init()
}
inline fun ViewPropertyAnimator.onAnimationEnd(crossinline continuation: (Animator) -> Unit) {
setListener(object : AnimatorListenerAdapter() {
override fun onAnimationEnd(animation: Animator) {
continuation(animation)
}
})
}
inline fun ViewPropertyAnimator.onAnimationStart(crossinline continuation: (Animator) -> Unit) {
setListener(object : AnimatorListenerAdapter() {
override fun onAnimationStart(animation: Animator) {
continuation(animation)
}
})
}
fab.animate()
.alpha(0f)
.setListener {
onAnimationStart {
// bla bla
}
onAnimationEnd {
// bla bla
}
}
fab.animate().onAnimationEnd {
// bla bla
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment