use of com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache in project Android-Universal-Image-Loader by nostra13.
the class DefaultConfigurationFactory method createDiskCache.
/**
* Creates default implementation of {@link DiskCache} depends on incoming parameters
*/
public static DiskCache createDiskCache(Context context, FileNameGenerator diskCacheFileNameGenerator, long diskCacheSize, int diskCacheFileCount) {
File reserveCacheDir = createReserveDiskCacheDir(context);
if (diskCacheSize > 0 || diskCacheFileCount > 0) {
File individualCacheDir = StorageUtils.getIndividualCacheDirectory(context);
try {
return new LruDiskCache(individualCacheDir, reserveCacheDir, diskCacheFileNameGenerator, diskCacheSize, diskCacheFileCount);
} catch (IOException e) {
L.e(e);
// continue and create unlimited cache
}
}
File cacheDir = StorageUtils.getCacheDirectory(context);
return new UnlimitedDiskCache(cacheDir, reserveCacheDir, diskCacheFileNameGenerator);
}
use of com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache in project QuickAndroid by ImKarl.
the class QAImageLoaderConfig method getConfig.
/**
* 获取加载配置
* @param context
* @param imageOnLoading 加载中显示的图片
* @param imageOnFail 加载失败显示的图片
* @return
*/
public static ImageLoaderConfiguration getConfig(Context context, Drawable imageOnLoading, Drawable imageOnFail) {
DisplayImageOptions options = new DisplayImageOptions.Builder().showImageOnLoading(// 加载中
imageOnLoading).showImageForEmptyUri(// 图片Uri为空或是错误的时候显示的图片
imageOnFail).showImageOnFail(// resource or drawable
imageOnFail).resetViewBeforeLoading(// default
false).delayBeforeLoading(// 加载前延迟时长
50).cacheInMemory(// default = false 是否使用内存缓存
true).cacheOnDisk(// default = false 是否使用文件缓存
true).considerExifParams(// default = false
false).imageScaleType(// default
ImageScaleType.IN_SAMPLE_POWER_OF_2).bitmapConfig(// default
Bitmap.Config.ARGB_8888).displayer(// default = new SimpleBitmapDisplayer()
new FadeInBitmapDisplayer(100)).build();
File cacheDir = new File(QAFileManager.getUsableDir(context.getPackageName()));
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context).threadPoolSize(// default 线程池大小
3).threadPriority(// default 线程优先级
Thread.NORM_PRIORITY - 2).denyCacheImageMultipleSizesInMemory().memoryCache(// 内存缓存
new LruMemoryCache(8 * 1024 * 1024)).diskCache(// default 磁盘缓存
new UnlimitedDiskCache(cacheDir)).diskCacheSize(// 磁盘缓存大小
30 * 1024 * 1024).diskCacheFileNameGenerator(// default 磁盘缓存文件名
new HashCodeFileNameGenerator()).imageDownloader(// default 图片下载器
new BaseImageDownloader(context)).imageDecoder(// default 图片解码器
new BaseImageDecoder(QACore.isDebug())).defaultDisplayImageOptions(// default=DisplayImageOptions.createSimple() 图片显示选项
options).build();
return config;
}
use of com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache 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.impl.UnlimitedDiskCache in project QuickAndroid by ImKarl.
the class QAImageLoaderConfig method getConfig.
/**
* 获取加载配置
* @param context
* @param imageOnLoadingRes 加载中显示的图片
* @param imageOnFailRes 加载失败显示的图片
* @return
*/
public static ImageLoaderConfiguration getConfig(Context context, int imageOnLoadingRes, int imageOnFailRes) {
DisplayImageOptions options = new DisplayImageOptions.Builder().showImageOnLoading(// 加载中
imageOnLoadingRes).showImageForEmptyUri(// 图片Uri为空或是错误的时候显示的图片
imageOnFailRes).showImageOnFail(// resource or drawable
imageOnFailRes).resetViewBeforeLoading(// default
false).delayBeforeLoading(// 加载前延迟时长
50).cacheInMemory(// default = false 是否使用内存缓存
true).cacheOnDisk(// default = false 是否使用文件缓存
true).considerExifParams(// default = false
false).imageScaleType(// default
ImageScaleType.IN_SAMPLE_POWER_OF_2).bitmapConfig(// default
Bitmap.Config.ARGB_8888).displayer(// default = new SimpleBitmapDisplayer()
new FadeInBitmapDisplayer(100)).build();
File cacheDir = new File(QAFileManager.getUsableDir(context.getPackageName()));
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context).threadPoolSize(// default 线程池大小
3).threadPriority(// default 线程优先级
Thread.NORM_PRIORITY - 2).denyCacheImageMultipleSizesInMemory().memoryCache(// 内存缓存
new LruMemoryCache(8 * 1024 * 1024)).diskCache(// default 磁盘缓存
new UnlimitedDiskCache(cacheDir)).diskCacheSize(// 磁盘缓存大小
30 * 1024 * 1024).diskCacheFileNameGenerator(// default 磁盘缓存文件名
new HashCodeFileNameGenerator()).imageDownloader(// default 图片下载器
new BaseImageDownloader(context)).imageDecoder(// default 图片解码器
new BaseImageDecoder(QACore.isDebug())).defaultDisplayImageOptions(// default=DisplayImageOptions.createSimple() 图片显示选项
options).build();
return config;
}
Aggregations