public class MemoryCacheAdapter extends Object implements MemoryCache
MemoryCache.ResourceRemovedListener| Constructor and Description |
|---|
MemoryCacheAdapter() |
| Modifier and Type | Method and Description |
|---|---|
void |
clearMemory()
Evict all items from the memory cache.
|
int |
getCurrentSize()
Returns the sum of the sizes of all the contents of the cache in bytes.
|
int |
getMaxSize()
Returns the current maximum size in bytes of the cache.
|
Resource<?> |
put(Key key,
Resource<?> resource)
Add bitmap to the cache with the given key.
|
Resource<?> |
remove(Key key)
Removes the value for the given key and returns it if present or null otherwise.
|
void |
setResourceRemovedListener(MemoryCache.ResourceRemovedListener listener)
Set the listener to be called when a bitmap is removed from the cache.
|
void |
setSizeMultiplier(float multiplier)
Adjust the maximum size of the cache by multiplying the original size of the cache by the given
multiplier.
|
void |
trimMemory(int level)
Trim the memory cache to the appropriate level.
|
public int getCurrentSize()
MemoryCachegetCurrentSize in interface MemoryCachepublic int getMaxSize()
MemoryCachegetMaxSize in interface MemoryCachepublic void setSizeMultiplier(float multiplier)
MemoryCacheIf the size multiplier causes the size of the cache to be decreased, items will be evicted until the cache is smaller than the new size.
setSizeMultiplier in interface MemoryCachemultiplier - A size multiplier >= 0.public Resource<?> remove(Key key)
MemoryCacheremove in interface MemoryCachekey - The key.public Resource<?> put(Key key, Resource<?> resource)
MemoryCacheput in interface MemoryCachekey - The key to retrieve the bitmap.resource - The EngineResource to store.public void setResourceRemovedListener(MemoryCache.ResourceRemovedListener listener)
MemoryCachesetResourceRemovedListener in interface MemoryCachelistener - The listener.public void clearMemory()
MemoryCacheclearMemory in interface MemoryCachepublic void trimMemory(int level)
MemoryCachetrimMemory in interface MemoryCachelevel - This integer represents a trim level as specified in ComponentCallbacks2.