本文整理汇总了Java中com.nostra13.universalimageloader.cache.disc.impl.ext.LruDiskCache类的典型用法代码示例。如果您正苦于以下问题:Java LruDiskCache类的具体用法?Java LruDiskCache怎么用?Java LruDiskCache使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LruDiskCache类属于com.nostra13.universalimageloader.cache.disc.impl.ext包,在下文中一共展示了LruDiskCache类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDiskCache
import com.nostra13.universalimageloader.cache.disc.impl.ext.LruDiskCache; //导入依赖的package包/类
/**
* 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);
}
示例2: getDefaultConfig
import com.nostra13.universalimageloader.cache.disc.impl.ext.LruDiskCache; //导入依赖的package包/类
private ImageLoaderConfiguration getDefaultConfig() throws IOException {
int MAX_CACHE_MEMORY_SIZE = (int) (Runtime.getRuntime().maxMemory() / 8);
File cacheDir = StorageUtils.getOwnCacheDirectory(context, context.getPackageName() + "/cache/image/");
LogUtil.i(TAG, "ImageLoader memory cache size = " + MAX_CACHE_MEMORY_SIZE / M + "M");
LogUtil.i(TAG, "ImageLoader disk cache directory = " + cacheDir.getAbsolutePath());
ImageLoaderConfiguration config = new ImageLoaderConfiguration
.Builder(context)
.threadPoolSize(3) // 线程池内加载的数量
.threadPriority(Thread.NORM_PRIORITY - 2) // 降低线程的优先级,减小对UI主线程的影响
.denyCacheImageMultipleSizesInMemory()
.memoryCache(new LruMemoryCache(MAX_CACHE_MEMORY_SIZE))
.discCache(new LruDiskCache(cacheDir, new Md5FileNameGenerator(), 0))
.defaultDisplayImageOptions(DisplayImageOptions.createSimple())
.imageDownloader(new BaseImageDownloader(context, 5 * 1000, 30 * 1000)) // connectTimeout (5 s), readTimeout (30 s)超时时间
.writeDebugLogs()
.build();
return config;
}
示例3: createDiskCache
import com.nostra13.universalimageloader.cache.disc.impl.ext.LruDiskCache; //导入依赖的package包/类
/**
* 默认图片 本地路径缓存
* 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);
}
开发者ID:jiangqqlmj,项目名称:Android-Universal-Image-Loader-Modify,代码行数:24,代码来源:DefaultConfigurationFactory.java
示例4: getImageCache
import com.nostra13.universalimageloader.cache.disc.impl.ext.LruDiskCache; //导入依赖的package包/类
/**
* Returns (and initialises, if needed) an image cache that uses memory and (1MB) local storage.
* @return An image cache that loads web images synchronously and transparently
*/
public ImageLoader getImageCache() {
if (imageCache == null) {
imageCache = ImageLoader.getInstance();
try {
LruDiskCache diskCache = new LruDiskCache(context.getCacheDir(), null, new Md5FileNameGenerator(), 640000, 25);
// @formatter:off
Builder imageCacheBuilder = new Builder(context)
.defaultDisplayImageOptions(
new DisplayImageOptions.Builder()
.cacheInMemory(true)
.cacheOnDisk(true)
.imageScaleType(ImageScaleType.IN_SAMPLE_INT)
.showImageForEmptyUri(R.drawable.ic_launcher).build())
.memoryCache(new UsingFreqLimitedMemoryCache(1024 * 1024))
.diskCache(diskCache);
imageCache.init(imageCacheBuilder.build());
// @formatter:on
} catch (IOException e) {
// The cache directory is always available on Android; ignore this exception
}
}
return imageCache;
}
示例5: createDiskCache
import com.nostra13.universalimageloader.cache.disc.impl.ext.LruDiskCache; //导入依赖的package包/类
public static DiskCache createDiskCache(Context context, FileNameGenerator
diskCacheFileNameGenerator, long diskCacheSize, int diskCacheFileCount) {
File reserveCacheDir = createReserveDiskCacheDir(context);
if (diskCacheSize > 0 || diskCacheFileCount > 0) {
try {
return new LruDiskCache(StorageUtils.getIndividualCacheDirectory(context),
reserveCacheDir, diskCacheFileNameGenerator, diskCacheSize,
diskCacheFileCount);
} catch (IOException e) {
L.e(e);
}
}
return new UnlimitedDiskCache(StorageUtils.getCacheDirectory(context), reserveCacheDir,
diskCacheFileNameGenerator);
}
示例6: initImageLoader
import com.nostra13.universalimageloader.cache.disc.impl.ext.LruDiskCache; //导入依赖的package包/类
private void initImageLoader() {
DisplayImageOptions options = new DisplayImageOptions.Builder()
.bitmapConfig(Bitmap.Config.RGB_565)
.imageScaleType(ImageScaleType.EXACTLY)
.cacheOnDisc(true)
.displayer(new FadeInBitmapDisplayer(200))
.build();
File cacheDir = new File(FileUtil.getCacheDir().getAbsolutePath() + "/" + Constants.IMAGE_CACHE_DIR);
ImageLoaderConfiguration.Builder configBuilder = null;
try {
configBuilder = new ImageLoaderConfiguration.Builder(getApplicationContext())
.memoryCache(new WeakMemoryCache())
.diskCache(new LruDiskCache(cacheDir,new Md5FileNameGenerator(),500))
.denyCacheImageMultipleSizesInMemory()
.threadPoolSize(3)//线程池内加载的数量
.threadPriority(Thread.NORM_PRIORITY - 2)
.memoryCache(new UsingFreqLimitedMemoryCache(2 * 1024 * 1024)) // You can pass your own memory cache implementation/你可以通过自己的内存缓存实现
.memoryCacheSize(2 * 1024 * 1024)
.discCacheSize(50 * 1024 * 1024)
.discCacheFileNameGenerator(new Md5FileNameGenerator())//将保存的时候的URI名称用MD5 加密
.tasksProcessingOrder(QueueProcessingType.LIFO)
.discCacheFileCount(100) //缓存的文件数量
//.discCache(new UnlimitedDiscCache(cacheDir))
.defaultDisplayImageOptions(options);
} catch (IOException e) {
e.printStackTrace();
}
if (BuildConfig.DEBUG) {
configBuilder.writeDebugLogs();
}
ImageLoader.getInstance().init(configBuilder.build());
}