public class MemoryCacheAdapter extends Object implements MemoryCache
MemoryCache.ResourceRemovedListener
构造器和说明 |
---|
MemoryCacheAdapter() |
限定符和类型 | 方法和说明 |
---|---|
void |
clearMemory()
Evict all items from the memory cache.
|
long |
getCurrentSize()
Returns the sum of the sizes of all the contents of the cache in bytes.
|
long |
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 long getCurrentSize()
MemoryCache
getCurrentSize
在接口中 MemoryCache
public long getMaxSize()
MemoryCache
getMaxSize
在接口中 MemoryCache
public void setSizeMultiplier(float multiplier)
MemoryCache
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.
setSizeMultiplier
在接口中 MemoryCache
multiplier
- A size multiplier >= 0.@Nullable public Resource<?> remove(@NonNull Key key)
MemoryCache
remove
在接口中 MemoryCache
key
- The key.@Nullable public Resource<?> put(@NonNull Key key, @Nullable Resource<?> resource)
MemoryCache
put
在接口中 MemoryCache
key
- The key to retrieve the bitmap.resource
- The EngineResource
to store.public void setResourceRemovedListener(@NonNull MemoryCache.ResourceRemovedListener listener)
MemoryCache
setResourceRemovedListener
在接口中 MemoryCache
listener
- The listener.public void clearMemory()
MemoryCache
clearMemory
在接口中 MemoryCache
public void trimMemory(int level)
MemoryCache
trimMemory
在接口中 MemoryCache
level
- This integer represents a trim level as specified in ComponentCallbacks2
.