本文整理汇总了Java中com.nostra13.universalimageloader.utils.StorageUtils类的典型用法代码示例。如果您正苦于以下问题:Java StorageUtils类的具体用法?Java StorageUtils怎么用?Java StorageUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StorageUtils类属于com.nostra13.universalimageloader.utils包,在下文中一共展示了StorageUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDiskCache
import com.nostra13.universalimageloader.utils.StorageUtils; //导入依赖的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: initImageLoader
import com.nostra13.universalimageloader.utils.StorageUtils; //导入依赖的package包/类
public void initImageLoader() {
File cacheDir = StorageUtils.getCacheDirectory(this);
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this)
.memoryCacheExtraOptions(480, 800) // default = device screen dimensions
.diskCacheExtraOptions(480, 800, null)
.denyCacheImageMultipleSizesInMemory()
.memoryCache(new LruMemoryCache(2 * 1024 * 1024))
.memoryCacheSize(2 * 1024 * 1024)
.memoryCacheSizePercentage(13) // default
.diskCache(new UnlimitedDiskCache(cacheDir)) // default
.diskCacheSize(50 * 1024 * 1024)
.diskCacheFileCount(100)
// .writeDebugLogs()
.build();
ImageLoader.getInstance().init(config);
}
示例3: initImageLoader
import com.nostra13.universalimageloader.utils.StorageUtils; //导入依赖的package包/类
/**
* 初始化图片载入框架
*/
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(new HashCodeFileNameGenerator()) // default
.imageDownloader(new BaseImageDownloader(this)) // default
.imageDecoder(new BaseImageDecoder(false)) // default
.defaultDisplayImageOptions(DisplayImageOptions.createSimple()).build();
ImageLoader.getInstance().init(config);
}
示例4: getDefaultConfig
import com.nostra13.universalimageloader.utils.StorageUtils; //导入依赖的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;
}
示例5: initImageLoader
import com.nostra13.universalimageloader.utils.StorageUtils; //导入依赖的package包/类
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, Constant.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);
}
示例6: initImageLoader
import com.nostra13.universalimageloader.utils.StorageUtils; //导入依赖的package包/类
/**
* 初始化ImageLoader
*
* @param context 上下文对象
*/
private void initImageLoader(Context context) {
File cacheDir = StorageUtils.getCacheDirectory(context);
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
.memoryCacheExtraOptions(480, 800) // default = device screen dimensions
.diskCacheExtraOptions(480, 800, null)
// .taskExecutor(...)
// .taskExecutorForCachedImages(...)
.threadPoolSize(3) // default
.threadPriority(Thread.NORM_PRIORITY - 2) // default
.tasksProcessingOrder(QueueProcessingType.FIFO) // default
.denyCacheImageMultipleSizesInMemory()
.memoryCache(new LruMemoryCache(2 * 1024 * 1024))
.memoryCacheSize(2 * 1024 * 1024)
.memoryCacheSizePercentage(13) // default
.diskCache(new UnlimitedDiskCache(cacheDir)) // default
.diskCacheSize(50 * 1024 * 1024)
.diskCacheFileCount(100)
.diskCacheFileNameGenerator(new HashCodeFileNameGenerator()) // default
.imageDownloader(new BaseImageDownloader(context)) // default
// .imageDecoder(new BaseImageDecoder()) // default
.defaultDisplayImageOptions(DisplayImageOptions.createSimple()) // default
.writeDebugLogs()
.build();
ImageLoader.getInstance().init(config);
}
示例7: onCreate
import com.nostra13.universalimageloader.utils.StorageUtils; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
//初始化ImageLoader
// ImageLoaderConfiguration configuration=ImageLoaderConfiguration.createDefault(getApplicationContext());
// ImageLoader.getInstance().init(configuration);
File cacheDir = StorageUtils.getOwnCacheDirectory(this, "Hungry and hurry/Cache");
ImageLoaderConfiguration config = new ImageLoaderConfiguration
.Builder(this)
.memoryCacheExtraOptions(480, 800) // maxwidth, max height,即保存的每个缓存文件的最大长宽
.threadPoolSize(3)//线程池内加载的数量
.threadPriority(Thread.NORM_PRIORITY - 2)
.denyCacheImageMultipleSizesInMemory()
.memoryCache(new UsingFreqLimitedMemoryCache(2 * 1024 * 1024)) // You can pass your own memory cache implementation/你可以通过自己的内存缓存实现
.memoryCacheSize(2 * 1024 * 1024)
.tasksProcessingOrder(QueueProcessingType.LIFO)
.diskCache(new UnlimitedDiskCache(cacheDir))//自定义缓存路径
.diskCacheFileCount(70)
.diskCacheFileNameGenerator(new Md5FileNameGenerator())//将保存的时候的URI名称用MD5 加密
.defaultDisplayImageOptions(DisplayImageOptions.createSimple())
.imageDownloader(new BaseImageDownloader(this,5 * 1000, 30 * 1000)) // connectTimeout (5 s), readTimeout (30 s)超时时间
.writeDebugLogs() // Remove for releaseapp
.build();//开始构建
ImageLoader.getInstance().init(config);
}
示例8: initImageLoader
import com.nostra13.universalimageloader.utils.StorageUtils; //导入依赖的package包/类
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);
}
示例9: initImageLoader
import com.nostra13.universalimageloader.utils.StorageUtils; //导入依赖的package包/类
/** 初始化ImageLoader */
public static void initImageLoader(Context context) {
File cacheDir = StorageUtils.getOwnCacheDirectory(context,
"beautynote/cache");// 获取到缓存的目录地址
// 创建配置ImageLoader(所有的选项都是可选的,只使用那些你真的想定制),这个可以设定在APPLACATION里面,设置为全局的配置参数
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
context)
// 线程池内加载的数量
.threadPoolSize(3).threadPriority(Thread.NORM_PRIORITY - 2)
.memoryCache(new WeakMemoryCache())
.denyCacheImageMultipleSizesInMemory()
.discCacheFileNameGenerator(new Md5FileNameGenerator())
// 将保存的时候的URI名称用MD5 加密
.tasksProcessingOrder(QueueProcessingType.LIFO)
.discCache(new UnlimitedDiscCache(cacheDir))// 自定义缓存路径
// .defaultDisplayImageOptions(DisplayImageOptions.createSimple())
.writeDebugLogs() // Remove for release app
.build();
// Initialize ImageLoader with configuration.
ImageLoader.getInstance().init(config);// 全局初始化此配置
}
示例10: cache
import com.nostra13.universalimageloader.utils.StorageUtils; //导入依赖的package包/类
public static File cache(String name){
File cacheDir=null;
if(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){
String path="/storage/sdcard1";
// String name="zhai/Cache";//你要新建的文件夹名或者文件名
cacheDir=new File(path,name);//方法1和方法2的区别在于此
boolean is=cacheDir.exists();//判断文件(夹)是否存在
if(!is){
cacheDir.mkdir();//创建文件夹
}
//存储在外置sd卡中
}else{
cacheDir=StorageUtils.getOwnCacheDirectory(getApp(),name);
}
return cacheDir;
}
示例11: createDiskCache
import com.nostra13.universalimageloader.utils.StorageUtils; //导入依赖的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 LruDiscCache(individualCacheDir, reserveCacheDir, diskCacheFileNameGenerator, diskCacheSize,
diskCacheFileCount);
} catch (IOException e) {
L.e(e);
// continue and create unlimited cache
}
}
File cacheDir = StorageUtils.getCacheDirectory(context);
return new UnlimitedDiscCache(cacheDir, reserveCacheDir, diskCacheFileNameGenerator);
}
示例12: onCreate
import com.nostra13.universalimageloader.utils.StorageUtils; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
File cacheDir = StorageUtils.getCacheDirectory(this);
ImageLoaderConfiguration configuration = new ImageLoaderConfiguration.Builder(this)
.threadPriority(Thread.NORM_PRIORITY - 2)
.denyCacheImageMultipleSizesInMemory()
.diskCache(new UnlimitedDiscCache(cacheDir))
.diskCacheSize(50 * 1024 * 1024)
.diskCacheFileCount(100)
.diskCacheFileNameGenerator(new Md5FileNameGenerator())
.memoryCache(new LruMemoryCache(2 * 1024 * 1024))
.memoryCacheSize(2 * 1024 * 1024)
.memoryCacheSizePercentage(13)
.tasksProcessingOrder(QueueProcessingType.LIFO)
.build();
ImageLoader.getInstance().init(configuration);
}
示例13: initImageLoader
import com.nostra13.universalimageloader.utils.StorageUtils; //导入依赖的package包/类
/**
* ��ʼ��ImageLoader
*
* @param applicationContext
*/
private static void initImageLoader(Context context) {
File cacheDir = StorageUtils.getOwnCacheDirectory(context,
"bmobchat/Cache");// ��ȡ�������Ŀ¼��ַ
// ��������ImageLoader(���е�ѡ��ǿ�ѡ��,ֻʹ����Щ������붨��)����������趨��APPLACATION���棬����Ϊȫ�ֵ����ò���
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
context)
// �̳߳��ڼ��ص�����
.threadPoolSize(3).threadPriority(Thread.NORM_PRIORITY - 2)
.memoryCache(new WeakMemoryCache())
.denyCacheImageMultipleSizesInMemory()
.discCacheFileNameGenerator(new Md5FileNameGenerator())
// �������ʱ���URI������MD5 ����
.tasksProcessingOrder(QueueProcessingType.LIFO)
.discCache(new UnlimitedDiscCache(cacheDir))// �Զ��建��·��
// .defaultDisplayImageOptions(DisplayImageOptions.createSimple())
.writeDebugLogs() // Remove for release app
.build();
// Initialize ImageLoader with configuration.
ImageLoader.getInstance().init(config);// ȫ�ֳ�ʼ��������
}
示例14: initImageLoader
import com.nostra13.universalimageloader.utils.StorageUtils; //导入依赖的package包/类
/** 初始化ImageLoader */
public static void initImageLoader(Context context) {
File cacheDir = StorageUtils.getOwnCacheDirectory(context,
"bmobim/Cache");// 获取到缓存的目录地址
// 创建配置ImageLoader(所有的选项都是可选的,只使用那些你真的想定制),这个可以设定在APPLACATION里面,设置为全局的配置参数
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
context)
// 线程池内加载的数量
.threadPoolSize(3).threadPriority(Thread.NORM_PRIORITY - 2)
.memoryCache(new WeakMemoryCache())
.denyCacheImageMultipleSizesInMemory()
.discCacheFileNameGenerator(new Md5FileNameGenerator())
// 将保存的时候的URI名称用MD5 加密
.tasksProcessingOrder(QueueProcessingType.LIFO)
.discCache(new UnlimitedDiscCache(cacheDir))// 自定义缓存路径
// .defaultDisplayImageOptions(DisplayImageOptions.createSimple())
.writeDebugLogs() // Remove for release app
.build();
// Initialize ImageLoader with configuration.
ImageLoader.getInstance().init(config);// 全局初始化此配置
}
示例15: initImageLoader
import com.nostra13.universalimageloader.utils.StorageUtils; //导入依赖的package包/类
/**
* 初始化imageloader
*/
private void initImageLoader() {
File cacheDir = StorageUtils.getOwnCacheDirectory(
getApplicationContext(), "imageloader/Cache");
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
this)
.threadPoolSize(3)
// default
.threadPriority(Thread.NORM_PRIORITY - 2)
// default
.tasksProcessingOrder(QueueProcessingType.FIFO)
// default
.denyCacheImageMultipleSizesInMemory()
.memoryCache(new LruMemoryCache(2 * 1024 * 1024))
.memoryCacheSize(2 * 1024 * 1024).memoryCacheSizePercentage(13)
// default
.diskCache(new UnlimitedDiskCache(cacheDir))
// default
.diskCacheSize(50 * 1024 * 1024).diskCacheFileCount(100)
.diskCacheFileNameGenerator(new Md5FileNameGenerator()) // default
.defaultDisplayImageOptions(ImageLoaderHelper.getInstance(this).getDisplayOptions()) // default
.writeDebugLogs().build();
ImageLoader.getInstance().init(config);
}