public <Z> Resource<Z> load(Key key, ResourceDecoder<File, Z> decoder, int width, int height) { File fromCache = diskCache.get(key); if (fromCache == null) { return null; } Resource<Z> result = null; try { result = decoder.decode(fromCache, width, height); } catch (IOException e) { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Exception decoding image from cache", e); } } if (result == null) { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Failed to decode image from cache or not present in cache"); } diskCache.delete(key); } return result; } }
private Resource<T> loadFromCache(Key key) throws IOException { File cacheFile = diskCacheProvider.getDiskCache().get(key); if (cacheFile == null) { return null; } Resource<T> result = null; try { result = loadProvider.getCacheDecoder().decode(cacheFile, width, height); } finally { if (result == null) { diskCacheProvider.getDiskCache().delete(key); } } return result; }