Class ShadowPausedLooper
@Implements(value=android.os.Looper.class, isInAndroidSdk=false) public final class ShadowPausedLooper extends ShadowLooper
LooperMode.Mode.PAUSED.
This shadow differs from the legacy ShadowLegacyLooper in the following ways:\ - Has
no connection to Scheduler. Its APIs are standalone - The main
looper is always paused. Posted messages are not executed unless idle() is called. -
Just like in real Android, each looper has its own thread, and posted tasks get executed in that
thread. - - There is only a single SystemClock value that all loopers read from. Unlike
legacy behavior where each Scheduler kept their own clock value.
This class should not be used directly; use ShadowLooper instead.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.robolectric.shadows.ShadowLooper
ShadowLooper.Picker -
Constructor Summary
Constructors Constructor Description ShadowPausedLooper() -
Method Summary
Modifier and Type Method Description protected void__constructor__(boolean quitAllowed)DurationgetLastScheduledTaskTime()protected static Collection<Looper>getLoopers()DurationgetNextScheduledTaskTime()SchedulergetScheduler()Returns theSchedulerthat is being used to manage the enqueued tasks.booleanhasQuit()voididle()Executes all posted tasks scheduled before or at the current time.voididleConstantly(boolean shouldIdleConstantly)voididleFor(long time, TimeUnit timeUnit)Advances the system clock by the given time, then executes all posted tasks scheduled before or at the given time.voididleIfPaused()Helper method to selectively call idle() only if LooperMode is PAUSED.booleanisIdle()Returns true if there are no pending tasks scheduled to be executed before current time.booleanisPaused()voidpause()Pause the looper.booleanpost(Runnable runnable, long delayMillis)Enqueue a task to be run later.booleanpostAtFrontOfQueue(Runnable runnable)Enqueue a task to be run ahead of all other delayed tasks.protected static voidprepareMainLooper()protected voidquit()protected voidquitSafely()voidquitUnchecked()voidreset()Causes all enqueued tasks to be discarded, and pause state to be resetstatic voidresetLoopers()voidresetScheduler()Only supported forLooperMode.Mode.LEGACY.voidrunOneTask()Causes only one of the nextRunnables that have been scheduled to run while advancing the clock to its start time.voidrunPaused(Runnable runnable)Runs the current task with the looper paused.voidrunToEndOfTasks()voidrunToNextTask()Causes the nextRunnable(s) that have been scheduled to run while advancing the clock to its start time.booleansetPaused(boolean shouldPause)Control the paused state of the Looper.voidunPause()Not supported for the main Looper inLooperMode.Mode.PAUSED.Methods inherited from class org.robolectric.shadows.ShadowLooper
assertLooperMode, clearLooperMode, getAllLoopers, getLooperForThread, getShadowMainLooper, idle, idle, idleFor, idleMainLooper, idleMainLooper, idleMainLooper, idleMainLooperConstantly, looperMode, pauseLooper, pauseMainLooper, resetThreadLoopers, runMainLooperOneTask, runMainLooperToNextTask, runUiThreadTasks, runUiThreadTasksIncludingDelayedTasks, shadowMainLooper, unPauseLooper, unPauseMainLooper
-
Constructor Details
-
ShadowPausedLooper
public ShadowPausedLooper()
-
-
Method Details
-
__constructor__
-
getLoopers
-
quitUnchecked
public void quitUnchecked()- Specified by:
quitUncheckedin classShadowLooper
-
hasQuit
public boolean hasQuit()- Specified by:
hasQuitin classShadowLooper
-
idle
public void idle()Description copied from class:ShadowLooperExecutes all posted tasks scheduled before or at the current time.- Specified by:
idlein classShadowLooper
-
idleFor
Description copied from class:ShadowLooperAdvances the system clock by the given time, then executes all posted tasks scheduled before or at the given time.- Specified by:
idleForin classShadowLooper
-
isIdle
public boolean isIdle()Description copied from class:ShadowLooperReturns true if there are no pending tasks scheduled to be executed before current time.- Specified by:
isIdlein classShadowLooper
-
unPause
public void unPause()Description copied from class:ShadowLooperNot supported for the main Looper inLooperMode.Mode.PAUSED.- Specified by:
unPausein classShadowLooper
-
pause
public void pause()Description copied from class:ShadowLooperPause the looper.Has no practical effect for realistic looper, since it is always paused.
- Specified by:
pausein classShadowLooper
-
isPaused
public boolean isPaused()- Specified by:
isPausedin classShadowLooper
-
setPaused
public boolean setPaused(boolean shouldPause)Description copied from class:ShadowLooperControl the paused state of the Looper.Not supported for the main Looper in
LooperMode.Mode.PAUSED.- Specified by:
setPausedin classShadowLooper
-
resetScheduler
public void resetScheduler()Description copied from class:ShadowLooperOnly supported forLooperMode.Mode.LEGACY.- Specified by:
resetSchedulerin classShadowLooper
-
reset
public void reset()Description copied from class:ShadowLooperCauses all enqueued tasks to be discarded, and pause state to be reset- Specified by:
resetin classShadowLooper
-
idleIfPaused
public void idleIfPaused()Description copied from class:ShadowLooperHelper method to selectively call idle() only if LooperMode is PAUSED.Intended for backwards compatibility, to avoid changing behavior for tests still using LEGACY LooperMode.
- Specified by:
idleIfPausedin classShadowLooper
-
idleConstantly
public void idleConstantly(boolean shouldIdleConstantly)- Specified by:
idleConstantlyin classShadowLooper
-
runToEndOfTasks
public void runToEndOfTasks()Description copied from class:ShadowLooperCauses all of theRunnables that have been scheduled to run while advancing the clock to the start time of the last scheduledRunnable.- Specified by:
runToEndOfTasksin classShadowLooper
-
runToNextTask
public void runToNextTask()Description copied from class:ShadowLooperCauses the nextRunnable(s) that have been scheduled to run while advancing the clock to its start time. If more than oneRunnableis scheduled to run at this time then they will all be run.- Specified by:
runToNextTaskin classShadowLooper
-
runOneTask
public void runOneTask()Description copied from class:ShadowLooperCauses only one of the nextRunnables that have been scheduled to run while advancing the clock to its start time. Only oneRunnablewill run even if more than one has been scheduled to run at the same time.- Specified by:
runOneTaskin classShadowLooper
-
post
Description copied from class:ShadowLooperEnqueue a task to be run later.- Specified by:
postin classShadowLooper- Parameters:
runnable- the task to be rundelayMillis- how many milliseconds into the (virtual) future to run it- Returns:
- true if the runnable is enqueued
- See Also:
Handler.postDelayed(Runnable,long)
-
postAtFrontOfQueue
Description copied from class:ShadowLooperEnqueue a task to be run ahead of all other delayed tasks.- Specified by:
postAtFrontOfQueuein classShadowLooper- Parameters:
runnable- the task to be run- Returns:
- true if the runnable is enqueued
- See Also:
Handler.postAtFrontOfQueue(Runnable)
-
runPaused
Description copied from class:ShadowLooperRuns the current task with the looper paused.When LooperMode is PAUSED, this will execute all pending tasks scheduled before the current time.
- Specified by:
runPausedin classShadowLooper
-
getNextScheduledTaskTime
- Specified by:
getNextScheduledTaskTimein classShadowLooper- Returns:
- the scheduled time of the next posted task; Duration.ZERO if there is no currently scheduled task.
-
getLastScheduledTaskTime
- Specified by:
getLastScheduledTaskTimein classShadowLooper- Returns:
- the scheduled time of the last posted task; Duration.ZERO 0 if there is no currently scheduled task.
-
resetLoopers
-
prepareMainLooper
-
quit
-
quitSafely
-
getScheduler
Description copied from class:ShadowLooperReturns theSchedulerthat is being used to manage the enqueued tasks. This scheduler is managed by the Looper's associated queue.Only supported for
LooperMode.Mode.LEGACY.- Specified by:
getSchedulerin classShadowLooper- Returns:
- the
Schedulerthat is being used to manage the enqueued tasks.
-