com.github.ignition.support.cache
Class ImageCache
java.lang.Object
com.github.ignition.support.cache.AbstractCache<String,byte[]>
com.github.ignition.support.cache.ImageCache
- All Implemented Interfaces:
- Map<String,byte[]>
public class ImageCache
- extends AbstractCache<String,byte[]>
Implements a cache capable of caching image files. It exposes helper methods to immediately
access binary image data as Bitmap
objects.
- Author:
- Matthias Kaeppler
Nested classes/interfaces inherited from interface java.util.Map |
Map.Entry<K,V> |
Constructor Summary |
ImageCache(int initialCapacity,
long expirationInMinutes,
int maxConcurrentThreads)
|
Methods inherited from class com.github.ignition.support.cache.AbstractCache |
clear, clear, containsKey, containsKeyInMemory, containsKeyOnDisk, containsValue, enableDiskCache, entrySet, get, getCachedFiles, getDiskCacheDirectory, isDiskCacheEnabled, isEmpty, keySet, put, putAll, remove, removeKey, setDiskCacheEnabled, size, values |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ImageCache
public ImageCache(int initialCapacity,
long expirationInMinutes,
int maxConcurrentThreads)
removeAllWithPrefix
public void removeAllWithPrefix(String urlPrefix)
getFileNameForKey
public String getFileNameForKey(String imageUrl)
- Description copied from class:
AbstractCache
- Only meaningful if disk caching is enabled. See
AbstractCache.enableDiskCache(android.content.Context, int)
. Turns a cache key
into the file name that will be used to persist the value to disk. Subclasses must implement
this.
- Specified by:
getFileNameForKey
in class AbstractCache<String,byte[]>
- Parameters:
imageUrl
- the cache key
- Returns:
- the file name
readValueFromDisk
protected byte[] readValueFromDisk(File file)
throws IOException
- Description copied from class:
AbstractCache
- Only meaningful if disk caching is enabled. See
AbstractCache.enableDiskCache(android.content.Context, int)
. Restores a value
previously persisted to the disk cache.
- Specified by:
readValueFromDisk
in class AbstractCache<String,byte[]>
- Parameters:
file
- the file holding the cached value
- Returns:
- the cached value
- Throws:
IOException
getBitmap
public android.graphics.Bitmap getBitmap(Object elementKey)
writeValueToDisk
protected void writeValueToDisk(File file,
byte[] imageData)
throws IOException
- Description copied from class:
AbstractCache
- Only meaningful if disk caching is enabled. See
AbstractCache.enableDiskCache(android.content.Context, int)
. Persists a value to
the disk cache.
- Specified by:
writeValueToDisk
in class AbstractCache<String,byte[]>
imageData
- the cache value to persist
- Throws:
IOException
Copyright © 2012. All Rights Reserved.