Skip to content

Instantly share code, notes, and snippets.

@iChintanSoni
Created July 7, 2018 12:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iChintanSoni/35679f1fb71817c80637c3b0dcb30bf4 to your computer and use it in GitHub Desktop.
Save iChintanSoni/35679f1fb71817c80637c3b0dcb30bf4 to your computer and use it in GitHub Desktop.
class AnimatorExtension {
// Skipping the initialization
private val animator: Animator? = null
// Normal Usage
fun normalAnimationListener() {
animator?.addListener(
onStart = {
},
onEnd = {
},
onCancel = {
},
onRepeat = {
}
)
}
// For Kitkat and above
fun animationPauseListener() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
animator?.addPauseListener(
onPause = {
},
onResume = {
}
)
}
}
// Also set individual animation listeners
fun individualAnimationListener() {
animator?.doOnPause {
}
animator?.doOnCancel {
}
animator?.doOnEnd {
}
animator?.doOnRepeat {
}
animator?.doOnResume {
}
animator?.doOnStart {
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment