use of me.ccrama.redditslide.util.OkHttpImageDownloader in project Slide by ccrama.
the class ImageLoaderUnescape method initImageLoader.
public static void initImageLoader(Context context) {
long discCacheSize = 1024 * 1024;
DiskCache discCache;
File dir = getCacheDirectory(context);
int threadPoolSize;
discCacheSize *= 100;
threadPoolSize = 7;
if (discCacheSize > 0) {
try {
dir.mkdir();
discCache = new LruDiskCache(dir, new Md5FileNameGenerator(), discCacheSize);
} catch (IOException e) {
discCache = new UnlimitedDiskCache(dir);
}
} else {
discCache = new UnlimitedDiskCache(dir);
}
options = new DisplayImageOptions.Builder().cacheOnDisk(true).bitmapConfig(Bitmap.Config.RGB_565).imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2).cacheInMemory(false).resetViewBeforeLoading(false).displayer(new FadeInBitmapDisplayer(250)).build();
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context).threadPoolSize(threadPoolSize).denyCacheImageMultipleSizesInMemory().diskCache(discCache).threadPoolSize(4).imageDownloader(new OkHttpImageDownloader(context)).defaultDisplayImageOptions(options).build();
if (ImageLoader.getInstance().isInited()) {
ImageLoader.getInstance().destroy();
}
imageLoader = ImageLoaderUnescape.getInstance();
imageLoader.init(config);
}
use of me.ccrama.redditslide.util.OkHttpImageDownloader in project Slide by ccrama.
the class ImageFlairs method initFlairImageLoader.
public static FlairImageLoader initFlairImageLoader(Context context) {
// 100 MB limit
long discCacheSize = 1024 * 1024 * 100;
DiskCache discCache;
File dir = getCacheDirectory(context);
discCacheSize *= 100;
int threadPoolSize = 7;
if (discCacheSize > 0) {
try {
dir.mkdir();
discCache = new LruDiskCache(dir, new Md5FileNameGenerator(), discCacheSize);
} catch (IOException e) {
discCache = new UnlimitedDiskCache(dir);
}
} else {
discCache = new UnlimitedDiskCache(dir);
}
options = new DisplayImageOptions.Builder().cacheOnDisk(true).imageScaleType(ImageScaleType.NONE).cacheInMemory(false).resetViewBeforeLoading(false).build();
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context).threadPoolSize(threadPoolSize).denyCacheImageMultipleSizesInMemory().diskCache(discCache).threadPoolSize(4).imageDownloader(new OkHttpImageDownloader(context)).defaultDisplayImageOptions(options).build();
if (FlairImageLoader.getInstance().isInited()) {
FlairImageLoader.getInstance().destroy();
}
imageLoader = FlairImageLoader.getInstance();
imageLoader.init(config);
return imageLoader;
}
Aggregations