Remove set default options in ImageManager
Simpler interface if people just set instances of
default disk/memory cache that they create
diff --git a/library/src/com/bumptech/photos/resize/ImageManager.java b/library/src/com/bumptech/photos/resize/ImageManager.java
index 96eaad1..609ae38 100644
--- a/library/src/com/bumptech/photos/resize/ImageManager.java
+++ b/library/src/com/bumptech/photos/resize/ImageManager.java
@@ -27,7 +27,6 @@
import java.io.File;
import java.io.FileNotFoundException;
-import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.concurrent.ExecutorService;
@@ -167,15 +166,6 @@
return this;
}
- public Builder setDefaultMemoryCacheSize(int maxSize) {
- if (memoryCache != null) {
- throw new IllegalArgumentException("Can't set a default memory cache after setting a custom one");
- }
-
- memoryCache = new LruPhotoCache(maxSize);
- return this;
- }
-
public Builder setDiskCache(DiskCache diskCache) {
this.diskCache = diskCache;
return this;
@@ -186,33 +176,6 @@
return this;
}
- public Builder setDefaultDiskCacheOptions(File dir) {
- setDefaultDiskCacheOptions(dir, DEFAULT_DISK_CACHE_SIZE);
- return this;
- }
-
- public Builder setDefaultDiskCacheOptions(int size) {
- setDefaultDiskCacheOptions(getPhotoCacheDir(context), size);
- return this;
- }
-
- public Builder setDefaultDiskCacheOptions(File dir, int size) {
- if (size <= 0) {
- throw new IllegalArgumentException("Size must be >= 0");
- }
-
- if (diskCache != null) {
- throw new IllegalArgumentException("Can't set disk cache twice");
- }
-
- try {
- diskCache = DiskLruCacheWrapper.get(dir, size);
- } catch (IOException e) {
- e.printStackTrace();
- disableDiskCache();
- }
- return this;
- }
public Builder setMaxBitmapsPerSize(int maxBitmapsPerSize) {
this.maxBitmapsPerSize = maxBitmapsPerSize;
@@ -232,11 +195,11 @@
}
if (memoryCache == null) {
- setDefaultMemoryCacheSize(LruPhotoCache.getMaxCacheSize(context));
+ memoryCache = new LruPhotoCache(LruPhotoCache.getMaxCacheSize(context));
}
if (diskCache == null) {
- setDefaultDiskCacheOptions(getPhotoCacheDir(context), DEFAULT_DISK_CACHE_SIZE);
+ diskCache = DiskLruCacheWrapper.get(getPhotoCacheDir(context), DEFAULT_DISK_CACHE_SIZE);
}
}
}
diff --git a/samples/flickr/src/com/bumptech/flickr/FlickrSearchActivity.java b/samples/flickr/src/com/bumptech/flickr/FlickrSearchActivity.java
index 6c5a3e6..4734876 100644
--- a/samples/flickr/src/com/bumptech/flickr/FlickrSearchActivity.java
+++ b/samples/flickr/src/com/bumptech/flickr/FlickrSearchActivity.java
@@ -18,6 +18,8 @@
import com.bumptech.flickr.api.Api;
import com.bumptech.flickr.api.Photo;
import com.bumptech.photos.resize.ImageManager;
+import com.bumptech.photos.resize.cache.DiskLruCacheWrapper;
+import com.bumptech.photos.resize.cache.LruPhotoCache;
import com.bumptech.photos.util.Log;
import java.io.File;
@@ -47,7 +49,8 @@
}
imageManager = new ImageManager.Builder(this)
- .setDefaultDiskCacheOptions(50 * 1024 * 1024)
+ .setMemoryCache(new LruPhotoCache(1234))
+ .setDiskCache(DiskLruCacheWrapper.get(ImageManager.getPhotoCacheDir(this), 50 * 1024 * 1024))
.setMaxBitmapsPerSize(40)
.build();