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 forChoreographer.Different shadow implementations will be used depending on the current
LooperMode. SeeShadowLegacyChoreographerandShadowPausedChoreographerfor details.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static interfaceShadowChoreographer.ChoreographerReflectorAccessor interface forChoreographer's internalsstatic classShadowChoreographer.Picker
-
Constructor Summary
Constructors Constructor Description ShadowChoreographer()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voiddoFrame(long frameTimeNanos, int frame)static DurationgetFrameDelay()static longgetFrameInterval()Deprecated.Use theLooperMode.Mode.PAUSEDlooper andgetFrameDelay()to configure the frame delay.static booleanisPaused()SeesetPaused(boolean).static voidreset()static voidsetFrameDelay(Duration delay)Sets the delay between each frame.static voidsetFrameInterval(long frameInterval)Deprecated.Use theLooperMode.Mode.PAUSEDlooper andsetFrameDelay(Duration)to configure the frame delay.static voidsetPaused(boolean paused)Sets whether posting a frame should auto advance the clock or not.static voidsetPostCallbackDelay(int delayMillis)Deprecated.Use theLooperMode.Mode.PAUSEDlooper instead.static voidsetPostFrameCallbackDelay(int delayMillis)Deprecated.Use theLooperMode.Mode.PAUSEDlooper andsetPaused(boolean)andsetFrameDelay(Duration)to configure the vsync event behavior.
-
-
-
Method Detail
-
setFrameDelay
public static void setFrameDelay(Duration delay)
Sets the delay between each frame. Note that the frames use theShadowSystemClockand 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.PAUSEDlooper mode.
-
getFrameDelay
public static Duration 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.PAUSEDlooper mode.
-
isPaused
public static boolean isPaused()
SeesetPaused(boolean).
-
setPostCallbackDelay
@Deprecated public static void setPostCallbackDelay(int delayMillis)
Deprecated.Use theLooperMode.Mode.PAUSEDlooper 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 RobolectricScheduleris inScheduler.IdleState.PAUSEDmode.Only supported in
LooperMode.Mode.LEGACY
-
setPostFrameCallbackDelay
@Deprecated public static void setPostFrameCallbackDelay(int delayMillis)
Deprecated.Use theLooperMode.Mode.PAUSEDlooper 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.PAUSEDand displaying an animation.
-
getFrameInterval
@Deprecated public static long getFrameInterval()
Deprecated.Use theLooperMode.Mode.PAUSEDlooper 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 public static void setFrameInterval(long frameInterval)
Deprecated.Use theLooperMode.Mode.PAUSEDlooper 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
@Implementation(maxSdk=30) protected void doFrame(long frameTimeNanos, int frame)
-
reset
@Resetter public static void reset()
-
-