|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.herroworld.imagegrabber.DiskLruCache
public class DiskLruCache
A simple disk LRU bitmap cache to illustrate how a disk cache would be used for bitmap caching. A much more robust and efficient disk LRU cache solution can be found in the ICS source code (libcore/luni/src/main/java/libcore/io/DiskLruCache.java) and is preferable to this simple implementation.
Method Summary | |
---|---|
void |
clearCache()
Removes all disk cache entries from this instance cache dir |
static void |
clearCache(Context context,
java.lang.String uniqueName)
Removes all disk cache entries from the application cache directory in the uniqueName sub-directory. |
boolean |
containsKey(java.lang.String key)
Checks if a specific key exist in the cache. |
static java.lang.String |
createFilePath(java.io.File cacheDir,
java.lang.String key)
Creates a constant cache file path given a target cache directory and an image key. |
java.lang.String |
createFilePath(java.lang.String key)
Create a constant cache file path using the current cache directory and an image key. |
Bitmap |
get(java.lang.String key)
Get an image from the disk cache. |
static java.io.File |
getDiskCacheDir(Context context,
java.lang.String uniqueName)
Get a usable cache directory (external if available, internal otherwise). |
static DiskLruCache |
openCache(Context context,
java.io.File cacheDir,
long maxByteSize)
Used to fetch an instance of DiskLruCache. |
void |
put(java.lang.String key,
Bitmap data)
Add a bitmap to the disk cache. |
void |
setCompressParams(CompressFormat compressFormat,
int quality)
Sets the target compression format and quality for images written to the disk cache. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static DiskLruCache openCache(Context context, java.io.File cacheDir, long maxByteSize)
context
- cacheDir
- maxByteSize
-
public void put(java.lang.String key, Bitmap data)
key
- A unique identifier for the bitmap.data
- The bitmap to store.public Bitmap get(java.lang.String key)
key
- The unique identifier for the bitmap
public boolean containsKey(java.lang.String key)
key
- The unique identifier for the bitmap
public void clearCache()
public static void clearCache(Context context, java.lang.String uniqueName)
context
- The context to useuniqueName
- A unique cache directory name to append to the app
cache directorypublic static java.io.File getDiskCacheDir(Context context, java.lang.String uniqueName)
context
- The context to useuniqueName
- A unique directory name to append to the cache dir
public static java.lang.String createFilePath(java.io.File cacheDir, java.lang.String key)
cacheDir
- key
-
public java.lang.String createFilePath(java.lang.String key)
key
-
public void setCompressParams(CompressFormat compressFormat, int quality)
compressFormat
- quality
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |