Skip to content

Instantly share code, notes, and snippets.

@nikhilpanju
Created December 2, 2019 16:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nikhilpanju/fd78678d6c1b1f54ec0a17ffab7b5b7b to your computer and use it in GitHub Desktop.
Save nikhilpanju/fd78678d6c1b1f54ec0a17ffab7b5b7b to your computer and use it in GitHub Desktop.
inline fun getValueAnimator(forward: Boolean = true, duration: Long, interpolator: TimeInterpolator,
crossinline updateListener: (progress: Float) -> Unit
): ValueAnimator {
val a =
if (forward) ValueAnimator.ofFloat(0f, 1f)
else ValueAnimator.ofFloat(1f, 0f)
a.addUpdateListener { updateListener(it.animatedValue as Float) }
a.duration = duration
a.interpolator = interpolator
return a
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment