com.bumptech.glide.load.engine.cache
Class LruResourceCache

java.lang.Object
  extended by com.bumptech.glide.util.LruCache<Key,Resource<?>>
      extended by com.bumptech.glide.load.engine.cache.LruResourceCache
All Implemented Interfaces:
MemoryCache

public class LruResourceCache
extends LruCache<Key,Resource<?>>
implements MemoryCache

An LRU in memory cache for Resources.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.bumptech.glide.load.engine.cache.MemoryCache
MemoryCache.ResourceRemovedListener
 
Constructor Summary
LruResourceCache(int size)
          Constructor for LruResourceCache.
 
Method Summary
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.
 
Methods inherited from class com.bumptech.glide.util.LruCache
clearMemory, contains, get, getCurrentSize, getMaxSize, put, remove, setSizeMultiplier, trimToSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.bumptech.glide.load.engine.cache.MemoryCache
clearMemory, getCurrentSize, getMaxSize, put, remove, setSizeMultiplier
 

Constructor Detail

LruResourceCache

public LruResourceCache(int size)
Constructor for LruResourceCache.

Parameters:
size - The maximum size in bytes the in memory cache can use.
Method Detail

setResourceRemovedListener

public void setResourceRemovedListener(MemoryCache.ResourceRemovedListener listener)
Description copied from interface: MemoryCache
Set the listener to be called when a bitmap is removed from the cache.

Specified by:
setResourceRemovedListener in interface MemoryCache
Parameters:
listener - The listener.

onItemEvicted

protected void onItemEvicted(Key key,
                             Resource<?> item)
Description copied from class: LruCache
A callback called whenever an item is evicted from the cache. Subclasses can override.

Overrides:
onItemEvicted in class LruCache<Key,Resource<?>>
Parameters:
key - The key of the evicted item.
item - The evicted item.

getSize

protected int getSize(Resource<?> item)
Description copied from class: LruCache
Returns the size of a given item, defaulting to one. The units must match those used in the size passed in to the constructor. Subclasses can override this method to return sizes in various units, usually bytes.

Overrides:
getSize in class LruCache<Key,Resource<?>>
Parameters:
item - The item to get the size of.

trimMemory

public void trimMemory(int level)
Description copied from interface: MemoryCache
Trim the memory cache to the appropriate level. Typically called on the callback onTrimMemory.

Specified by:
trimMemory in interface MemoryCache
Parameters:
level - This integer represents a trim level as specified in ComponentCallbacks2.