Package org.robolectric.android.internal
Class LooperDelegatingScheduler
java.lang.Object
org.robolectric.util.Scheduler
org.robolectric.android.internal.LooperDelegatingScheduler
A foreground Scheduler implementation used for
LooperMode.Mode.PAUSED.
All API calls will delegate to ShadowLooper.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.robolectric.util.Scheduler
Scheduler.IdleState -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanRun all runnables that are scheduled to run in the next time interval.booleanadvanceTo(long endTime) Run all runnables that are scheduled before the endTime.booleanRun all runnables in the queue, and any additional runnables they schedule that are scheduled before the latest scheduled runnable currently in the queue.booleanRun the next runnable in the queue.booleanDetermine if any enqueued runnables are enqueued before the current time.longGet the current time (as seen by the scheduler), in milliseconds.Retrieves the current idling state of thisScheduler.voididleConstantly(boolean shouldIdleConstantly) Deprecated.booleanisPaused()Determine if the scheduler is paused.voidpause()Pause the scheduler.voidAdd a runnable to the queue.voidpostAtFrontOfQueue(Runnable runnable) Add a runnable to the head of the queue.voidpostDelayed(Runnable runnable, long delayMillis) Add a runnable to the queue to be run after a delay.voidpostDelayed(Runnable runnable, long delay, TimeUnit unit) Add a runnable to the queue to be run after a delay.voidRemove a runnable from the queue.voidreset()Reset the internal state of the Scheduler.booleanRun the next runnable in the queue.voidsetIdleState(Scheduler.IdleState idleState) Sets the current idling state of thisScheduler.intsize()Return the number of enqueued runnables.voidunPause()Un-pause the scheduler.
-
Constructor Details
-
LooperDelegatingScheduler
-
-
Method Details
-
getIdleState
Description copied from class:SchedulerRetrieves the current idling state of thisScheduler.- Overrides:
getIdleStatein classScheduler- Returns:
- The current idle state of this
Scheduler. - See Also:
-
setIdleState
Description copied from class:SchedulerSets 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.- Overrides:
setIdleStatein classScheduler- Parameters:
idleState- The new idle state of thisScheduler.- See Also:
-
getCurrentTime
public long getCurrentTime()Description copied from class:SchedulerGet the current time (as seen by the scheduler), in milliseconds.- Overrides:
getCurrentTimein classScheduler- Returns:
- Current time in milliseconds.
-
pause
public void pause()Description copied from class:SchedulerPause the scheduler. Equivalent tosetIdleState(PAUSED). -
unPause
public void unPause()Description copied from class:SchedulerUn-pause the scheduler. Equivalent tosetIdleState(UNPAUSED). -
isPaused
public boolean isPaused()Description copied from class:SchedulerDetermine if the scheduler is paused. -
post
Description copied from class:SchedulerAdd a runnable to the queue. -
postDelayed
Description copied from class:SchedulerAdd a runnable to the queue to be run after a delay.- Overrides:
postDelayedin classScheduler- Parameters:
runnable- Runnable to add.delayMillis- Delay in millis.
-
postDelayed
Description copied from class:SchedulerAdd a runnable to the queue to be run after a delay.- Overrides:
postDelayedin classScheduler
-
postAtFrontOfQueue
Description copied from class:SchedulerAdd a runnable to the head of the queue.- Overrides:
postAtFrontOfQueuein classScheduler- Parameters:
runnable- Runnable to add.
-
remove
Description copied from class:SchedulerRemove a runnable from the queue. -
advanceToLastPostedRunnable
public boolean advanceToLastPostedRunnable()Description copied from class:SchedulerRun all runnables in the queue, and any additional runnables they schedule that are scheduled before the latest scheduled runnable currently in the queue.- Overrides:
advanceToLastPostedRunnablein classScheduler- Returns:
- True if a runnable was executed.
-
advanceToNextPostedRunnable
public boolean advanceToNextPostedRunnable()Description copied from class:SchedulerRun the next runnable in the queue.- Overrides:
advanceToNextPostedRunnablein classScheduler- Returns:
- True if a runnable was executed.
-
advanceBy
Description copied from class:SchedulerRun all runnables that are scheduled to run in the next time interval. -
advanceTo
public boolean advanceTo(long endTime) Description copied from class:SchedulerRun all runnables that are scheduled before the endTime. -
runOneTask
public boolean runOneTask()Description copied from class:SchedulerRun the next runnable in the queue.- Overrides:
runOneTaskin classScheduler- Returns:
- True if a runnable was executed.
-
areAnyRunnable
public boolean areAnyRunnable()Description copied from class:SchedulerDetermine if any enqueued runnables are enqueued before the current time.- Overrides:
areAnyRunnablein classScheduler- Returns:
- True if any runnables can be executed.
-
reset
public void reset()Description copied from class:SchedulerReset the internal state of the Scheduler. -
size
public int size()Description copied from class:SchedulerReturn the number of enqueued runnables. -
getNextScheduledTaskTime
- Overrides:
getNextScheduledTaskTimein classScheduler
-
getLastScheduledTaskTime
- Overrides:
getLastScheduledTaskTimein classScheduler
-
idleConstantly
Deprecated.Description copied from class:SchedulerSet the idle state of the Scheduler. If necessary, the clock will be advanced and runnables executed as required by the newly-set state.- Overrides:
idleConstantlyin classScheduler- Parameters:
shouldIdleConstantly- If true the idle state will be set toScheduler.IdleState.CONSTANT_IDLE, otherwise it will be set toScheduler.IdleState.UNPAUSED.
-