com.nostra13.universalimageloader.cache.disc.impl
Class LimitedAgeDiscCache

java.lang.Object
  extended by com.nostra13.universalimageloader.cache.disc.impl.BaseDiscCache
      extended by com.nostra13.universalimageloader.cache.disc.impl.LimitedAgeDiscCache
All Implemented Interfaces:
DiscCacheAware, DiskCache

public class LimitedAgeDiscCache
extends BaseDiscCache

Cache which deletes files which were loaded more than defined time. Cache size is unlimited.

Since:
1.3.1
Author:
Sergey Tarasevich (nostra13[at]gmail[dot]com)

Field Summary
 
Fields inherited from class com.nostra13.universalimageloader.cache.disc.impl.BaseDiscCache
bufferSize, cacheDir, compressFormat, compressQuality, DEFAULT_BUFFER_SIZE, DEFAULT_COMPRESS_FORMAT, DEFAULT_COMPRESS_QUALITY, fileNameGenerator, reserveCacheDir
 
Constructor Summary
LimitedAgeDiscCache(File cacheDir, File reserveCacheDir, FileNameGenerator fileNameGenerator, long maxAge)
           
LimitedAgeDiscCache(File cacheDir, File reserveCacheDir, long maxAge)
           
LimitedAgeDiscCache(File cacheDir, long maxAge)
           
 
Method Summary
 void clear()
          Clears disk cache.
 File get(String imageUri)
          Returns file of cached image
 boolean remove(String imageUri)
          Removes image file associated with incoming URI
 boolean save(String imageUri, android.graphics.Bitmap bitmap)
          Saves image bitmap in disk cache.
 boolean save(String imageUri, InputStream imageStream, IoUtils.CopyListener listener)
          Saves image stream in disk cache.
 
Methods inherited from class com.nostra13.universalimageloader.cache.disc.impl.BaseDiscCache
close, getDirectory, getFile, setBufferSize, setCompressFormat, setCompressQuality
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LimitedAgeDiscCache

public LimitedAgeDiscCache(File cacheDir,
                           long maxAge)
Parameters:
cacheDir - Directory for file caching
maxAge - Max file age (in seconds). If file age will exceed this value then it'll be removed on next treatment (and therefore be reloaded).

LimitedAgeDiscCache

public LimitedAgeDiscCache(File cacheDir,
                           File reserveCacheDir,
                           long maxAge)
Parameters:
cacheDir - Directory for file caching
maxAge - Max file age (in seconds). If file age will exceed this value then it'll be removed on next treatment (and therefore be reloaded).

LimitedAgeDiscCache

public LimitedAgeDiscCache(File cacheDir,
                           File reserveCacheDir,
                           FileNameGenerator fileNameGenerator,
                           long maxAge)
Parameters:
cacheDir - Directory for file caching
reserveCacheDir - null-ok; Reserve directory for file caching. It's used when the primary directory isn't available.
fileNameGenerator - Name generator for cached files
maxAge - Max file age (in seconds). If file age will exceed this value then it'll be removed on next treatment (and therefore be reloaded).
Method Detail

get

public File get(String imageUri)
Description copied from interface: DiscCacheAware
Returns file of cached image

Specified by:
get in interface DiscCacheAware
Overrides:
get in class BaseDiscCache
Parameters:
imageUri - Original image URI
Returns:
File of cached image or null if image wasn't cached

save

public boolean save(String imageUri,
                    InputStream imageStream,
                    IoUtils.CopyListener listener)
             throws IOException
Description copied from interface: DiscCacheAware
Saves image stream in disk cache.

Specified by:
save in interface DiscCacheAware
Overrides:
save in class BaseDiscCache
Parameters:
imageUri - Original image URI
imageStream - Input stream of image
listener - Listener for saving progress, can be ignored if you don't use progress listener in ImageLoader calls
Returns:
true - if image was saved successfully; false - if image wasn't saved in disk cache.
Throws:
IOException

save

public boolean save(String imageUri,
                    android.graphics.Bitmap bitmap)
             throws IOException
Description copied from interface: DiscCacheAware
Saves image bitmap in disk cache.

Specified by:
save in interface DiscCacheAware
Overrides:
save in class BaseDiscCache
Parameters:
imageUri - Original image URI
bitmap - Image bitmap
Returns:
true - if bitmap was saved successfully; false - if bitmap wasn't saved in disk cache.
Throws:
IOException

remove

public boolean remove(String imageUri)
Description copied from interface: DiscCacheAware
Removes image file associated with incoming URI

Specified by:
remove in interface DiscCacheAware
Overrides:
remove in class BaseDiscCache
Parameters:
imageUri - Image URI
Returns:
true - if image file is deleted successfully; false - if image file doesn't exist for incoming URI or image file can't be deleted.

clear

public void clear()
Description copied from interface: DiscCacheAware
Clears disk cache.

Specified by:
clear in interface DiscCacheAware
Overrides:
clear in class BaseDiscCache


Copyright © 2011-2014. All Rights Reserved.