use of com.nostra13.universalimageloader.cache.disc.DiskCache in project LibreraReader by foobnix.
the class IMG method init.
public static void init(Context context) {
IMG.context = context;
bookBGWithMark = context.getResources().getDrawable(R.drawable.bookeffect2);
bookBGNoMark = context.getResources().getDrawable(R.drawable.bookeffect1);
final Builder builder = new DisplayImageOptions.Builder();
builder.cacheInMemory(true);
builder.cacheOnDisk(true);
builder.showImageOnLoading(COLOR_DRAWABLE);
builder.showImageOnFail(COLOR_DRAWABLE);
builder.showImageForEmptyUri(COLOR_DRAWABLE);
builder.bitmapConfig(BMP_CFG);
builder.imageScaleType(ImageScaleType.NONE);
builder.resetViewBeforeLoading(RESET_VIEW_BEFORE_LOADING);
builder.considerExifParams(false);
builder.decodingOptions(new Options());
final ImageLoaderConfiguration config = //
new ImageLoaderConfiguration.Builder(context).threadPoolSize(//
1).threadPriority(//
Thread.NORM_PRIORITY).defaultDisplayImageOptions(//
builder.build()).diskCache(//
new UnlimitedDiskCache(new File(context.getExternalCacheDir(), "Images-1"))).imageDownloader(//
ImageExtractor.getInstance(context)).build();
ImageLoader.getInstance().init(config);
}
use of com.nostra13.universalimageloader.cache.disc.DiskCache in project LibreraReader by foobnix.
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.DiskCache 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.DiskCache in project KenBurnsView by flavioarfaria.
the class FromURLActivity method loadImage.
private void loadImage() {
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
String cacheDirName = "." + getString(R.string.app_name);
cacheDir = new File(Environment.getExternalStorageDirectory(), cacheDirName);
} else {
cacheDir = getCacheDir();
}
if (!cacheDir.exists()) {
cacheDir.mkdirs();
}
config = new ImageLoaderConfiguration.Builder(this).memoryCache(new WeakMemoryCache()).denyCacheImageMultipleSizesInMemory().diskCache(new UnlimitedDiscCache(cacheDir)).threadPoolSize(5).build();
options = new DisplayImageOptions.Builder().bitmapConfig(Bitmap.Config.RGB_565).imageScaleType(ImageScaleType.IN_SAMPLE_INT).cacheOnDisk(true).cacheInMemory(true).build();
imageLoader.init(config);
imageLoader.displayImage("http://i.imgur.com/gysR4Ee.jpg", mImg, options, this);
}
use of com.nostra13.universalimageloader.cache.disc.DiskCache in project GomoTest by suReZj.
the class BaseActivity method initImageLoader.
/**
* 初始化图片载入框架
*/
private void initImageLoader() {
File cacheDir = StorageUtils.getCacheDirectory(this);
int MAXMEMONRY = (int) (Runtime.getRuntime().maxMemory());
// System.out.println("dsa-->"+MAXMEMONRY+" "+(MAXMEMONRY/5));//.memoryCache(new
// LruMemoryCache(50 * 1024 * 1024))
DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisk(true).build();
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this).memoryCacheExtraOptions(480, 800).defaultDisplayImageOptions(defaultOptions).diskCacheExtraOptions(480, 800, null).threadPoolSize(3).threadPriority(Thread.NORM_PRIORITY - 2).tasksProcessingOrder(QueueProcessingType.FIFO).denyCacheImageMultipleSizesInMemory().memoryCache(new LruMemoryCache(MAXMEMONRY / 5)).diskCache(new UnlimitedDiskCache(cacheDir)).diskCacheFileNameGenerator(// default
new HashCodeFileNameGenerator()).imageDownloader(// default
new BaseImageDownloader(this)).imageDecoder(// default
new BaseImageDecoder(false)).defaultDisplayImageOptions(DisplayImageOptions.createSimple()).build();
ImageLoader.getInstance().init(config);
}
Aggregations