Exemplo n.º 1
0
 public static void setBitmapToDiskLruCache(DiskLruCache diskLruCache, String key, Bitmap bitmap)
     throws IOException {
   DiskLruCache.Editor editor = diskLruCache.edit(key);
   OutputStream outputStream = editor.newOutputStream(0);
   bitmap.compress(Bitmap.CompressFormat.WEBP, 100, outputStream);
   outputStream.close();
   editor.commit();
   diskLruCache.flush();
 }
Exemplo n.º 2
0
 public static Bitmap getBitmapFromDiskLurCache(DiskLruCache diskLruCache, String key)
     throws IOException {
   DiskLruCache.Snapshot snapshot = diskLruCache.get(key);
   if (snapshot == null) return null;
   InputStream inputStream = snapshot.getInputStream(0);
   return BitmapFactory.decodeStream(inputStream);
 }