Class LooperDelegatingScheduler

java.lang.Object
org.robolectric.util.Scheduler
org.robolectric.android.internal.LooperDelegatingScheduler

public class LooperDelegatingScheduler extends Scheduler
A foreground Scheduler implementation used for LooperMode.Mode.PAUSED.

All API calls will delegate to ShadowLooper.

  • Constructor Details

    • LooperDelegatingScheduler

      public LooperDelegatingScheduler(Looper looper)
  • Method Details

    • getIdleState

      public Scheduler.IdleState getIdleState()
      Description copied from class: Scheduler
      Retrieves the current idling state of this Scheduler.
      Overrides:
      getIdleState in class Scheduler
      Returns:
      The current idle state of this Scheduler.
      See Also:
    • setIdleState

      public void setIdleState(Scheduler.IdleState idleState)
      Description copied from class: Scheduler
      Sets the current idling state of this 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.
      Overrides:
      setIdleState in class Scheduler
      Parameters:
      idleState - The new idle state of this Scheduler.
      See Also:
    • getCurrentTime

      public long getCurrentTime()
      Description copied from class: Scheduler
      Get the current time (as seen by the scheduler), in milliseconds.
      Overrides:
      getCurrentTime in class Scheduler
      Returns:
      Current time in milliseconds.
    • pause

      public void pause()
      Description copied from class: Scheduler
      Pause the scheduler. Equivalent to setIdleState(PAUSED).
      Overrides:
      pause in class Scheduler
      See Also:
    • unPause

      public void unPause()
      Description copied from class: Scheduler
      Un-pause the scheduler. Equivalent to setIdleState(UNPAUSED).
      Overrides:
      unPause in class Scheduler
      See Also:
    • isPaused

      public boolean isPaused()
      Description copied from class: Scheduler
      Determine if the scheduler is paused.
      Overrides:
      isPaused in class Scheduler
      Returns:
      true if it is paused.
    • post

      public void post(Runnable runnable)
      Description copied from class: Scheduler
      Add a runnable to the queue.
      Overrides:
      post in class Scheduler
      Parameters:
      runnable - Runnable to add.
    • postDelayed

      public void postDelayed(Runnable runnable, long delayMillis)
      Description copied from class: Scheduler
      Add a runnable to the queue to be run after a delay.
      Overrides:
      postDelayed in class Scheduler
      Parameters:
      runnable - Runnable to add.
      delayMillis - Delay in millis.
    • postDelayed

      public void postDelayed(Runnable runnable, long delay, TimeUnit unit)
      Description copied from class: Scheduler
      Add a runnable to the queue to be run after a delay.
      Overrides:
      postDelayed in class Scheduler
    • postAtFrontOfQueue

      public void postAtFrontOfQueue(Runnable runnable)
      Description copied from class: Scheduler
      Add a runnable to the head of the queue.
      Overrides:
      postAtFrontOfQueue in class Scheduler
      Parameters:
      runnable - Runnable to add.
    • remove

      public void remove(Runnable runnable)
      Description copied from class: Scheduler
      Remove a runnable from the queue.
      Overrides:
      remove in class Scheduler
      Parameters:
      runnable - Runnable to remove.
    • advanceToLastPostedRunnable

      public boolean advanceToLastPostedRunnable()
      Description copied from class: Scheduler
      Run all runnables in the queue, and any additional runnables they schedule that are scheduled before the latest scheduled runnable currently in the queue.
      Overrides:
      advanceToLastPostedRunnable in class Scheduler
      Returns:
      True if a runnable was executed.
    • advanceToNextPostedRunnable

      public boolean advanceToNextPostedRunnable()
      Description copied from class: Scheduler
      Run the next runnable in the queue.
      Overrides:
      advanceToNextPostedRunnable in class Scheduler
      Returns:
      True if a runnable was executed.
    • advanceBy

      public boolean advanceBy(long amount, TimeUnit unit)
      Description copied from class: Scheduler
      Run all runnables that are scheduled to run in the next time interval.
      Overrides:
      advanceBy in class Scheduler
      Returns:
      True if a runnable was executed.
    • advanceTo

      public boolean advanceTo(long endTime)
      Description copied from class: Scheduler
      Run all runnables that are scheduled before the endTime.
      Overrides:
      advanceTo in class Scheduler
      Parameters:
      endTime - Future time.
      Returns:
      True if a runnable was executed.
    • runOneTask

      public boolean runOneTask()
      Description copied from class: Scheduler
      Run the next runnable in the queue.
      Overrides:
      runOneTask in class Scheduler
      Returns:
      True if a runnable was executed.
    • areAnyRunnable

      public boolean areAnyRunnable()
      Description copied from class: Scheduler
      Determine if any enqueued runnables are enqueued before the current time.
      Overrides:
      areAnyRunnable in class Scheduler
      Returns:
      True if any runnables can be executed.
    • reset

      public void reset()
      Description copied from class: Scheduler
      Reset the internal state of the Scheduler.
      Overrides:
      reset in class Scheduler
    • size

      public int size()
      Description copied from class: Scheduler
      Return the number of enqueued runnables.
      Overrides:
      size in class Scheduler
      Returns:
      Number of enqueues runnables.
    • getNextScheduledTaskTime

      public Duration getNextScheduledTaskTime()
      Overrides:
      getNextScheduledTaskTime in class Scheduler
    • getLastScheduledTaskTime

      public Duration getLastScheduledTaskTime()
      Overrides:
      getLastScheduledTaskTime in class Scheduler