Ejemplo n.º 1
0
 public Bitmap getBitmap(String url) {
   if (diskLruCache.containsKey(url)) {
     return diskLruCache.getBitmap(url);
   } else {
     return null;
   }
 }
Ejemplo n.º 2
0
 @Override
 public void handleMessage(Message msg) {
   if (msg.obj != null) {
     if (!diskLruCache.containsKey(msg.obj.toString())) {
       diskLruCache.putBitmap(
           msg.obj.toString(), ImageCache.getInstance().get(msg.obj.toString()));
     }
   }
   super.handleMessage(msg);
 }
Ejemplo n.º 3
0
 public void load(
     ImageView imageView,
     String url,
     int defaultBackround,
     int width,
     int height,
     boolean isCache,
     final Drawable errorImage) {
   if (url == null || !url.contains("http://") && errorImage != null) {
     imageView.setImageDrawable(errorImage);
   } else {
     if (ImageCache.getInstance().get(url + width + "*" + height) != null) {
       imageView.setImageBitmap(ImageCache.getInstance().get(url + width + "*" + height));
     } else if (diskLruCache.containsKey(url + width + "*" + height)) {
       imageView.setImageBitmap(diskLruCache.getBitmap(url + width + "*" + height));
     } else {
       if (defaultBackround != 0) {
         imageView.setImageResource(defaultBackround);
       }
       final LoadRunnable run =
           new LoadRunnable(
               imageView, url, defaultBackround, errorImage, width, height, isCache, handler);
       executorServie.execute(run);
       // imageView.setOnClickListener(new OnClickListener() {
       // @Override
       // public void onClick(View v) {
       // ImageView imageView = (ImageView) v;
       // if (imageView.getDrawable() == null
       // || imageView.getDrawable() == errorImage) {
       // executorServie.execute(run);
       // }
       // }
       // });
     }
   }
 }
Ejemplo n.º 4
0
 public void clearDiskLruCache() {
   imageLoader = null;
   diskLruCache.clearCache();
 }