Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
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 void resume() | Clears an override without moving time: now() carries on from the overridden value at the wall clock’s pace. |
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().resume
public static void resume()Clears an override without moving time: now() carries on from the
overridden value at the wall clock’s pace. Every start time an animation or
timer recorded under the override stays in step, where reset()
would jump to the wall clock and stall anything that started ahead of it.
Does nothing when no override is active. The offset stays until
reset(), so code that compares this clock with
System.currentTimeMillis() sees the difference; read one clock throughout.isOverridden
public static boolean isOverridden()Returns true when an override time is currently active.
Returns
true when now() is returning an overridden value