Esempio n. 1
0
 private FilterInputStream getFromCache(String url) throws Exception {
   DiskLruCache cache = DiskLruCache.open(CommonUtil.getImageSavePath(), 1, 2, 2 * 1024 * 1024);
   cache.flush();
   String key = Util.hash(url);
   final DiskLruCache.Snapshot snapshot;
   try {
     snapshot = cache.get(key);
     if (snapshot == null) {
       return null;
     }
   } catch (IOException e) {
     return null;
   }
   FilterInputStream bodyIn =
       new FilterInputStream(snapshot.getInputStream(1)) {
         @Override
         public void close() throws IOException {
           snapshot.close();
           super.close();
         }
       };
   return bodyIn;
 }