public class LooperDelegatingScheduler extends Scheduler
LooperMode.Mode.PAUSED
.
All API calls will delegate to ShadowLooper.
Scheduler.IdleState
Constructor | Description |
---|---|
LooperDelegatingScheduler(Looper looper) |
Modifier and Type | Method | Description |
---|---|---|
boolean |
advanceBy(long interval) |
Run all runnables that are scheduled to run in the next time interval.
|
boolean |
advanceBy(long amount,
TimeUnit unit) |
Run all runnables that are scheduled to run in the next time interval.
|
boolean |
advanceTo(long endTime) |
Run all runnables that are scheduled before the endTime.
|
boolean |
advanceToLastPostedRunnable() |
Run all runnables in the queue, and any additional runnables they schedule that are scheduled
before the latest scheduled runnable currently in the queue.
|
boolean |
advanceToNextPostedRunnable() |
Run the next runnable in the queue.
|
boolean |
areAnyRunnable() |
Determine if any enqueued runnables are enqueued before the current time.
|
long |
getCurrentTime() |
Get the current time (as seen by the scheduler), in milliseconds.
|
Scheduler.IdleState |
getIdleState() |
Retrieves the current idling state of this
Scheduler . |
Duration |
getLastScheduledTaskTime() |
|
Duration |
getNextScheduledTaskTime() |
|
void |
idleConstantly(boolean shouldIdleConstantly) |
Deprecated.
|
boolean |
isPaused() |
Determine if the scheduler is paused.
|
void |
pause() |
Pause the scheduler.
|
void |
post(Runnable runnable) |
Add a runnable to the queue.
|
void |
postAtFrontOfQueue(Runnable runnable) |
Add a runnable to the head of the queue.
|
void |
postDelayed(Runnable runnable,
long delayMillis) |
Add a runnable to the queue to be run after a delay.
|
void |
postDelayed(Runnable runnable,
long delay,
TimeUnit unit) |
Add a runnable to the queue to be run after a delay.
|
void |
remove(Runnable runnable) |
Remove a runnable from the queue.
|
void |
reset() |
Reset the internal state of the Scheduler.
|
boolean |
runOneTask() |
Run the next runnable in the queue.
|
void |
setIdleState(Scheduler.IdleState idleState) |
Sets the current idling state of this
Scheduler . |
int |
size() |
Return the number of enqueued runnables.
|
void |
unPause() |
Un-pause the scheduler.
|
public LooperDelegatingScheduler(Looper looper)
public Scheduler.IdleState getIdleState()
Scheduler
Scheduler
.getIdleState
in class Scheduler
Scheduler
.Scheduler.setIdleState(IdleState)
,
Scheduler.isPaused()
public void setIdleState(Scheduler.IdleState idleState)
Scheduler
Scheduler
. If transitioning to the Scheduler.IdleState.UNPAUSED
state any tasks scheduled to be run at or before the current time will be
run, and if transitioning to the Scheduler.IdleState.CONSTANT_IDLE
state all scheduled tasks will
be run and the clock advanced to the time of the last runnable.setIdleState
in class Scheduler
idleState
- The new idle state of this Scheduler
.Scheduler.setIdleState(IdleState)
,
Scheduler.isPaused()
public long getCurrentTime()
Scheduler
getCurrentTime
in class Scheduler
public void pause()
Scheduler
setIdleState(PAUSED)
.pause
in class Scheduler
Scheduler.unPause()
,
Scheduler.setIdleState(IdleState)
public void unPause()
Scheduler
setIdleState(UNPAUSED)
.unPause
in class Scheduler
Scheduler.pause()
,
Scheduler.setIdleState(IdleState)
public boolean isPaused()
Scheduler
public void post(Runnable runnable)
Scheduler
public void postDelayed(Runnable runnable, long delayMillis)
Scheduler
postDelayed
in class Scheduler
runnable
- Runnable to add.delayMillis
- Delay in millis.public void postDelayed(Runnable runnable, long delay, TimeUnit unit)
Scheduler
postDelayed
in class Scheduler
public void postAtFrontOfQueue(Runnable runnable)
Scheduler
postAtFrontOfQueue
in class Scheduler
runnable
- Runnable to add.public void remove(Runnable runnable)
Scheduler
public boolean advanceToLastPostedRunnable()
Scheduler
advanceToLastPostedRunnable
in class Scheduler
public boolean advanceToNextPostedRunnable()
Scheduler
advanceToNextPostedRunnable
in class Scheduler
public boolean advanceBy(long interval)
Scheduler
public boolean advanceBy(long amount, TimeUnit unit)
Scheduler
public boolean advanceTo(long endTime)
Scheduler
public boolean runOneTask()
Scheduler
runOneTask
in class Scheduler
public boolean areAnyRunnable()
Scheduler
areAnyRunnable
in class Scheduler
public void reset()
Scheduler
public int size()
Scheduler
public Duration getNextScheduledTaskTime()
getNextScheduledTaskTime
in class Scheduler
public Duration getLastScheduledTaskTime()
getLastScheduledTaskTime
in class Scheduler
@Deprecated public void idleConstantly(boolean shouldIdleConstantly)
Scheduler
idleConstantly
in class Scheduler
shouldIdleConstantly
- If true the idle state will be set to Scheduler.IdleState.CONSTANT_IDLE
, otherwise it will be set to Scheduler.IdleState.UNPAUSED
.