Package org.robolectric.shadows
Class ShadowChoreographer
java.lang.Object
org.robolectric.shadows.ShadowChoreographer
- Direct Known Subclasses:
ShadowLegacyChoreographer
,ShadowPausedChoreographer
@Implements(value=android.view.Choreographer.class,
shadowPicker=Picker.class)
public abstract class ShadowChoreographer
extends Object
The shadow API for
Choreographer
.
Different shadow implementations will be used depending on the current LooperMode
. See
ShadowLegacyChoreographer
and ShadowPausedChoreographer
for details.
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static interface
Accessor interface forChoreographer
's CallbackQueue internalsprotected static interface
Accessor interface forChoreographer
's internalsstatic class
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
doFrame
(long frameTimeNanos, int frame) protected void
static Duration
static long
Deprecated.static long
This field is only used whenisPaused()
is true.static boolean
isPaused()
SeesetPaused(boolean)
.static void
reset()
static void
setFrameDelay
(Duration delay) Sets the delay between each frame.static void
setFrameInterval
(long frameInterval) Deprecated.Use theLooperMode.Mode.PAUSED
looper andsetFrameDelay(Duration)
to configure the frame delay.static void
setPaused
(boolean paused) Sets whether posting a frame should auto advance the clock or not.static void
setPostCallbackDelay
(int delayMillis) Deprecated.Use theLooperMode.Mode.PAUSED
looper instead.static void
setPostFrameCallbackDelay
(int delayMillis) Deprecated.Use theLooperMode.Mode.PAUSED
looper andsetPaused(boolean)
andsetFrameDelay(Duration)
to configure the vsync event behavior.
-
Constructor Details
-
ShadowChoreographer
public ShadowChoreographer()
-
-
Method Details
-
setFrameDelay
Sets the delay between each frame. Note that the frames use theShadowSystemClock
and so have the same fidelity, when using the paused looper mode (which is the only mode supported byShadowDisplayEventReceiver
) the clock has millisecond fidelity.Reasonable delays may be 15ms (approximating 60fps ~16.6ms), 10ms (approximating 90fps ~11.1ms), and 30ms (approximating 30fps ~33.3ms). Choosing too small of a frame delay may increase runtime as animation frames will have more steps.
Only works in
LooperMode.Mode.PAUSED
looper mode. -
getFrameDelay
-
setPaused
public static void setPaused(boolean paused) Sets whether posting a frame should auto advance the clock or not. When paused the clock is not auto advanced, when unpaused the clock is advanced by the frame delay every time a frame callback is added. The default is not paused.Only works in
LooperMode.Mode.PAUSED
looper mode. -
isPaused
public static boolean isPaused()SeesetPaused(boolean)
. -
getNextVsyncTime
public static long getNextVsyncTime()This field is only used whenisPaused()
is true. It represents the next scheduled vsync time (with respect to the system clock). When the system clock is advanced to or beyond this time, a Choreographer frame will be triggered. It may be useful for tests to know when the next scheduled vsync time is in order to determine how long to idle the main looper in order to trigger the next Choreographer callback. -
setPostCallbackDelay
Deprecated.Use theLooperMode.Mode.PAUSED
looper instead.Allows application to specify a fixed amount of delay when#postCallback(int, Runnable, Object)
is invoked. The default delay value is 0. This can be used to avoid infinite animation tasks to be spawned when the RobolectricScheduler
is inScheduler.IdleState.PAUSED
mode.Only supported in
LooperMode.Mode.LEGACY
-
setPostFrameCallbackDelay
Deprecated.Use theLooperMode.Mode.PAUSED
looper andsetPaused(boolean)
andsetFrameDelay(Duration)
to configure the vsync event behavior.Allows application to specify a fixed amount of delay when#postFrameCallback(FrameCallback)
is invoked. The default delay value is 0. This can be used to avoid infinite animation tasks to be spawned when in LooperMode PAUSED orScheduler.IdleState.PAUSED
and displaying an animation. -
getFrameInterval
Deprecated.Use theLooperMode.Mode.PAUSED
looper andgetFrameDelay()
to configure the frame delay.Return the current inter-frame interval.Can only be used in
LooperMode.Mode.LEGACY
- Returns:
- Inter-frame interval.
-
setFrameInterval
Deprecated.Use theLooperMode.Mode.PAUSED
looper andsetFrameDelay(Duration)
to configure the frame delay.Set the inter-frame interval used to advance the clock. By default, this is set to 1ms.Only supported in
LooperMode.Mode.LEGACY
- Parameters:
frameInterval
- Inter-frame interval.
-
doFrame
-
doFrame
@Implementation(minSdk=31) protected void doFrame(long frameTimeNanos, int frame, Object vsyncEventData) -
reset
-
LooperMode.Mode.PAUSED
looper andgetFrameDelay()
to configure the frame delay.