public Bitmap getBitmap(String key) { if (key == null) { return null; } Bitmap bitmap = getBitmapFromMemCache(key); if (bitmap != null) { return bitmap; } DiskLruCache.Snapshot snapshot = null; try { snapshot = _diskCache.get(key); if (snapshot == null) { return null; } final InputStream in = snapshot.getInputStream(0); if (in != null) { final BufferedInputStream buffIn = new BufferedInputStream(in, Utilities.IO_BUFFER_SIZE); bitmap = BitmapFactory.decodeStream(buffIn); } } catch (IOException e) { e.printStackTrace(); } finally { if (snapshot != null) { snapshot.close(); } } return bitmap; }
public boolean containsKey(String key) { if (key == null) { return false; } boolean contained = false; DiskLruCache.Snapshot snapshot = null; try { snapshot = _diskCache.get(key); contained = snapshot != null; } catch (IOException e) { e.printStackTrace(); } finally { if (snapshot != null) { snapshot.close(); } } return contained; }