Class MemoryCacheAdapter
- java.lang.Object
-
- com.bumptech.glide.load.engine.cache.MemoryCacheAdapter
-
- All Implemented Interfaces:
MemoryCache
public class MemoryCacheAdapter extends java.lang.Object implements MemoryCache
A simple class that ignores all puts and returns null for all gets.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.bumptech.glide.load.engine.cache.MemoryCache
MemoryCache.ResourceRemovedListener
-
-
Constructor Summary
Constructors Constructor Description MemoryCacheAdapter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearMemory()Evict all items from the memory cache.longgetCurrentSize()Returns the sum of the sizes of all the contents of the cache in bytes.longgetMaxSize()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.voidsetResourceRemovedListener(MemoryCache.ResourceRemovedListener listener)Set the listener to be called when a bitmap is removed from the cache.voidsetSizeMultiplier(float multiplier)Adjust the maximum size of the cache by multiplying the original size of the cache by the given multiplier.voidtrimMemory(int level)Trim the memory cache to the appropriate level.
-
-
-
Method Detail
-
getCurrentSize
public long getCurrentSize()
Description copied from interface:MemoryCacheReturns the sum of the sizes of all the contents of the cache in bytes.- Specified by:
getCurrentSizein interfaceMemoryCache
-
getMaxSize
public long getMaxSize()
Description copied from interface:MemoryCacheReturns the current maximum size in bytes of the cache.- Specified by:
getMaxSizein interfaceMemoryCache
-
setSizeMultiplier
public void setSizeMultiplier(float multiplier)
Description copied from interface:MemoryCacheAdjust the maximum size of the cache by multiplying the original size of the cache by the given multiplier.If 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.
- Specified by:
setSizeMultiplierin interfaceMemoryCache- Parameters:
multiplier- A size multiplier>= 0.
-
remove
@Nullable public Resource<?> remove(@NonNull Key key)
Description copied from interface:MemoryCacheRemoves the value for the given key and returns it if present or null otherwise.- Specified by:
removein interfaceMemoryCache- Parameters:
key- The key.
-
put
@Nullable public Resource<?> put(@NonNull Key key, @Nullable Resource<?> resource)
Description copied from interface:MemoryCacheAdd bitmap to the cache with the given key.- Specified by:
putin interfaceMemoryCache- Parameters:
key- The key to retrieve the bitmap.resource- TheEngineResourceto store.- Returns:
- The old value of key (null if key is not in map).
-
setResourceRemovedListener
public void setResourceRemovedListener(@NonNull MemoryCache.ResourceRemovedListener listener)Description copied from interface:MemoryCacheSet the listener to be called when a bitmap is removed from the cache.- Specified by:
setResourceRemovedListenerin interfaceMemoryCache- Parameters:
listener- The listener.
-
clearMemory
public void clearMemory()
Description copied from interface:MemoryCacheEvict all items from the memory cache.- Specified by:
clearMemoryin interfaceMemoryCache
-
trimMemory
public void trimMemory(int level)
Description copied from interface:MemoryCacheTrim the memory cache to the appropriate level. Typically called on the callback onTrimMemory.- Specified by:
trimMemoryin interfaceMemoryCache- Parameters:
level- This integer represents a trim level as specified inComponentCallbacks2.
-
-