Package org.robolectric.shadows
Class ShadowLegacyChoreographer
- java.lang.Object
-
- org.robolectric.shadows.ShadowChoreographer
-
- org.robolectric.shadows.ShadowLegacyChoreographer
-
@Implements(value=android.view.Choreographer.class, shadowPicker=Picker.class, isInAndroidSdk=false) public class ShadowLegacyChoreographer extends ShadowChoreographer
TheChoreographershadow forLooperMode.Mode.PAUSED.In
LooperMode.Mode.PAUSEDmode, Robolectric maintains its own concept of the current time from the Choreographer's point of view, aimed at making animations work correctly. Time starts out at 0 and advances byframeIntervalevery timeChoreographer.getFrameTimeNanos()is called.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.robolectric.shadows.ShadowChoreographer
ShadowChoreographer.ChoreographerReflector, ShadowChoreographer.Picker
-
-
Constructor Summary
Constructors Constructor Description ShadowLegacyChoreographer()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static longgetFrameInterval()Return the current inter-frame interval.protected longgetFrameTimeNanos()protected static ChoreographergetInstance()protected voidpostCallback(int callbackType, Runnable action, Object token)The default implementation will callpostCallbackDelayed(int, Runnable, Object, long)with no delay.protected voidpostCallbackDelayed(int callbackType, Runnable action, Object token, long delayMillis)protected voidpostFrameCallback(Choreographer.FrameCallback callback)The default implementation will callpostFrameCallbackDelayed(FrameCallback, long)with no delay.protected voidpostFrameCallbackDelayed(Choreographer.FrameCallback callback, long delayMillis)protected voidremoveCallbacks(int callbackType, Runnable action, Object token)protected voidremoveFrameCallback(Choreographer.FrameCallback callback)static voidreset()static voidsetFrameInterval(long frameInterval)Set the inter-frame interval used to advance the clock.static voidsetPostCallbackDelay(int delayMillis)Allows application to specify a fixed amount of delay whenpostCallback(int, Runnable, Object)is invoked.static voidsetPostFrameCallbackDelay(int delayMillis)Allows application to specify a fixed amount of delay whenpostFrameCallback(FrameCallback)is invoked.-
Methods inherited from class org.robolectric.shadows.ShadowChoreographer
doFrame
-
-
-
-
Method Detail
-
setPostCallbackDelay
public static void setPostCallbackDelay(int delayMillis)
Allows application to specify a fixed amount of delay whenpostCallback(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.
-
setPostFrameCallbackDelay
public static void setPostFrameCallbackDelay(int delayMillis)
Allows application to specify a fixed amount of delay whenpostFrameCallback(FrameCallback)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.
-
getInstance
@Implementation protected static Choreographer getInstance()
-
postCallback
@Implementation protected void postCallback(int callbackType, Runnable action, Object token)
The default implementation will callpostCallbackDelayed(int, Runnable, Object, long)with no delay.AnimationHandlercalls this method to schedule animation updates infinitely. Because during a Robolectric test the system time is paused and execution of the event loop is invoked for each test instruction, the behavior of AnimationHandler would result in endless looping (the execution of the task results in a new animation task created and scheduled to the front of the event loop queue).To prevent endless looping, a test may call
setPostCallbackDelay(int)to specify a small delay when animation is scheduled.- See Also:
setPostCallbackDelay(int)
-
postCallbackDelayed
@Implementation protected void postCallbackDelayed(int callbackType, Runnable action, Object token, long delayMillis)
-
removeCallbacks
@Implementation protected void removeCallbacks(int callbackType, Runnable action, Object token)
-
postFrameCallback
@Implementation protected void postFrameCallback(Choreographer.FrameCallback callback)
The default implementation will callpostFrameCallbackDelayed(FrameCallback, long)with no delay.AnimationHandlercalls this method to schedule animation updates infinitely. Because during a Robolectric test the system time is paused and execution of the event loop is invoked for each test instruction, the behavior of AnimationHandler would result in endless looping (the execution of the task results in a new animation task created and scheduled to the front of the event loop queue).To prevent endless looping, a test may call
setPostFrameCallbackDelay(int)to specify a small delay when animation is scheduled.- See Also:
setPostCallbackDelay(int)
-
postFrameCallbackDelayed
@Implementation protected void postFrameCallbackDelayed(Choreographer.FrameCallback callback, long delayMillis)
-
removeFrameCallback
@Implementation protected void removeFrameCallback(Choreographer.FrameCallback callback)
-
getFrameTimeNanos
@Implementation protected long getFrameTimeNanos()
-
getFrameInterval
public static long getFrameInterval()
Return the current inter-frame interval.- Returns:
- Inter-frame interval.
-
setFrameInterval
public static void setFrameInterval(long frameInterval)
Set the inter-frame interval used to advance the clock. By default, this is set to 1ms.- Parameters:
frameInterval- Inter-frame interval.
-
reset
@Resetter public static void reset()
-
-