Skip to content

Instantly share code, notes, and snippets.

Created January 24, 2018 16:41
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/15766bbdee613a20c69ab0a0bda414e3 to your computer and use it in GitHub Desktop.
Save anonymous/15766bbdee613a20c69ab0a0bda414e3 to your computer and use it in GitHub Desktop.
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