Package org.robolectric.util
Class Scheduler
java.lang.Object
org.robolectric.util.Scheduler
- Direct Known Subclasses:
- LooperDelegatingScheduler
Deprecated.
Class that manages a queue of Runnables that are scheduled to run now (or at some time in the
 future). Runnables that are scheduled to run on the UI thread (tasks, animations, etc) eventually
 get routed to a Scheduler instance.
 
The execution of a scheduler can be in one of three states:
- paused (pause()): if paused, then no posted events will be run unless the Scheduler is explicitly instructed to do so, correctly matching Android's behavior.
- normal (unPause()): if not paused but not set to idle constantly, then the Scheduler will automatically run anyRunnables that are scheduled to run at or before the Scheduler's current time, but it won't automatically run any future events. To run future events the Scheduler needs to have its clock advanced.
- idling constantly: if setIdleState(IdleState)is called with `CONSTANT_IDLE`, then the Scheduler will continue looping through posted events (including future events), advancing its clock as it goes.
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic enumDeprecated.Describes the current state of aScheduler.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionfinal booleanadvanceBy(long interval) Deprecated.booleanDeprecated.Run all runnables that are scheduled to run in the next time interval.booleanadvanceTo(long endTime) Deprecated.Run all runnables that are scheduled before the endTime.booleanDeprecated.Run all runnables in the queue, and any additional runnables they schedule that are scheduled before the latest scheduled runnable currently in the queue.booleanDeprecated.Run the next runnable in the queue.booleanDeprecated.Determine if any enqueued runnables are enqueued before the current time.longDeprecated.Get the current time (as seen by the scheduler), in milliseconds.Deprecated.Retrieves the current idling state of thisScheduler.Deprecated.Deprecated.booleanisPaused()Deprecated.Determine if the scheduler is paused.voidpause()Deprecated.Pause the scheduler.voidDeprecated.Add a runnable to the queue.voidpostAtFrontOfQueue(Runnable runnable) Deprecated.Add a runnable to the head of the queue.voidpostDelayed(Runnable runnable, long delayMillis) Deprecated.Add a runnable to the queue to be run after a delay.voidpostDelayed(Runnable runnable, long delay, TimeUnit unit) Deprecated.Add a runnable to the queue to be run after a delay.voidDeprecated.Remove a runnable from the queue.voidreset()Deprecated.Reset the internal state of the Scheduler.booleanDeprecated.Run the next runnable in the queue.voidsetIdleState(Scheduler.IdleState idleState) Deprecated.Sets the current idling state of thisScheduler.intsize()Deprecated.Return the number of enqueued runnables.voidunPause()Deprecated.Un-pause the scheduler.
- 
Constructor Details- 
Schedulerpublic Scheduler()Deprecated.
 
- 
- 
Method Details- 
getIdleStateDeprecated.Retrieves the current idling state of thisScheduler.- Returns:
- The current idle state of this Scheduler.
- See Also:
 
- 
setIdleStateDeprecated.Sets the current idling state of thisScheduler. If transitioning to theScheduler.IdleState.UNPAUSEDstate any tasks scheduled to be run at or before the current time will be run, and if transitioning to theScheduler.IdleState.CONSTANT_IDLEstate all scheduled tasks will be run and the clock advanced to the time of the last runnable.- Parameters:
- idleState- The new idle state of this- Scheduler.
- See Also:
 
- 
getCurrentTimepublic long getCurrentTime()Deprecated.Get the current time (as seen by the scheduler), in milliseconds.- Returns:
- Current time in milliseconds.
 
- 
pausepublic void pause()Deprecated.Pause the scheduler. Equivalent tosetIdleState(PAUSED).- See Also:
 
- 
unPausepublic void unPause()Deprecated.Un-pause the scheduler. Equivalent tosetIdleState(UNPAUSED).- See Also:
 
- 
isPausedpublic boolean isPaused()Deprecated.Determine if the scheduler is paused.- Returns:
- true if it is paused.
 
- 
postDeprecated.Add a runnable to the queue.- Parameters:
- runnable- Runnable to add.
 
- 
postDelayedDeprecated.Add a runnable to the queue to be run after a delay.- Parameters:
- runnable- Runnable to add.
- delayMillis- Delay in millis.
 
- 
postDelayedDeprecated.Add a runnable to the queue to be run after a delay.
- 
postAtFrontOfQueueDeprecated.Add a runnable to the head of the queue.- Parameters:
- runnable- Runnable to add.
 
- 
removeDeprecated.Remove a runnable from the queue.- Parameters:
- runnable- Runnable to remove.
 
- 
advanceToLastPostedRunnablepublic boolean advanceToLastPostedRunnable()Deprecated.Run all runnables in the queue, and any additional runnables they schedule that are scheduled before the latest scheduled runnable currently in the queue.- Returns:
- True if a runnable was executed.
 
- 
advanceToNextPostedRunnablepublic boolean advanceToNextPostedRunnable()Deprecated.Run the next runnable in the queue.- Returns:
- True if a runnable was executed.
 
- 
advanceBy@InlineMe(replacement="this.advanceBy(interval, MILLISECONDS)", staticImports="java.util.concurrent.TimeUnit.MILLISECONDS") @Deprecated public final boolean advanceBy(long interval) Deprecated.Run all runnables that are scheduled to run in the next time interval.- Parameters:
- interval- Time interval (in millis).
- Returns:
- True if a runnable was executed.
 
- 
advanceByDeprecated.Run all runnables that are scheduled to run in the next time interval.- Returns:
- True if a runnable was executed.
 
- 
advanceTopublic boolean advanceTo(long endTime) Deprecated.Run all runnables that are scheduled before the endTime.- Parameters:
- endTime- Future time.
- Returns:
- True if a runnable was executed.
 
- 
runOneTaskpublic boolean runOneTask()Deprecated.Run the next runnable in the queue.- Returns:
- True if a runnable was executed.
 
- 
areAnyRunnablepublic boolean areAnyRunnable()Deprecated.Determine if any enqueued runnables are enqueued before the current time.- Returns:
- True if any runnables can be executed.
 
- 
resetpublic void reset()Deprecated.Reset the internal state of the Scheduler.
- 
sizepublic int size()Deprecated.Return the number of enqueued runnables.- Returns:
- Number of enqueues runnables.
 
- 
getNextScheduledTaskTimeDeprecated.
- 
getLastScheduledTaskTimeDeprecated.
 
- 
invalid reference