@Implements(value=android.os.Looper.class, isInAndroidSdk=false) public class ShadowLegacyLooper extends ShadowLooper
LooperMode.Mode.LEGACY.
Robolectric enqueues posted Runnables to be run (on this thread) later.
Runnables that are scheduled to run immediately can be triggered by calling idle().
ShadowMessageQueueShadowLooper.Picker| Constructor | Description |
|---|---|
ShadowLegacyLooper() |
| Modifier and Type | Method | Description |
|---|---|---|
protected void |
__constructor__(boolean quitAllowed) |
|
Duration |
getLastScheduledTaskTime() |
|
static Looper |
getLooperForThread(Thread thread) |
|
protected static Collection<Looper> |
getLoopers() |
Return loopers for all threads including main thread.
|
protected static Looper |
getMainLooper() |
|
Duration |
getNextScheduledTaskTime() |
|
Scheduler |
getScheduler() |
Returns the
Scheduler that is being used to manage the enqueued
tasks. |
boolean |
hasQuit() |
|
void |
idle() |
Executes all posted tasks scheduled before or at the current time.
|
void |
idle(long intervalMillis) |
Deprecated.
Use
idle(long, TimeUnit). |
void |
idle(long amount,
TimeUnit unit) |
Causes
Runnables that have been scheduled to run within the next specified amount of
time to run while advancing the clock. |
void |
idleConstantly(boolean shouldIdleConstantly) |
|
void |
idleFor(long time,
TimeUnit timeUnit) |
Advances the system clock by the given time, then executes all posted tasks scheduled before or
at the given time.
|
void |
idleIfPaused() |
Helper method to selectively call idle() only if LooperMode is PAUSED.
|
boolean |
isIdle() |
Returns true if there are no pending tasks scheduled to be executed before current time.
|
boolean |
isPaused() |
|
protected static void |
loop() |
|
protected static Looper |
myLooper() |
|
void |
pause() |
Pause the looper.
|
boolean |
post(Runnable runnable,
long delayMillis) |
Deprecated.
Use a
Handler instance to post to a looper. |
boolean |
postAtFrontOfQueue(Runnable runnable) |
Deprecated.
Use a
Handler instance to post to a looper. |
protected void |
quit() |
|
protected void |
quitSafely() |
|
void |
quitUnchecked() |
|
void |
reset() |
Causes all enqueued tasks to be discarded, and pause state to be reset
|
void |
resetScheduler() |
Only supported for
LooperMode.Mode.LEGACY. |
static void |
resetThreadLoopers() |
|
void |
runOneTask() |
Causes only one of the next
Runnables that have been scheduled to run while advancing
the clock to its start time. |
void |
runPaused(Runnable r) |
Runs the current task with the looper paused.
|
void |
runToEndOfTasks() |
|
void |
runToNextTask() |
Causes the next
Runnable(s) that have been scheduled to run while advancing the clock
to its start time. |
boolean |
setPaused(boolean shouldPause) |
Control the paused state of the Looper.
|
void |
unPause() |
Not supported for the main Looper in
LooperMode.Mode.PAUSED. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitassertLooperMode, getAllLoopers, getShadowMainLooper, idleFor, idleMainLooper, idleMainLooper, idleMainLooper, idleMainLooperConstantly, looperMode, pauseLooper, pauseMainLooper, runMainLooperOneTask, runMainLooperToNextTask, runUiThreadTasks, runUiThreadTasksIncludingDelayedTasks, shadowMainLooper, unPauseLooper, unPauseMainLooper@Resetter public static void resetThreadLoopers()
@Implementation protected void __constructor__(boolean quitAllowed)
@Implementation protected static Looper getMainLooper()
@Implementation protected static Looper myLooper()
@Implementation protected static void loop()
@Implementation protected void quit()
@Implementation(minSdk=18) protected void quitSafely()
public void quitUnchecked()
quitUnchecked in class ShadowLooperpublic boolean hasQuit()
hasQuit in class ShadowLooperprotected static Collection<Looper> getLoopers()
public void idle()
ShadowLooperidle in class ShadowLooperpublic void idleFor(long time,
TimeUnit timeUnit)
ShadowLooperidleFor in class ShadowLooperpublic boolean isIdle()
ShadowLooperisIdle in class ShadowLooperpublic void idleIfPaused()
ShadowLooperIntended for backwards compatibility, to avoid changing behavior for tests still using LEGACY LooperMode.
idleIfPaused in class ShadowLooper@Deprecated public void idle(long intervalMillis)
idle(long, TimeUnit).Runnables that have been scheduled to run within the next intervalMillis
milliseconds to run while advancing the scheduler's clock.idle in class ShadowLooperpublic void idle(long amount,
TimeUnit unit)
ShadowLooperRunnables that have been scheduled to run within the next specified amount of
time to run while advancing the clock.idle in class ShadowLooperpublic void idleConstantly(boolean shouldIdleConstantly)
idleConstantly in class ShadowLooperpublic void runToEndOfTasks()
ShadowLooperRunnables that have been scheduled to run while advancing the clock
to the start time of the last scheduled Runnable.runToEndOfTasks in class ShadowLooperpublic void runToNextTask()
ShadowLooperRunnable(s) that have been scheduled to run while advancing the clock
to its start time. If more than one Runnable is scheduled to run at this time then they
will all be run.runToNextTask in class ShadowLooperpublic void runOneTask()
ShadowLooperRunnables that have been scheduled to run while advancing
the clock to its start time. Only one Runnable will run even if more than one has been
scheduled to run at the same time.runOneTask in class ShadowLooper@Deprecated public boolean post(Runnable runnable, long delayMillis)
Handler instance to post to a looper.post in class ShadowLooperrunnable - the task to be rundelayMillis - how many milliseconds into the (virtual) future to run itHandler.postDelayed(Runnable,long)@Deprecated public boolean postAtFrontOfQueue(Runnable runnable)
Handler instance to post to a looper.postAtFrontOfQueue in class ShadowLooperrunnable - the task to be runHandler.postAtFrontOfQueue(Runnable)public void pause()
ShadowLooperHas no practical effect for realistic looper, since it is always paused.
pause in class ShadowLooperpublic Duration getNextScheduledTaskTime()
getNextScheduledTaskTime in class ShadowLooperpublic Duration getLastScheduledTaskTime()
getLastScheduledTaskTime in class ShadowLooperpublic void unPause()
ShadowLooperLooperMode.Mode.PAUSED.unPause in class ShadowLooperpublic boolean isPaused()
isPaused in class ShadowLooperpublic boolean setPaused(boolean shouldPause)
ShadowLooperNot supported for the main Looper in LooperMode.Mode.PAUSED.
setPaused in class ShadowLooperpublic void resetScheduler()
ShadowLooperLooperMode.Mode.LEGACY.resetScheduler in class ShadowLooperpublic void reset()
reset in class ShadowLooperpublic Scheduler getScheduler()
Scheduler that is being used to manage the enqueued
tasks. This scheduler is managed by the Looper's associated queue.getScheduler in class ShadowLooperScheduler that is being used to manage the enqueued
tasks.public void runPaused(Runnable r)
ShadowLooperWhen LooperMode is PAUSED, this will execute all pending tasks scheduled before the current time.
runPaused in class ShadowLooper