Created
July 7, 2018 12:55
-
-
Save iChintanSoni/35679f1fb71817c80637c3b0dcb30bf4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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