Class 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.
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanReturns true when an override time is currently active.static longnow()Returns the current animation time in milliseconds.static voidreset()Clears any override and restores now() to delegate toSystem.currentTimeMillis().static voidsetTime(long time) Overrides the value returned by now().
-
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
timevalue until either this method is called again or reset() is invoked. Advancing animations while overridden requires repeatedly calling this method with increasing values.Parameters
time: the time in milliseconds that now() should return
-
reset
public static void reset()Clears any override and restores now() to delegate toSystem.currentTimeMillis(). -
isOverridden
public static boolean isOverridden()Returns true when an override time is currently active.
Returns
true when now() is returning an overridden value
-