public class

AnimatedFrameCache

extends Object
java.lang.Object
   ↳ com.facebook.imagepipeline.animated.impl.AnimatedFrameCache

Class Overview

Facade to the image memory cache for frames of an animated image.

Each animated image should have its own instance of this class.

Summary

Public Constructors
AnimatedFrameCache(CacheKey imageCacheKey, CountingMemoryCache<CacheKeyCloseableImage> backingCache)
Public Methods
CloseableReference<CloseableImage> cache(int frameIndex, CloseableReference<CloseableImage> imageRef)
Caches the image for the given frame index.
boolean contains(int frameIndex)
Check whether the cache contains an image for the given frame index.
CloseableReference<CloseableImage> get(int frameIndex)
Gets the image for the given frame index.
CloseableReference<CloseableImage> getForReuse()
Gets the image to be reused, or null if there is no such image.
synchronized void onReusabilityChange(CacheKey key, boolean isReusable)
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public AnimatedFrameCache (CacheKey imageCacheKey, CountingMemoryCache<CacheKeyCloseableImage> backingCache)

Public Methods

public CloseableReference<CloseableImage> cache (int frameIndex, CloseableReference<CloseableImage> imageRef)

Caches the image for the given frame index.

Important: the client should use the returned reference instead of the original one. It is the caller's responsibility to close the returned reference once not needed anymore.

Returns
  • the new reference to be used, null if the value cannot be cached

public boolean contains (int frameIndex)

Check whether the cache contains an image for the given frame index.

public CloseableReference<CloseableImage> get (int frameIndex)

Gets the image for the given frame index.

It is the caller's responsibility to close the returned reference once not needed anymore.

public CloseableReference<CloseableImage> getForReuse ()

Gets the image to be reused, or null if there is no such image.

The returned image is the least recently used image that has no more clients referencing it, and it has not yet been evicted from the cache.

The client can freely modify the bitmap of the returned image and can cache it again without any restrictions.

public synchronized void onReusabilityChange (CacheKey key, boolean isReusable)