public class

AnimatedDrawableCachingBackendImpl

extends DelegatingAnimatedDrawableBackend
implements AnimatedDrawableCachingBackend
java.lang.Object
   ↳ com.facebook.imagepipeline.animated.base.DelegatingAnimatedDrawableBackend
     ↳ com.facebook.imagepipeline.animated.impl.AnimatedDrawableCachingBackendImpl

Class Overview

A caching and prefetching layer that delegates to a AnimatedDrawableBackend.

Summary

Public Constructors
AnimatedDrawableCachingBackendImpl(SerialExecutorService executorService, ActivityManager activityManager, AnimatedDrawableUtil animatedDrawableUtil, MonotonicClock monotonicClock, AnimatedDrawableBackend animatedDrawableBackend, AnimatedDrawableOptions options)
Public Methods
void appendDebugOptionString(StringBuilder sb)
Appends a string about the state of the backend that might be useful for debugging.
synchronized void dropCaches()
Instructs the backend to drop its caches.
AnimatedDrawableCachingBackend forNewBounds(Rect bounds)
Creates a new AnimatedDrawableBackend with the same parameters but with a new bounds.
CloseableReference<Bitmap> getBitmapForFrame(int frameNumber)
Gets the bitmap for the specified frame number.
int getMemoryUsage()
Gets the number of bytes currently used by the backend for caching (for debugging)
CloseableReference<Bitmap> getPreviewBitmap()
Gets the bitmap for the preview frame.
void renderFrame(int frameNumber, Canvas canvas)
Renders the specified frame onto the canvas.
Protected Methods
synchronized void finalize()
[Expand]
Inherited Methods
From class com.facebook.imagepipeline.animated.base.DelegatingAnimatedDrawableBackend
From class java.lang.Object
From interface com.facebook.imagepipeline.animated.base.AnimatedDrawableBackend
From interface com.facebook.imagepipeline.animated.base.AnimatedDrawableCachingBackend

Public Constructors

public AnimatedDrawableCachingBackendImpl (SerialExecutorService executorService, ActivityManager activityManager, AnimatedDrawableUtil animatedDrawableUtil, MonotonicClock monotonicClock, AnimatedDrawableBackend animatedDrawableBackend, AnimatedDrawableOptions options)

Public Methods

public void appendDebugOptionString (StringBuilder sb)

Appends a string about the state of the backend that might be useful for debugging.

Parameters
sb the builder to append to

public synchronized void dropCaches ()

Instructs the backend to drop its caches.

public AnimatedDrawableCachingBackend forNewBounds (Rect bounds)

Creates a new AnimatedDrawableBackend with the same parameters but with a new bounds.

Parameters
bounds the bounds
Returns
  • an AnimatedDrawableBackend with the new bounds (this may be the same instance if the bounds don't require a new backend)

public CloseableReference<Bitmap> getBitmapForFrame (int frameNumber)

Gets the bitmap for the specified frame number. The bitmap should be the size of the rendered image according to getRenderedWidth() and getRenderedHeight() and ready to be drawn in the Drawable's draw method.

Parameters
frameNumber the frame number (0-based)
Returns
  • a reference to the bitmap which must be released by the caller when done or null to indicate to the caller that the bitmap is not ready and it should try again later

public int getMemoryUsage ()

Gets the number of bytes currently used by the backend for caching (for debugging)

Returns
  • the number of bytes currently used by the backend for caching

public CloseableReference<Bitmap> getPreviewBitmap ()

Gets the bitmap for the preview frame. This will only return non-null if the ImageDecodeOptions were configured to decode the preview frame.

Returns
  • a reference to the preview bitmap which must be released by the caller when done or null if there is no preview bitmap set

public void renderFrame (int frameNumber, Canvas canvas)

Renders the specified frame onto the canvas.

Parameters
frameNumber the frame number (0-based)
canvas the canvas to render onto

Protected Methods

protected synchronized void finalize ()

Throws
Throwable