Package icyllis.modernui.animation

# Class AnimationUtils

java.lang.Object
icyllis.modernui.animation.AnimationUtils

public final class AnimationUtils extends Object
Defines common utilities for working with animations.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static long`
  `currentAnimationTimeMillis()`
  Returns the current animation time in milliseconds used to update animations.
  `static void`
  `lockAnimationClock(long vsyncMillis)`
  Locks AnimationUtils`currentAnimationTimeMillis()` to a fixed value for the current thread.
  `static void`
  `unlockAnimationClock()`
  Frees the time lock set in place by `lockAnimationClock(long)`.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### lockAnimationClock

    @Internal public static void lockAnimationClock(long vsyncMillis)
    Locks AnimationUtils`currentAnimationTimeMillis()` to a fixed value for the current thread.

    Must be followed by a call to `unlockAnimationClock()` to allow time to progress. Failing to do this will result in stuck animations, scrolls, and flings.

    Note that time is not allowed to "rewind" and must perpetually flow forward. So the lock may fail if the time is in the past from a previously returned value, however time will be frozen for the duration of the lock. The clock is a thread-local, so ensure that this method, `unlockAnimationClock()`, and `currentAnimationTimeMillis()` are all called on the same thread.

  - ### unlockAnimationClock

    @Internal public static void unlockAnimationClock()
    Frees the time lock set in place by `lockAnimationClock(long)`. Must be called to allow the animation clock to self-update.

  - ### currentAnimationTimeMillis

    public static long currentAnimationTimeMillis()
    Returns the current animation time in milliseconds used to update animations. This value is updated and synced when a new frame started, it's different from `Core.timeMillis()` which gives you a real current time.
    Returns:
      the current animation time in milliseconds