Package icyllis.modernui.animation
Class AnimationUtils
java.lang.Object
icyllis.modernui.animation.AnimationUtils
Defines common utilities for working with animations.
-
Method Summary
Modifier and TypeMethodDescriptionstatic long
Returns the current animation time in milliseconds used to update animations.static void
lockAnimationClock
(long vsyncMillis) Locks AnimationUtilscurrentAnimationTimeMillis()
to a fixed value for the current thread.static void
Frees the time lock set in place bylockAnimationClock(long)
.
-
Method Details
-
lockAnimationClock
@Internal public static void lockAnimationClock(long vsyncMillis) Locks AnimationUtilscurrentAnimationTimeMillis()
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()
, andcurrentAnimationTimeMillis()
are all called on the same thread. -
unlockAnimationClock
@Internal public static void unlockAnimationClock()Frees the time lock set in place bylockAnimationClock(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 fromCore.timeMillis()
which gives you a real current time.- Returns:
- the current animation time in milliseconds
-