Set the volley lru cache size to 1/8 of the available memory

filtering
Floens 10 years ago
parent 3b250b82b6
commit fec551bc55
  1. 11
      Clover/app/src/main/java/org/floens/chan/Chan.java
  2. 2
      Clover/app/src/main/java/org/floens/chan/core/net/BitmapLruImageCache.java

@ -30,12 +30,12 @@ import com.squareup.leakcanary.RefWatcher;
import org.floens.chan.chan.ChanUrls;
import org.floens.chan.core.cache.FileCache;
import org.floens.chan.core.database.DatabaseManager;
import org.floens.chan.core.http.ReplyManager;
import org.floens.chan.core.manager.BoardManager;
import org.floens.chan.core.manager.WatchManager;
import org.floens.chan.core.net.BitmapLruImageCache;
import org.floens.chan.core.http.ReplyManager;
import org.floens.chan.core.settings.ChanSettings;
import org.floens.chan.core.database.DatabaseManager;
import org.floens.chan.utils.AndroidUtils;
import org.floens.chan.utils.Logger;
@ -50,7 +50,6 @@ public class Chan extends Application {
private static final long FILE_CACHE_DISK_SIZE = 50 * 1024 * 1024;
private static final String FILE_CACHE_NAME = "filecache";
private static final int VOLLEY_LRU_CACHE_SIZE = 8 * 1024 * 1024;
private static final int VOLLEY_CACHE_SIZE = 10 * 1024 * 1024;
public static Context con;
@ -152,7 +151,11 @@ public class Chan extends Application {
replyManager = new ReplyManager(this);
volleyRequestQueue = Volley.newRequestQueue(this, getUserAgent(), null, new File(cacheDir, Volley.DEFAULT_CACHE_DIR), VOLLEY_CACHE_SIZE);
imageLoader = new ImageLoader(volleyRequestQueue, new BitmapLruImageCache(VOLLEY_LRU_CACHE_SIZE));
final int runtimeMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
final int lruImageCacheSize = runtimeMemory / 8;
imageLoader = new ImageLoader(volleyRequestQueue, new BitmapLruImageCache(lruImageCacheSize));
fileCache = new FileCache(new File(cacheDir, FILE_CACHE_NAME), FILE_CACHE_DISK_SIZE, getUserAgent());

@ -29,7 +29,7 @@ public class BitmapLruImageCache extends LruCache<String, Bitmap> implements Ima
@Override
protected int sizeOf(String key, Bitmap value) {
return value.getRowBytes() * value.getHeight();
return value.getRowBytes() * value.getHeight() / 1024;
}
@Override

Loading…
Cancel
Save