Java Code Examples for com.nostra13.universalimageloader.utils.StorageUtils#getCacheDirectory()
The following examples show how to use
com.nostra13.universalimageloader.utils.StorageUtils#getCacheDirectory() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultConfigurationFactory.java From Android-Universal-Image-Loader-Modify with Apache License 2.0 | 6 votes |
/** * 默认图片 本地路径缓存 * 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); }
Example 2
Source File: MainApplication.java From snowdream-books-android with Apache License 2.0 | 6 votes |
private void initImageLoader(){ Context context = getApplicationContext(); File cacheDir = StorageUtils.getCacheDirectory(context); ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context) .memoryCacheExtraOptions(480, 800) // default = device screen dimensions .diskCacheExtraOptions(480, 800, null) .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 UnlimitedDiscCache(cacheDir)) // default .diskCacheSize(50 * 1024 * 1024) .diskCacheFileCount(100) .diskCacheFileNameGenerator(new HashCodeFileNameGenerator()) // default .imageDownloader(new BaseImageDownloader(context)) // default .imageDecoder(new BaseImageDecoder(false)) // default .defaultDisplayImageOptions(DisplayImageOptions.createSimple()) // default // .writeDebugLogs() .build(); ImageLoader.getInstance().init(config); }
Example 3
Source File: UniversalImageLoader.java From UltimateAndroid with Apache License 2.0 | 6 votes |
public static ImageLoaderConfiguration.Builder getDefaultImageLoaderConfigurationBuilder(Context context) { File cacheDir = StorageUtils.getCacheDirectory(context); ImageLoaderConfiguration.Builder builder = new ImageLoaderConfiguration.Builder(context) // .memoryCacheExtraOptions(480, 800) // default = device screen dimensions // .discCacheExtraOptions(480, 800, Bitmap.CompressFormat.JPEG, 75, null) .threadPoolSize(3) // default .threadPriority(Thread.NORM_PRIORITY - 1) // default .tasksProcessingOrder(QueueProcessingType.FIFO) // default .denyCacheImageMultipleSizesInMemory() // .memoryCache(new LruMemoryCache(2 * 1024 * 1024)) // .memoryCacheSize(2 * 1024 * 1024) .memoryCacheSizePercentage(13) // default .discCache(new UnlimitedDiscCache(cacheDir)) // default // .discCacheSize(50 * 1024 * 1024) .discCacheFileCount(1000) .discCacheFileNameGenerator(new HashCodeFileNameGenerator()) // default .imageDownloader(new BaseImageDownloader(context)) // default .imageDecoder(new BaseImageDecoder(false)) // default // .defaultDisplayImageOptions(DisplayImageOptions.createSimple()) // default .defaultDisplayImageOptions(getDefaultImageOptions()); return builder; }
Example 4
Source File: DefaultConfigurationFactory.java From candybar with Apache License 2.0 | 6 votes |
/** * 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); }
Example 5
Source File: UniversalImageLoader.java From UltimateAndroid with Apache License 2.0 | 6 votes |
/** * Get default ImageLoaderConfiguration.Builder,and you can easily change the builder. * @param context * @return */ public static ImageLoaderConfiguration.Builder getDefaultImageLoaderConfigurationBuilder(Context context) { File cacheDir = StorageUtils.getCacheDirectory(context); ImageLoaderConfiguration.Builder builder = new ImageLoaderConfiguration.Builder(context) // .memoryCacheExtraOptions(480, 800) // default = device screen dimensions // .discCacheExtraOptions(480, 800, Bitmap.CompressFormat.JPEG, 75, null) .threadPoolSize(3) // default .threadPriority(Thread.NORM_PRIORITY - 1) // default .tasksProcessingOrder(QueueProcessingType.FIFO) // default .denyCacheImageMultipleSizesInMemory() // .memoryCache(new LruMemoryCache(2 * 1024 * 1024)) // .memoryCacheSize(2 * 1024 * 1024) .memoryCacheSizePercentage(13) // default .diskCache(new UnlimitedDiskCache(cacheDir)) // default // .discCacheSize(50 * 1024 * 1024) .diskCacheFileCount(1000) .diskCacheFileNameGenerator(new HashCodeFileNameGenerator()) // default .imageDownloader(new BaseImageDownloader(context)) // default .imageDecoder(new BaseImageDecoder(false)) // default // .defaultDisplayImageOptions(DisplayImageOptions.createSimple()) // default .defaultDisplayImageOptions(getDefaultImageOptions()); return builder; }
Example 6
Source File: SdCacheTools.java From BigApp_WordPress_Android with Apache License 2.0 | 5 votes |
public static File getOwnImageCacheDir(Context context) { File imageCache = StorageUtils.getCacheDirectory(context, "WP/images", true); if (!imageCache.exists()) { imageCache.mkdirs(); } return imageCache; }
Example 7
Source File: AppApplication.java From AndroidAppCodeFramework with Apache License 2.0 | 5 votes |
@Override public void onCreate() { super.onCreate(); File cacheDir = StorageUtils.getCacheDirectory(this); ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext()) .discCacheExtraOptions(720, 1024, Bitmap.CompressFormat.PNG, 100, null) .discCache(new UnlimitedDiscCache(cacheDir)) .discCacheSize(50 * 1024 * 1024) .discCacheFileCount(100) .build(); ImageLoader.getInstance().init(config); }
Example 8
Source File: DefaultConfigurationFactory.java From MiBandDecompiled with Apache License 2.0 | 5 votes |
public static DiskCache createDiskCache(Context context, FileNameGenerator filenamegenerator, long l, int i) { File file = a(context); if (l > 0L || i > 0) { LruDiscCache lrudisccache = new LruDiscCache(StorageUtils.getIndividualCacheDirectory(context), filenamegenerator, l, i); lrudisccache.setReserveCacheDir(file); return lrudisccache; } else { return new UnlimitedDiscCache(StorageUtils.getCacheDirectory(context), file, filenamegenerator); } }
Example 9
Source File: DefaultConfigurationFactory.java From MiBandDecompiled with Apache License 2.0 | 5 votes |
private static File a(Context context) { File file = StorageUtils.getCacheDirectory(context, false); File file1 = new File(file, "uil-images"); if (file1.exists() || file1.mkdir()) { file = file1; } return file; }
Example 10
Source File: MediaStoreUtils.java From BigApp_WordPress_Android with Apache License 2.0 | 5 votes |
public static File getTempCacheDir(Context context) { File temp = new File(StorageUtils.getCacheDirectory(context, true), "temp"); if (!temp.exists()) { temp.mkdirs(); } return temp; }
Example 11
Source File: SdCacheTools.java From BigApp_WordPress_Android with Apache License 2.0 | 5 votes |
public static File getOwnInnerFileCacheDir(Context context) { File imageCache = StorageUtils.getCacheDirectory(context, "WP/files", false); if (!imageCache.exists()) { imageCache.mkdirs(); } return imageCache; }
Example 12
Source File: AppApplication.java From AndroidAppCodeFramework with Apache License 2.0 | 5 votes |
@Override public void onCreate() { super.onCreate(); File cacheDir = StorageUtils.getCacheDirectory(this); ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext()) .discCacheExtraOptions(720, 1024, Bitmap.CompressFormat.PNG, 100, null) .discCache(new UnlimitedDiscCache(cacheDir)) .discCacheSize(50 * 1024 * 1024) .discCacheFileCount(100) .build(); ImageLoader.getInstance().init(config); }
Example 13
Source File: SdCacheTools.java From BigApp_WordPress_Android with Apache License 2.0 | 5 votes |
public static File getOwnFileCacheDir(Context context) { File imageCache = StorageUtils.getCacheDirectory(context, "WP/files", true); if (!imageCache.exists()) { imageCache.mkdirs(); } return imageCache; }
Example 14
Source File: DefaultConfigurationFactory.java From BigApp_WordPress_Android with Apache License 2.0 | 5 votes |
/** Creates reserve disk cache folder which will be used if primary disk cache folder becomes unavailable */ private static File createReserveDiskCacheDir(Context context) { File cacheDir = StorageUtils.getCacheDirectory(context, false); File individualDir = new File(cacheDir, "uil-images"); if (individualDir.exists() || individualDir.mkdir()) { cacheDir = individualDir; } return cacheDir; }
Example 15
Source File: DefaultConfigurationFactory.java From android-open-project-demo with Apache License 2.0 | 5 votes |
/** Creates reserve disk cache folder which will be used if primary disk cache folder becomes unavailable */ private static File createReserveDiskCacheDir(Context context) { File cacheDir = StorageUtils.getCacheDirectory(context, false); File individualDir = new File(cacheDir, "uil-images"); if (individualDir.exists() || individualDir.mkdir()) { cacheDir = individualDir; } return cacheDir; }
Example 16
Source File: DefaultConfigurationFactory.java From mobile-manager-tool with MIT License | 5 votes |
/** Creates reserve disk cache folder which will be used if primary disk cache folder becomes unavailable */ private static File createReserveDiskCacheDir(Context context) { File cacheDir = StorageUtils.getCacheDirectory(context, false); File individualDir = new File(cacheDir, "uil-images"); if (individualDir.exists() || individualDir.mkdir()) { cacheDir = individualDir; } return cacheDir; }
Example 17
Source File: MyApplication.java From zhangshangwuda with Apache License 2.0 | 5 votes |
private void initImageLoader() { DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder() .cacheInMemory(true).cacheOnDisc(true).build(); File cacheDir = StorageUtils.getCacheDirectory(this); File cacheImg = new File(cacheDir, "IMG"); ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder( getApplicationContext()) .defaultDisplayImageOptions(defaultOptions) .discCache(new UnlimitedDiscCache(cacheImg)) .discCacheSize(30 * 1024 * 1024) // .writeDebugLogs() .build(); mImageLoader = ImageLoader.getInstance(); mImageLoader.init(config); }
Example 18
Source File: ImageLoaderUtil.java From sctalk with Apache License 2.0 | 5 votes |
public static void initImageLoaderConfig(Context context) { try { File cacheDir = StorageUtils.getOwnCacheDirectory(context, CommonUtil.getSavePath(SysConstant.FILE_SAVE_TYPE_IMAGE)); File reserveCacheDir = StorageUtils.getCacheDirectory(context); int maxMemory = (int) (Runtime.getRuntime().maxMemory() ); // 使用最大可用内存值的1/8作为缓存的大小。 int cacheSize = maxMemory/8; DisplayMetrics metrics=new DisplayMetrics(); WindowManager mWm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE); mWm.getDefaultDisplay().getMetrics(metrics); IMImageLoaderConfig = new ImageLoaderConfiguration.Builder(context) .memoryCacheExtraOptions(metrics.widthPixels, metrics.heightPixels) .threadPriority(Thread.NORM_PRIORITY-2) // .denyCacheImageMultipleSizesInMemory() .memoryCache(new UsingFreqLimitedMemoryCache(cacheSize)) .diskCacheFileNameGenerator(new Md5FileNameGenerator()) .tasksProcessingOrder(QueueProcessingType.LIFO) .diskCacheExtraOptions(metrics.widthPixels, metrics.heightPixels, null) .diskCache(new UnlimitedDiscCache(cacheDir,reserveCacheDir,new Md5FileNameGenerator())) .diskCacheSize(1024 * 1024 * 1024) .diskCacheFileCount(1000) .build(); IMImageLoadInstance = ImageLoader.getInstance(); IMImageLoadInstance.init(IMImageLoaderConfig); }catch (Exception e){ logger.e(e.toString()); } }
Example 19
Source File: DefaultConfigurationFactory.java From letv with Apache License 2.0 | 5 votes |
private static File createReserveDiskCacheDir(Context context) { File cacheDir = StorageUtils.getCacheDirectory(context, false); File individualDir = new File(cacheDir, "uil-images"); if (individualDir.exists() || individualDir.mkdir()) { return individualDir; } return cacheDir; }
Example 20
Source File: DefaultConfigurationFactory.java From candybar with Apache License 2.0 | 5 votes |
/** * Creates reserve disk cache folder which will be used if primary disk cache folder becomes unavailable */ private static File createReserveDiskCacheDir(Context context) { File cacheDir = StorageUtils.getCacheDirectory(context, false); File individualDir = new File(cacheDir, "uil-images"); if (individualDir.exists() || individualDir.mkdir()) { cacheDir = individualDir; } return cacheDir; }