@Implements(value=android.os.Looper.class, isInAndroidSdk=false) public class ShadowLegacyLooper extends ShadowLooper
LooperMode.Mode.LEGACY
.
Robolectric enqueues posted Runnable
s to be run (on this thread) later.
Runnable
s that are scheduled to run immediately can be triggered by calling idle()
.
ShadowMessageQueue
ShadowLooper.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
Runnable s 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
Runnable s 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, wait
assertLooperMode, clearLooperMode, 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 ShadowLooper
public boolean hasQuit()
hasQuit
in class ShadowLooper
protected static Collection<Looper> getLoopers()
public void idle()
ShadowLooper
idle
in class ShadowLooper
public void idleFor(long time, TimeUnit timeUnit)
ShadowLooper
idleFor
in class ShadowLooper
public boolean isIdle()
ShadowLooper
isIdle
in class ShadowLooper
public void idleIfPaused()
ShadowLooper
Intended 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)
.Runnable
s that have been scheduled to run within the next intervalMillis
milliseconds to run while advancing the scheduler's clock.idle
in class ShadowLooper
public void idle(long amount, TimeUnit unit)
ShadowLooper
Runnable
s that have been scheduled to run within the next specified amount of
time to run while advancing the clock.idle
in class ShadowLooper
public void idleConstantly(boolean shouldIdleConstantly)
idleConstantly
in class ShadowLooper
public void runToEndOfTasks()
ShadowLooper
Runnable
s that have been scheduled to run while advancing the clock
to the start time of the last scheduled Runnable
.runToEndOfTasks
in class ShadowLooper
public void runToNextTask()
ShadowLooper
Runnable
(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 ShadowLooper
public void runOneTask()
ShadowLooper
Runnable
s 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 ShadowLooper
runnable
- 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 ShadowLooper
runnable
- the task to be runHandler.postAtFrontOfQueue(Runnable)
public void pause()
ShadowLooper
Has no practical effect for realistic looper, since it is always paused.
pause
in class ShadowLooper
public Duration getNextScheduledTaskTime()
getNextScheduledTaskTime
in class ShadowLooper
public Duration getLastScheduledTaskTime()
getLastScheduledTaskTime
in class ShadowLooper
public void unPause()
ShadowLooper
LooperMode.Mode.PAUSED
.unPause
in class ShadowLooper
public boolean isPaused()
isPaused
in class ShadowLooper
public boolean setPaused(boolean shouldPause)
ShadowLooper
Not supported for the main Looper in LooperMode.Mode.PAUSED
.
setPaused
in class ShadowLooper
public void resetScheduler()
ShadowLooper
LooperMode.Mode.LEGACY
.resetScheduler
in class ShadowLooper
public void reset()
reset
in class ShadowLooper
public 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 ShadowLooper
Scheduler
that is being used to manage the enqueued
tasks.public void runPaused(Runnable r)
ShadowLooper
When LooperMode is PAUSED, this will execute all pending tasks scheduled before the current time.
runPaused
in class ShadowLooper