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 internalsstatic class
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
doFrame
(long frameTimeNanos, int frame) static Duration
static long
Deprecated.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)
. -
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
-
reset
-
LooperMode.Mode.PAUSED
looper andgetFrameDelay()
to configure the frame delay.