public class

AnimatedDrawable2

extends Drawable
implements Animatable DrawableWithCaches
java.lang.Object
   ↳ android.graphics.drawable.Drawable
     ↳ com.facebook.fresco.animation.drawable.AnimatedDrawable2

Class Overview

Experimental new animated drawable that uses a supplied AnimationBackend for drawing frames.

Summary

Public Constructors
AnimatedDrawable2()
AnimatedDrawable2(AnimationBackend animationBackend)
Public Methods
void draw(Canvas canvas)
void dropCaches()
Informs the Drawable to drop its caches.
AnimationBackend getAnimationBackend()
long getDroppedFrames()
int getFrameCount()
Get the number of frames for the animation.
int getIntrinsicHeight()
int getIntrinsicWidth()
int getLoopCount()
Get the loop count of the animation.
long getLoopDurationMs()
Get the animation duration for 1 loop by summing all frame durations.
int getOpacity()
long getStartTimeMs()
boolean isInfiniteAnimation()
boolean isRunning()
Check whether the animation is running.
void jumpToFrame(int targetFrameNumber)
Jump immediately to the given frame number.
void setAlpha(int alpha)
void setAnimationBackend(AnimationBackend animationBackend)
Update the animation backend to be used for the animation.
void setAnimationListener(AnimationListener animationListener)
Set an animation listener that is notified for various animation events.
void setColorFilter(ColorFilter colorFilter)
void start()
Start the animation.
void stop()
Stop the animation at the current frame.
Protected Methods
void onBoundsChange(Rect bounds)
boolean onLevelChange(int level)
Set the animation to the given level.
[Expand]
Inherited Methods
From class android.graphics.drawable.Drawable
From class java.lang.Object
From interface android.graphics.drawable.Animatable
From interface com.facebook.drawable.base.DrawableWithCaches

Public Constructors

public AnimatedDrawable2 ()

public AnimatedDrawable2 (AnimationBackend animationBackend)

Public Methods

public void draw (Canvas canvas)

public void dropCaches ()

Informs the Drawable to drop its caches.

public AnimationBackend getAnimationBackend ()

public long getDroppedFrames ()

public int getFrameCount ()

Get the number of frames for the animation. If no animation backend is set, 0 will be returned.

Returns
  • the number of frames of the animation

public int getIntrinsicHeight ()

public int getIntrinsicWidth ()

public int getLoopCount ()

Get the loop count of the animation. The returned value is either LOOP_COUNT_INFINITE if the animation is repeated infinitely or a positive integer that corresponds to the number of loops. If no animation backend is set, LOOP_COUNT_INFINITE will be returned.

Returns

public long getLoopDurationMs ()

Get the animation duration for 1 loop by summing all frame durations.

Returns
  • the duration of 1 animation loop in ms

public int getOpacity ()

public long getStartTimeMs ()

public boolean isInfiniteAnimation ()

public boolean isRunning ()

Check whether the animation is running.

Returns
  • true if the animation is currently running

public void jumpToFrame (int targetFrameNumber)

Jump immediately to the given frame number. The animation will not be paused if it is running. If the animation is not running, the animation will not be started.

Parameters
targetFrameNumber the frame number to jump to

public void setAlpha (int alpha)

public void setAnimationBackend (AnimationBackend animationBackend)

Update the animation backend to be used for the animation. This will also stop the animation. In order to remove the current animation backend, call this method with null.

Parameters
animationBackend the animation backend to be used or null

public void setAnimationListener (AnimationListener animationListener)

Set an animation listener that is notified for various animation events.

Parameters
animationListener the listener to use

public void setColorFilter (ColorFilter colorFilter)

public void start ()

Start the animation.

public void stop ()

Stop the animation at the current frame. It can be resumed by calling start() again.

Protected Methods

protected void onBoundsChange (Rect bounds)

protected boolean onLevelChange (int level)

Set the animation to the given level. The level represents the animation time in ms. If the animation time is greater than the last frame time for the last loop, the last frame will be displayed. If the animation is running (e.g. if start() has been called, the level change will be ignored. In this case, stop() the animation first.

Parameters
level the animation time in ms
Returns
  • true if the level change could be performed