# Conflicts: # app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/LoginActivity.java # app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/PersonalFragment.java
46 lines
1.1 KiB
Java
46 lines
1.1 KiB
Java
package com.android_app.matan.ara.sagi.thesocialnotework;
|
|
|
|
/**
|
|
* Created by aran on 5/26/16.
|
|
*/
|
|
|
|
import com.android.volley.toolbox.ImageLoader.ImageCache;
|
|
|
|
import android.graphics.Bitmap;
|
|
import android.support.v4.util.LruCache;
|
|
|
|
/**
|
|
* A class to extend the LruCache class - for better image caching
|
|
*/
|
|
public class LruBitmapCache extends LruCache<String, Bitmap> implements ImageCache {
|
|
public static int getDefaultLruCacheSize() {
|
|
final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
|
|
final int cacheSize = maxMemory / 8;
|
|
|
|
return cacheSize;
|
|
}
|
|
|
|
public LruBitmapCache() {
|
|
this(getDefaultLruCacheSize());
|
|
}
|
|
|
|
public LruBitmapCache(int sizeInKiloBytes) {
|
|
super(sizeInKiloBytes);
|
|
}
|
|
|
|
@Override
|
|
protected int sizeOf(String key, Bitmap value) {
|
|
return value.getRowBytes() * value.getHeight() / 1024;
|
|
}
|
|
|
|
@Override
|
|
public Bitmap getBitmap(String url) {
|
|
return get(url);
|
|
}
|
|
|
|
@Override
|
|
public void putBitmap(String url, Bitmap bitmap) {
|
|
put(url, bitmap);
|
|
}
|
|
}
|