From c345bfd40ed4976bdbd9fe4cddfbb4bb107b0be3 Mon Sep 17 00:00:00 2001 From: Florens Douwes Date: Sat, 9 Aug 2014 14:51:12 +0200 Subject: [PATCH] Decreased volley cache site, reduce startup time. The startup time needs to be fixed another time. --- .../src/main/java/com/android/volley/toolbox/Volley.java | 7 ++++++- .../app/src/main/java/org/floens/chan/ChanApplication.java | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Clover/app/src/main/java/com/android/volley/toolbox/Volley.java b/Clover/app/src/main/java/com/android/volley/toolbox/Volley.java index 0be1c734..a031413f 100644 --- a/Clover/app/src/main/java/com/android/volley/toolbox/Volley.java +++ b/Clover/app/src/main/java/com/android/volley/toolbox/Volley.java @@ -45,6 +45,10 @@ public class Volley { } public static RequestQueue newRequestQueue(Context context, HttpStack stack, File cacheDir) { + return newRequestQueue(context, stack, cacheDir, -1); + } + + public static RequestQueue newRequestQueue(Context context, HttpStack stack, File cacheDir, int diskCacheSize) { String userAgent = "volley/0"; try { String packageName = context.getPackageName(); @@ -65,7 +69,8 @@ public class Volley { Network network = new BasicNetwork(stack); - RequestQueue queue = new RequestQueue(new DiskBasedCache(cacheDir), network); + DiskBasedCache diskCache = diskCacheSize < 0 ? new DiskBasedCache(cacheDir) : new DiskBasedCache(cacheDir, diskCacheSize); + RequestQueue queue = new RequestQueue(diskCache, network); queue.start(); return queue; diff --git a/Clover/app/src/main/java/org/floens/chan/ChanApplication.java b/Clover/app/src/main/java/org/floens/chan/ChanApplication.java index 7fa26cca..77e78669 100644 --- a/Clover/app/src/main/java/org/floens/chan/ChanApplication.java +++ b/Clover/app/src/main/java/org/floens/chan/ChanApplication.java @@ -47,6 +47,7 @@ public class ChanApplication extends Application { private static final long FILE_CACHE_DISK_SIZE = 50 * 1024 * 1024; // 50mb private static final String FILE_CACHE_NAME = "filecache"; private static final int VOLLEY_LRU_CACHE_SIZE = 8 * 1024 * 1024; // 8mb + private static final int VOLLEY_CACHE_SIZE = 20 * 1024 * 1024; // 8mb private static ChanApplication instance; private static RequestQueue volleyRequestQueue; @@ -127,7 +128,7 @@ public class ChanApplication extends Application { File cacheDir = getExternalCacheDir() != null ? getExternalCacheDir() : getCacheDir(); - volleyRequestQueue = Volley.newRequestQueue(this, null, new File(cacheDir, Volley.DEFAULT_CACHE_DIR)); + volleyRequestQueue = Volley.newRequestQueue(this, null, new File(cacheDir, Volley.DEFAULT_CACHE_DIR), VOLLEY_CACHE_SIZE); imageLoader = new ImageLoader(volleyRequestQueue, new BitmapLruImageCache(VOLLEY_LRU_CACHE_SIZE)); fileCache = new FileCache(new File(cacheDir, FILE_CACHE_NAME), FILE_CACHE_DISK_SIZE);