Store cache files on the dir returned by getExternalCacheDir, if available.

Closes #7
captchafix
Florens Douwes 11 years ago
parent 3349945f36
commit 51358673b7
  1. 7
      Clover/app/src/main/java/com/android/volley/toolbox/Volley.java
  2. 4
      Clover/app/src/main/java/org/floens/chan/ChanApplication.java

@ -30,7 +30,8 @@ import java.io.File;
public class Volley { public class Volley {
/** Default on-disk cache directory. */ /** Default on-disk cache directory. */
private static final String DEFAULT_CACHE_DIR = "volley"; public static final String DEFAULT_CACHE_DIR = "volley";
/** /**
* Creates a default instance of the worker pool and calls {@link RequestQueue#start()} on it. * Creates a default instance of the worker pool and calls {@link RequestQueue#start()} on it.
@ -40,8 +41,10 @@ public class Volley {
* @return A started {@link RequestQueue} instance. * @return A started {@link RequestQueue} instance.
*/ */
public static RequestQueue newRequestQueue(Context context, HttpStack stack) { public static RequestQueue newRequestQueue(Context context, HttpStack stack) {
File cacheDir = new File(context.getCacheDir(), DEFAULT_CACHE_DIR); return newRequestQueue(context, stack, new File(context.getCacheDir(), DEFAULT_CACHE_DIR));
}
public static RequestQueue newRequestQueue(Context context, HttpStack stack, File cacheDir) {
String userAgent = "volley/0"; String userAgent = "volley/0";
try { try {
String packageName = context.getPackageName(); String packageName = context.getPackageName();

@ -37,6 +37,7 @@ import org.floens.chan.service.WatchService;
import org.floens.chan.utils.IconCache; import org.floens.chan.utils.IconCache;
import org.floens.chan.utils.ThemeHelper; import org.floens.chan.utils.ThemeHelper;
import java.io.File;
import java.lang.reflect.Field; import java.lang.reflect.Field;
public class ChanApplication extends Application implements PinListener { public class ChanApplication extends Application implements PinListener {
@ -108,7 +109,8 @@ public class ChanApplication extends Application implements PinListener {
IconCache.createIcons(this); IconCache.createIcons(this);
volleyRequestQueue = Volley.newRequestQueue(this); File cacheDir = new File(getExternalCacheDir() != null ? getExternalCacheDir() : getCacheDir(), Volley.DEFAULT_CACHE_DIR);
volleyRequestQueue = Volley.newRequestQueue(this, null, cacheDir);
imageLoader = new ImageLoader(volleyRequestQueue, new BitmapLruImageCache(1024 * 1024 * 8)); imageLoader = new ImageLoader(volleyRequestQueue, new BitmapLruImageCache(1024 * 1024 * 8));
databaseManager = new DatabaseManager(this); databaseManager = new DatabaseManager(this);

Loading…
Cancel
Save