Created
November 6, 2013 15:29
-
-
Save omarmiatello/7337982 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.neosperience.egea.utils.volleytoolbox; | |
import com.android.volley.toolbox.ImageLoader.ImageCache; | |
import android.graphics.Bitmap; | |
import android.support.v4.util.LruCache; | |
import android.util.Log; | |
/** | |
* Basic LRU Memory cache. | |
* | |
* @author Trey Robinson | |
* | |
*/ | |
public class BitmapLruImageCache extends LruCache<String, Bitmap> implements ImageCache{ | |
private final String TAG = BitmapLruImageCache.class.getSimpleName(); | |
public BitmapLruImageCache(int maxSize) { | |
super(maxSize); | |
} | |
@Override | |
protected int sizeOf(String key, Bitmap value) { | |
return value.getRowBytes() * value.getHeight(); | |
} | |
@Override | |
public Bitmap getBitmap(String url) { | |
Log.v(TAG, "Retrieved item from Mem Cache"); | |
return get(url); | |
} | |
@Override | |
public void putBitmap(String url, Bitmap bitmap) { | |
Log.v(TAG, "Added item to Mem Cache"); | |
put(url, bitmap); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment