use of com.nostra13.universalimageloader.cache.disc.DiskCache in project StickerCamera by Skykai521.
the class App method initImageLoader.
private void initImageLoader() {
DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder().cacheInMemory(false).imageScaleType(ImageScaleType.EXACTLY).cacheOnDisk(true).build();
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this).threadPriority(Thread.NORM_PRIORITY - 2).defaultDisplayImageOptions(defaultOptions).denyCacheImageMultipleSizesInMemory().diskCacheFileNameGenerator(new Md5FileNameGenerator()).diskCache(new UnlimitedDiskCache(StorageUtils.getOwnCacheDirectory(this, AppConstants.APP_IMAGE))).diskCacheSize(100 * 1024 * 1024).tasksProcessingOrder(QueueProcessingType.LIFO).memoryCache(new LruMemoryCache(2 * 1024 * 1024)).memoryCacheSize(2 * 1024 * 1024).threadPoolSize(3).build();
ImageLoader.getInstance().init(config);
}
use of com.nostra13.universalimageloader.cache.disc.DiskCache 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;
}
use of com.nostra13.universalimageloader.cache.disc.DiskCache in project Slide by ccrama.
the class ImageLoaderUtils method initImageLoader.
public static void initImageLoader(Context context) {
long discCacheSize = 1024 * 1024;
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).bitmapConfig(SettingValues.highColorspaceImages ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565).imageScaleType(SettingValues.highColorspaceImages ? ImageScaleType.NONE_SAFE : ImageScaleType.IN_SAMPLE_POWER_OF_2).cacheInMemory(false).resetViewBeforeLoading(false).displayer(new FadeInBitmapDisplayer(250)).build();
if (SettingValues.highColorspaceImages) {
SubsamplingScaleImageView.setPreferredBitmapConfig(Bitmap.Config.ARGB_8888);
}
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 com.nostra13.universalimageloader.cache.disc.DiskCache in project BaseProject by fly803.
the class AppApplication method initImageLoader.
private void initImageLoader() {
// 初始化 Image-Loader
DisplayImageOptions options = new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisk(true).build();
ImageLoaderConfiguration configuration = new ImageLoaderConfiguration.Builder(this).memoryCache(new LruMemoryCache(MEMORY_SIZE)).diskCache(new UnlimitedDiscCache(new File(getCacheDir(), "caches"))).diskCacheSize(DISK_SIZE).defaultDisplayImageOptions(options).build();
ImageLoader.getInstance().init(configuration);
}
Aggregations