Class ShadowChoreographer

java.lang.Object
org.robolectric.shadows.ShadowChoreographer
Direct Known Subclasses:
ShadowLegacyChoreographer, ShadowPausedChoreographer

@Implements(value=android.view.Choreographer.class, shadowPicker=Picker.class) public abstract class ShadowChoreographer extends Object
The shadow API for Choreographer.

Different shadow implementations will be used depending on the current LooperMode. See ShadowLegacyChoreographer and ShadowPausedChoreographer for details.

  • Constructor Details

    • ShadowChoreographer

      public ShadowChoreographer()
  • Method Details

    • setFrameDelay

      public static void setFrameDelay(Duration delay)
      Sets the delay between each frame. Note that the frames use the ShadowSystemClock and so have the same fidelity, when using the paused looper mode (which is the only mode supported by ShadowDisplayEventReceiver) the clock has millisecond fidelity.

      Reasonable delays may be 15ms (approximating 60fps ~16.6ms), 10ms (approximating 90fps ~11.1ms), and 30ms (approximating 30fps ~33.3ms). Choosing too small of a frame delay may increase runtime as animation frames will have more steps.

      Only works in LooperMode.Mode.PAUSED looper mode.

    • getFrameDelay

      public static Duration getFrameDelay()
    • setPaused

      public static void setPaused(boolean paused)
      Sets whether posting a frame should auto advance the clock or not. When paused the clock is not auto advanced, when unpaused the clock is advanced by the frame delay every time a frame callback is added. The default is not paused.

      Only works in LooperMode.Mode.PAUSED looper mode.

    • isPaused

      public static boolean isPaused()
    • setPostCallbackDelay

      @Deprecated public static void setPostCallbackDelay(int delayMillis)
      Deprecated.
      Use the LooperMode.Mode.PAUSED looper instead.
      Allows application to specify a fixed amount of delay when #postCallback(int, Runnable, Object) is invoked. The default delay value is 0. This can be used to avoid infinite animation tasks to be spawned when the Robolectric Scheduler is in Scheduler.IdleState.PAUSED mode.

      Only supported in LooperMode.Mode.LEGACY

    • setPostFrameCallbackDelay

      @Deprecated public static void setPostFrameCallbackDelay(int delayMillis)
      Deprecated.
      Use the LooperMode.Mode.PAUSED looper and setPaused(boolean) and setFrameDelay(Duration) to configure the vsync event behavior.
      Allows application to specify a fixed amount of delay when #postFrameCallback(FrameCallback) is invoked. The default delay value is 0. This can be used to avoid infinite animation tasks to be spawned when in LooperMode PAUSED or Scheduler.IdleState.PAUSED and displaying an animation.
    • getFrameInterval

      @Deprecated public static long getFrameInterval()
      Deprecated.
      Use the LooperMode.Mode.PAUSED looper and getFrameDelay() to configure the frame delay.
      Return the current inter-frame interval.

      Can only be used in LooperMode.Mode.LEGACY

      Returns:
      Inter-frame interval.
    • setFrameInterval

      @Deprecated public static void setFrameInterval(long frameInterval)
      Deprecated.
      Use the LooperMode.Mode.PAUSED looper and setFrameDelay(Duration) to configure the frame delay.
      Set the inter-frame interval used to advance the clock. By default, this is set to 1ms.

      Only supported in LooperMode.Mode.LEGACY

      Parameters:
      frameInterval - Inter-frame interval.
    • doFrame

      @Implementation(maxSdk=30) protected void doFrame(long frameTimeNanos, int frame)
    • reset

      @Resetter public static void reset()