public class LruResourceCache extends LruCache<Key,Resource<?>> implements MemoryCache
Resources.MemoryCache.ResourceRemovedListener| Constructor and Description |
|---|
LruResourceCache(int size)
Constructor for LruResourceCache.
|
| Modifier and Type | Method and Description |
|---|---|
protected int |
getSize(Resource<?> item)
Returns the size of a given item, defaulting to one.
|
protected void |
onItemEvicted(Key key,
Resource<?> item)
A callback called whenever an item is evicted from the cache.
|
void |
setResourceRemovedListener(MemoryCache.ResourceRemovedListener listener)
Set the listener to be called when a bitmap is removed from the cache.
|
void |
trimMemory(int level)
Trim the memory cache to the appropriate level.
|
clearMemory, contains, get, getCurrentSize, getMaxSize, put, remove, setSizeMultiplier, trimToSizeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclearMemory, getCurrentSize, getMaxSize, put, remove, setSizeMultiplierpublic LruResourceCache(int size)
size - The maximum size in bytes the in memory cache can use.public void setResourceRemovedListener(MemoryCache.ResourceRemovedListener listener)
MemoryCachesetResourceRemovedListener in interface MemoryCachelistener - The listener.protected void onItemEvicted(Key key, Resource<?> item)
LruCacheonItemEvicted in class LruCache<Key,Resource<?>>key - The key of the evicted item.item - The evicted item.protected int getSize(Resource<?> item)
LruCachepublic void trimMemory(int level)
MemoryCachetrimMemory in interface MemoryCachelevel - This integer represents a trim level as specified in ComponentCallbacks2.