Skip to content

Instantly share code, notes, and snippets.

@pwittchen
Last active December 21, 2015 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pwittchen/6347865 to your computer and use it in GitHub Desktop.
Save pwittchen/6347865 to your computer and use it in GitHub Desktop.
package com.github.volley.example.toolbox;
import com.android.volley.toolbox.ImageLoader.ImageCache;
import android.graphics.Bitmap;
import android.support.v4.util.LruCache;
public class BitmapLruCache extends LruCache<String, Bitmap> implements ImageCache {
public BitmapLruCache(int maxSize) {
super(maxSize);
}
// Fix thanks to Steven's comment: sizeOf method should not be overriden,
// when we are passing max image cache entries in another place of the code
// @Override
// protected int sizeOf(String key, Bitmap value) {
// return value.getRowBytes() * value.getHeight();
// }
@Override
public Bitmap getBitmap(String url) {
return get(url);
}
@Override
public void putBitmap(String url, Bitmap bitmap) {
put(url, bitmap);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment