Search in sources :

Example 11 with FileCache

use of com.koushikdutta.async.util.FileCache in project ion by koush.

the class IonBitmapRequestBuilder method isLocallyCached.

@Override
public LocallyCachedStatus isLocallyCached() {
    if (builder.noCache || deepZoom)
        return LocallyCachedStatus.NOT_CACHED;
    final String decodeKey = computeDecodeKey();
    addDefaultTransform();
    String bitmapKey = computeBitmapKey(decodeKey);
    BitmapInfo info = builder.ion.bitmapCache.get(bitmapKey);
    // memory cache
    if (info != null && info.exception == null)
        return LocallyCachedStatus.CACHED;
    FileCache fileCache = ion.responseCache.getFileCache();
    if (hasTransforms() && fileCache.exists(bitmapKey))
        return LocallyCachedStatus.CACHED;
    if (fileCache.exists(decodeKey))
        return LocallyCachedStatus.MAYBE_CACHED;
    return LocallyCachedStatus.NOT_CACHED;
}
Also used : BitmapInfo(com.koushikdutta.ion.bitmap.BitmapInfo) FileCache(com.koushikdutta.async.util.FileCache)

Aggregations

FileCache (com.koushikdutta.async.util.FileCache)11 File (java.io.File)9 IOException (java.io.IOException)3 FileInputStream (java.io.FileInputStream)2 Bitmap (android.graphics.Bitmap)1 AsyncHttpClientMiddleware (com.koushikdutta.async.http.AsyncHttpClientMiddleware)1 ByteBufferListParser (com.koushikdutta.async.parser.ByteBufferListParser)1 BitmapInfo (com.koushikdutta.ion.bitmap.BitmapInfo)1 MediaFile (com.koushikdutta.ion.loader.MediaFile)1 FileOutputStream (java.io.FileOutputStream)1 CancellationException (java.util.concurrent.CancellationException)1