Class AnimatedImageDrawable

java.lang.Object
icyllis.modernui.graphics.drawable.Drawable
icyllis.modernui.graphics.drawable.AnimatedImageDrawable
All Implemented Interfaces:
Animatable, Animatable2

public class AnimatedImageDrawable extends Drawable implements Animatable2
Drawable for drawing animated images (like GIF).

The framework handles decoding subsequent frames in another thread and updating when necessary. The drawable will only animate while it is being displayed.

  • Constructor Details

    • AnimatedImageDrawable

      public AnimatedImageDrawable()
  • Method Details

    • getAnimatedImageExecutor

      @Internal public static Executor getAnimatedImageExecutor()
    • start

      public void start()
      Description copied from interface: Animatable
      Starts the drawable's animation.
      Specified by:
      start in interface Animatable
    • stop

      public void stop()
      Description copied from interface: Animatable
      Stops the drawable's animation.
      Specified by:
      stop in interface Animatable
    • isRunning

      public boolean isRunning()
      Description copied from interface: Animatable
      Indicates whether the animation is running.
      Specified by:
      isRunning in interface Animatable
      Returns:
      True if the animation is running, false otherwise.
    • registerAnimationCallback

      public void registerAnimationCallback(@NonNull Animatable2.AnimationCallback callback)
      Description copied from interface: Animatable2
      Adds a callback to listen to the animation events.
      Specified by:
      registerAnimationCallback in interface Animatable2
      Parameters:
      callback - Callback to add.
    • unregisterAnimationCallback

      public boolean unregisterAnimationCallback(@NonNull Animatable2.AnimationCallback callback)
      Description copied from interface: Animatable2
      Removes the specified animation callback.
      Specified by:
      unregisterAnimationCallback in interface Animatable2
      Parameters:
      callback - Callback to remove.
      Returns:
      false if callback didn't exist in the call back list, or true if callback has been removed successfully.
    • clearAnimationCallbacks

      public void clearAnimationCallbacks()
      Description copied from interface: Animatable2
      Removes all existing animation callbacks.
      Specified by:
      clearAnimationCallbacks in interface Animatable2
    • draw

      public void draw(@NonNull Canvas canvas)
      Description copied from class: Drawable
      Draw in its bounds (set via setBounds) respecting optional effects such as alpha (set via setAlpha).
      Specified by:
      draw in class Drawable
      Parameters:
      canvas - The canvas to draw into