| | |
| | | */
|
| | | public class MemoryCacheUtils {
|
| | |
|
| | | // private HashMap<String, SoftReference<Bitmap>> mMemoryCache = new
|
| | | // HashMap<String, SoftReference<Bitmap>>();
|
| | | private LruCache<String, Bitmap> mMemoryCache;
|
| | |
|
| | | public MemoryCacheUtils() {
|
| | |
| | | * @param url
|
| | | */
|
| | | public Bitmap getBitmapFromMemory(String url) {
|
| | | // SoftReference<Bitmap> softReference = mMemoryCache.get(url);
|
| | | // if (softReference != null) {
|
| | | // Bitmap bitmap = softReference.get();
|
| | | // return bitmap;
|
| | | // }
|
| | | return mMemoryCache.get(url);
|
| | | }
|
| | |
|
| | |
| | | * @param bitmap
|
| | | */
|
| | | public void setBitmapToMemory(String url, Bitmap bitmap) {
|
| | | // SoftReference<Bitmap> softReference = new
|
| | | // SoftReference<Bitmap>(bitmap);
|
| | | // mMemoryCache.put(url, softReference);
|
| | | mMemoryCache.put(url, bitmap);
|
| | | }
|
| | | }
|