use of com.nostra13.universalimageloader.cache.disc.DiskCache 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 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);
}
use of com.nostra13.universalimageloader.cache.disc.DiskCache 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.DiskCache in project MGit by maks.
the class SheimiFragmentActivity method setupImageLoader.
private void setupImageLoader() {
DisplayImageOptions mDisplayOptions = new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisk(true).showImageForEmptyUri(R.drawable.ic_default_author).showImageOnFail(R.drawable.ic_default_author).build();
File cacheDir = StorageUtils.getCacheDirectory(this);
ImageLoaderConfiguration configuration = new ImageLoaderConfiguration.Builder(this).defaultDisplayImageOptions(mDisplayOptions).diskCache(new UnlimitedDiskCache(cacheDir)).diskCacheSize(SIZE).imageDownloader(new AvatarDownloader(this)).build();
mImageLoader = ImageLoader.getInstance();
mImageLoader.init(configuration);
}
use of com.nostra13.universalimageloader.cache.disc.DiskCache in project BlogSource by TeachCourse.
the class App method config.
/**
* 初始化ImageLoader配置
*
* @param context
*/
private ImageLoaderConfiguration config(Context context) {
File cacheDir = StorageUtils.getOwnCacheDirectory(context, CACHE);
if (!cacheDir.exists()) {
cacheDir.mkdirs();
}
ImageLoaderConfiguration options = new ImageLoaderConfiguration.Builder(context).memoryCacheExtraOptions(480, 800).denyCacheImageMultipleSizesInMemory().tasksProcessingOrder(QueueProcessingType.LIFO).diskCache(new UnlimitedDiskCache(cacheDir)).build();
return options;
}
Aggregations