-
public class AnimatedFrameCacheFacade to the image memory cache for frames of an animated image.
Each animated image should have its own instance of this class.
-
-
Constructor Summary
Constructors Constructor Description AnimatedFrameCache(CacheKey imageCacheKey, CountingMemoryCache<CacheKey, CloseableImage> backingCache)
-
Method Summary
Modifier and Type Method Description synchronized voidonReusabilityChange(CacheKey key, boolean isReusable)CloseableReference<CloseableImage>cache(int frameIndex, CloseableReference<CloseableImage> imageRef)Caches the image for the given frame index. CloseableReference<CloseableImage>get(int frameIndex)Gets the image for the given frame index. booleancontains(int frameIndex)Check whether the cache contains an image for the given frame index. CloseableReference<CloseableImage>getForReuse()Gets the image to be reused, or null if there is no such image. -
-
Method Detail
-
onReusabilityChange
synchronized void onReusabilityChange(CacheKey key, boolean isReusable)
-
cache
@Nullable() 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 isthe caller's responsibility to close the returned reference once not needed anymore.
-
get
@Nullable() 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.
-
contains
boolean contains(int frameIndex)
Check whether the cache contains an image for the given frame index.
-
getForReuse
@Nullable() 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 withoutany restrictions.
-
-
-
-