public final class AnimationTime
- Object
- AnimationTime
Pluggable time source for animations across the framework. Defaults to
System.currentTimeMillis() but can be overridden with an explicit value to
support deterministic playback (e.g. UI tests), to advance animations at a
custom pace (slow-motion, fast-forward), or to step through animation frames
manually.
All methods are static and the class holds only primitive state to keep the
hot path cheap - now() is invoked from every animation tick.
Methods
public static long now() | Returns the current animation time in milliseconds. |
public static void setTime(long time) | Overrides the value returned by now(). |
public static void reset() | Clears any override and restores now() to delegate to System.currentTimeMillis(). |
public static boolean isOverridden() | Returns true when an override time is currently active. |
Inherited methods
Method details
now
public static long now()Returns the current animation time in milliseconds. Returns
System.currentTimeMillis() unless an override has been set via
setTime(long).Returns
the current animation time in milliseconds
setTime
public static void setTime(long time)Overrides the value returned by now(). Once set, every animation
reading the clock will see the same
time value until either this method
is called again or reset() is invoked. Advancing animations
while overridden requires repeatedly calling this method with increasing
values.Parameters
timelong- the time in milliseconds that now() should return
reset
public static void reset()Clears any override and restores now() to delegate to
System.currentTimeMillis().isOverridden
public static boolean isOverridden()Returns true when an override time is currently active.
Returns
true when now() is returning an overridden value