public static class

ListUrlImageCache.Default

extends Object
implements ListUrlImageCache
java.lang.Object
   ↳ com.droidux.pack.list.cache.ListUrlImageCache.Default

Class Overview

Default implementation of the ListUrlImageCache. This cache implements 2-level mechanism (memory and disk backstore) to hold the images. The disk cache is using the Android cache directory to store the images.

Summary

Public Constructors
ListUrlImageCache.Default()
ListUrlImageCache.Default(Context context)
Public Methods
void clear()
Clear the cache.
void clearDiskCache()
Clears the disk cache.
void clearMemCache()
Clears the memory cache.
Bitmap get(String url)
Gets the bitmap for the specified url from the cache.
Bitmap getFast(String url)
For efficiency, if the requested Bitmap is available for quick fetch, for example from memory cache, it will be returned here.
void put(String url, Bitmap bitmap)
Store the bitmap for the specified url in the cache.
void setDiskCacheDirectory(File cacheDir)
Sets the cache directory.
void setDiskCacheLifetime(int lifetime)
Sets the lifetime of the disk cache.
void setMemCacheCapacity(int capacity)
Sets the maximum capacity of the memory cache.
void setMemCacheTtl(int ttl)
Sets the Time-to-live of the memory cache.
void setUseDiskCache(boolean use)
Sets whether to use the disk cache.
void setUseMemCache(boolean use)
Sets whether the memory cache be used.
boolean useDiskCache()
Check whether we are using the disk cache.
boolean useMemCache()
Check whether we are using the memory cache.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.droidux.pack.list.cache.ListUrlImageCache

Public Constructors

public ListUrlImageCache.Default ()

Since: API Level 2.5

public ListUrlImageCache.Default (Context context)

Since: API Level 2.5

Public Methods

public void clear ()

Since: API Level 2.5

Clear the cache.

public void clearDiskCache ()

Since: API Level 2.5

Clears the disk cache.

public void clearMemCache ()

Since: API Level 2.5

Clears the memory cache.

public Bitmap get (String url)

Since: API Level 2.5

Gets the bitmap for the specified url from the cache. Use getFast(String) first to see whether the image is readily available for quick fetch. The getFast(String) is called in the UI thread, whereas this function is called in the background thread.

Parameters
url The image url.
Returns
  • The requested image.

public Bitmap getFast (String url)

Since: API Level 2.5

For efficiency, if the requested Bitmap is available for quick fetch, for example from memory cache, it will be returned here. This function will be called in the UI thread. The get(String) function will be called in the background thread to allow for longer fetch, for example from 2nd level/disk cache.

Parameters
url The image url.
Returns
  • The requested image.

public void put (String url, Bitmap bitmap)

Since: API Level 2.5

Store the bitmap for the specified url in the cache.

Parameters
url The image url.
bitmap The web image.

public void setDiskCacheDirectory (File cacheDir)

Since: API Level 2.5

Sets the cache directory.

Parameters
cacheDir The cache directory. Default is set to the Android default cache directory.

public void setDiskCacheLifetime (int lifetime)

Since: API Level 2.5

Sets the lifetime of the disk cache.

Parameters
lifetime The lifetime in seconds. Default is 86400 seconds (24 hrs).

public void setMemCacheCapacity (int capacity)

Since: API Level 2.5

Sets the maximum capacity of the memory cache. If the cache is filled with more than the specified capacity, the eldest entry will be remove from the memory, and stored to disk (if the disk cache is enabled).

Parameters
capacity The maximum capacity. Default is 50.

public void setMemCacheTtl (int ttl)

Since: API Level 2.5

Sets the Time-to-live of the memory cache.

Parameters
ttl Time-to-live in seconds. Default is 180 seconds (3 minutes).

public void setUseDiskCache (boolean use)

Since: API Level 2.5

Sets whether to use the disk cache.

Parameters
use If true, the disk cache will be used. Default is true.

public void setUseMemCache (boolean use)

Since: API Level 2.5

Sets whether the memory cache be used.

Parameters
use If true, the memory cache will be used. Default is true.

public boolean useDiskCache ()

Since: API Level 2.5

Check whether we are using the disk cache.

Returns
  • If true, the disk cache is used. Default is true.

public boolean useMemCache ()

Since: API Level 2.5

Check whether we are using the memory cache.

Returns
  • If true, the memory cache is used. Default is true.