com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiscCache Java Examples
The following examples show how to use
com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiscCache.
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: AndroidUniversalImageLoaderSampleApplication.java From android-opensource-library-56 with Apache License 2.0 | 6 votes |
@Override public void onCreate() { super.onCreate(); ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder( getApplicationContext()) .threadPoolSize(3) .memoryCache(new LruMemoryCache(2 * 1024 * 1024)) .memoryCacheSize(2 * 1024 * 1024) .discCache( new UnlimitedDiscCache(StorageUtils .getCacheDirectory(getApplicationContext()))) .build(); ImageLoader.getInstance().init(config); }
Example #2
Source File: MainApplication.java From android-imageviewer with Apache License 2.0 | 6 votes |
public static void initImageLoader(Context context) { File cacheDir = StorageUtils.getCacheDirectory(context); ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context) .memoryCacheExtraOptions(480, 800) // default = device screen dimensions .denyCacheImageMultipleSizesInMemory() .discCacheExtraOptions(480, 800, Bitmap.CompressFormat.JPEG, 75, 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 .discCache(new UnlimitedDiscCache(cacheDir)) // default .discCacheSize(50 * 1024 * 1024) .discCacheFileCount(100) .discCacheFileNameGenerator(new HashCodeFileNameGenerator()) // default .imageDownloader(new BaseImageDownloader(context)) // default .imageDecoder(new BaseImageDecoder(true)) // default .defaultDisplayImageOptions(DisplayImageOptions.createSimple()) // default .writeDebugLogs() .build(); ImageLoader.getInstance().init(config); }
Example #3
Source File: HuxianApplication.java From android-open-project-demo with Apache License 2.0 | 6 votes |
@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); }
Example #4
Source File: DefaultConfigurationFactory.java From mobile-manager-tool with MIT License | 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 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); }
Example #5
Source File: DefaultConfigurationFactory.java From android-open-project-demo 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 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); }
Example #6
Source File: CustomGalleryActivity.java From MultipleImagePicker with Apache License 2.0 | 6 votes |
private void initImageLoader() { try { String CACHE_DIR = Environment.getExternalStorageDirectory() .getAbsolutePath() + "/.temp_tmp"; new File(CACHE_DIR).mkdirs(); File cacheDir = StorageUtils.getOwnCacheDirectory(getBaseContext(), CACHE_DIR); DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder() .cacheOnDisc(true).imageScaleType(ImageScaleType.EXACTLY) .bitmapConfig(Bitmap.Config.RGB_565).build(); ImageLoaderConfiguration.Builder builder = new ImageLoaderConfiguration.Builder( getBaseContext()) .defaultDisplayImageOptions(defaultOptions) .discCache(new UnlimitedDiscCache(cacheDir)) .memoryCache(new WeakMemoryCache()); ImageLoaderConfiguration config = builder.build(); imageLoader = ImageLoader.getInstance(); imageLoader.init(config); } catch (Exception e) { } }
Example #7
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 #8
Source File: GlobalConfig.java From light-novel-library_Wenku8_Android with GNU General Public License v2.0 | 6 votes |
public static void initImageLoader(Context context) { UnlimitedDiscCache localUnlimitedDiscCache = new UnlimitedDiscCache( new File(GlobalConfig.getFirstStoragePath() + "cache"), new File(context.getCacheDir() + File.separator + "imgs")); DisplayImageOptions localDisplayImageOptions = new DisplayImageOptions.Builder() .resetViewBeforeLoading(true) .cacheOnDisk(true) .cacheInMemory(true) .bitmapConfig(Bitmap.Config.RGB_565) .resetViewBeforeLoading(true) .displayer(new FadeInBitmapDisplayer(250)).build(); ImageLoaderConfiguration localImageLoaderConfiguration = new ImageLoaderConfiguration.Builder(context) .diskCache(localUnlimitedDiscCache) .defaultDisplayImageOptions(localDisplayImageOptions).build(); ImageLoader.getInstance().init(localImageLoaderConfiguration); }
Example #9
Source File: Application.java From v2ex-daily-android with Apache License 2.0 | 6 votes |
private void initiImageLoader() { DisplayImageOptions options = new DisplayImageOptions.Builder() .bitmapConfig(Bitmap.Config.RGB_565) .imageScaleType(ImageScaleType.EXACTLY) .cacheOnDisc(true) .displayer(new FadeInBitmapDisplayer(200)) .showImageOnLoading(R.drawable.ic_launcher) .build(); File cacheDir; if(Environment.getExternalStorageState() == Environment.MEDIA_MOUNTED){ cacheDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES); }else{ cacheDir = getCacheDir(); } ImageLoaderConfiguration.Builder configBuilder = new ImageLoaderConfiguration.Builder(mContext) .threadPoolSize(2) .memoryCache(new WeakMemoryCache()) .denyCacheImageMultipleSizesInMemory() .discCache(new UnlimitedDiscCache(cacheDir)) .defaultDisplayImageOptions(options); if(BuildConfig.DEBUG){ configBuilder.writeDebugLogs(); } ImageLoader.getInstance().init(configBuilder.build()); }
Example #10
Source File: App.java From RecyclerView-Animation-Demo with Apache License 2.0 | 6 votes |
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 UnlimitedDiscCache(StorageUtils.getOwnCacheDirectory(this, Environment.getExternalStorageDirectory() + "/sky"))) .diskCacheSize(100 * 1024 * 1024).tasksProcessingOrder(QueueProcessingType.LIFO) .memoryCache(new LruMemoryCache(2 * 1024 * 1024)).memoryCacheSize(2 * 1024 * 1024) .threadPoolSize(3) .build(); ImageLoader.getInstance().init(config); }
Example #11
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 #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: 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 #14
Source File: FromURLActivity.java From KenBurnsView with Apache License 2.0 | 5 votes |
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); }
Example #15
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 #16
Source File: ImageLoaderConfig.java From fitness_Android with Apache License 2.0 | 5 votes |
/** * 异步图片加载ImageLoader的初始化操作,在Application中调用此方法 * * @param context * 上下文对象 * @param cacheDisc * 图片缓存到SDCard的目录,只需要传入SDCard根目录下的子目录即可,默认会建立在SDcard的根目录下 */ public static void initImageLoader(Context context, String cacheDisc) { // 配置ImageLoader // 获取本地缓存的目录,该目录在SDCard的根目录下 File cacheDir = StorageUtils.getOwnCacheDirectory(context, cacheDisc); // 实例化Builder ImageLoaderConfiguration.Builder builder = new ImageLoaderConfiguration.Builder( context); // 设置线程数量 builder.threadPoolSize(3); // 设定线程等级比普通低一点 builder.threadPriority(Thread.NORM_PRIORITY); // 设定内存缓存为弱缓存 builder.memoryCache(new WeakMemoryCache()); // 设定内存图片缓存大小限制,不设置默认为屏幕的宽高 builder.memoryCacheExtraOptions(480, 800); // 设定只保存同一尺寸的图片在内存 builder.denyCacheImageMultipleSizesInMemory(); // 设定缓存的SDcard目录,UnlimitDiscCache速度最快 builder.discCache(new UnlimitedDiscCache(cacheDir)); // 设定缓存到SDCard目录的文件命名 builder.discCacheFileNameGenerator(new HashCodeFileNameGenerator()); // 设定网络连接超时 timeout: 10s 读取网络连接超时read timeout: 60s builder.imageDownloader(new BaseImageDownloader(context, 10000, 60000)); // 设置ImageLoader的配置参数 builder.defaultDisplayImageOptions(initDisplayOptions(true)); // 初始化ImageLoader ImageLoader.getInstance().init(builder.build()); }
Example #17
Source File: BraceletImageLoader.java From MiBandDecompiled with Apache License 2.0 | 5 votes |
private void a(Context context) { File file = new File(((BraceletApp)context).getStoragePath()); com.nostra13.universalimageloader.core.ImageLoaderConfiguration imageloaderconfiguration = (new com.nostra13.universalimageloader.core.ImageLoaderConfiguration.Builder(context)).threadPriority(5).denyCacheImageMultipleSizesInMemory().discCacheFileNameGenerator(new Md5FileNameGenerator()).tasksProcessingOrder(QueueProcessingType.LIFO).memoryCache(new LruMemoryCache(0x400000)).memoryCacheSize(0x400000).discCache(new UnlimitedDiscCache(file)).discCacheSize(0x3200000).discCacheFileCount(1000).writeDebugLogs().build(); b = ImageLoader.getInstance(); b.init(imageloaderconfiguration); a = (new com.nostra13.universalimageloader.core.DisplayImageOptions.Builder()).cacheInMemory(true).cacheOnDisc(true).build(); }
Example #18
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 #19
Source File: PhotoUtil.java From LoveTalkClient with Apache License 2.0 | 5 votes |
public static ImageLoaderConfiguration getImageLoaderConfig(Context context, File cacheDir) { return 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(); }
Example #20
Source File: ImageLoaderHelper.java From SimplifyReader with Apache License 2.0 | 5 votes |
public ImageLoaderConfiguration getImageLoaderConfiguration(String filePath) { File cacheDir = null; if (!CommonUtils.isEmpty(filePath)) { cacheDir = StorageUtils.getOwnCacheDirectory(mContext, filePath); } else { cacheDir = StorageUtils.getCacheDirectory(mContext); } ImageLoaderConfiguration.Builder builder = new ImageLoaderConfiguration.Builder(mContext); builder.denyCacheImageMultipleSizesInMemory(); builder.diskCacheSize(512 * 1024 * 1024); builder.diskCacheExtraOptions(720, 1280, null); builder.diskCache(new UnlimitedDiscCache(cacheDir)); builder.diskCacheFileNameGenerator(new Md5FileNameGenerator()); builder.memoryCacheSizePercentage(14); builder.memoryCacheSize(2 * 1024 * 1024); builder.memoryCacheExtraOptions(720, 1280); builder.memoryCache(new WeakMemoryCache()); builder.threadPoolSize(3); builder.threadPriority(Thread.NORM_PRIORITY - 2); builder.defaultDisplayImageOptions(getDisplayOptions()); return builder.build(); }
Example #21
Source File: Aptoide.java From aptoide-client with GNU General Public License v2.0 | 5 votes |
/** * Inits nostra13's ImageLoader */ private void initImageLoader() { DisplayImageOptions options = new DisplayImageOptions.Builder() .cacheInMemory(true) .cacheOnDisc(true) .resetViewBeforeLoading(true) .showStubImage(R.drawable.icon_non_available) .build(); FileNameGenerator generator = new FileNameGenerator() { @Override public String generate(String s) { if(s!=null){ return s.substring(s.lastIndexOf('/') + 1); } else { return null; } } }; ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext()) .discCache(new UnlimitedDiscCache(new File(getConfiguration().getPathCacheIcons()), null, generator)) .imageDownloader(new ImageDownloaderWithPermissions(getContext())) .defaultDisplayImageOptions(options) .build(); ImageLoader.getInstance().init(config); }
Example #22
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 #23
Source File: DefaultConfigurationFactory.java From letv with Apache License 2.0 | 5 votes |
public static DiskCache createDiskCache(Context context, FileNameGenerator diskCacheFileNameGenerator, long diskCacheSize, int diskCacheFileCount) { File reserveCacheDir = createReserveDiskCacheDir(context); if (diskCacheSize > 0 || diskCacheFileCount > 0) { try { return new LruDiscCache(StorageUtils.getIndividualCacheDirectory(context), reserveCacheDir, diskCacheFileNameGenerator, diskCacheSize, diskCacheFileCount); } catch (IOException e) { L.e(e); } } return new UnlimitedDiscCache(StorageUtils.getCacheDirectory(context), reserveCacheDir, diskCacheFileNameGenerator); }
Example #24
Source File: MainActivity.java From light-novel-library_Wenku8_Android with GNU General Public License v2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_main); // ImageLoader Configuration (ImageLoaderConfiguration) is global for // application. Display Options (DisplayImageOptions) are local for // every display. // task (ImageLoader.displayImage(...)). // Environment.getExternalStorageState() // can test SDcard exist Log.v("MewX", "dir0: " + Environment.getExternalStorageDirectory() + File.separator + "wenku8" + File.separator + "imgs"); Log.v("MewX", "dir1: " + getCacheDir() + File.separator + "imgs"); Log.v("MewX", "dir2: " + getFilesDir() + File.separator + "imgs"); LightCache.saveFile(GlobalConfig.getFirstStoragePath() + "imgs", ".nomedia", "".getBytes(), false); LightCache.saveFile(GlobalConfig.getSecondStoragePath() + "imgs", ".nomedia", "".getBytes(), false); // umeng MobclickAgent.updateOnlineConfig(this); AnalyticsConfig.enableEncrypt(false); // first: Environment.getExternalStorageDirectory(); then getCacheDir() UnlimitedDiscCache localUnlimitedDiscCache = new UnlimitedDiscCache( new File(GlobalConfig.getFirstStoragePath() + "cache"), new File(getCacheDir() + File.separator + "imgs")); DisplayImageOptions localDisplayImageOptions = new DisplayImageOptions.Builder() .resetViewBeforeLoading(true).cacheOnDisk(true) .cacheInMemory(true).bitmapConfig(Bitmap.Config.RGB_565) .resetViewBeforeLoading(true) .displayer(new FadeInBitmapDisplayer(250)).build(); ImageLoaderConfiguration localImageLoaderConfiguration = new ImageLoaderConfiguration.Builder( this).diskCache(localUnlimitedDiscCache) .defaultDisplayImageOptions(localDisplayImageOptions).build(); ImageLoader.getInstance().init(localImageLoaderConfiguration); // create menu items; setUpMenu(); if (savedInstanceState == null) { changeFragment(new LibraryFragment()); currentViewItemSave = itemLibrary; } return; }
Example #25
Source File: MainActivity.java From light-novel-library_Wenku8_Android with GNU General Public License v2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_main); // ImageLoader Configuration (ImageLoaderConfiguration) is global for // application. Display Options (DisplayImageOptions) are local for // every display. // task (ImageLoader.displayImage(...)). // Environment.getExternalStorageState() // can test SDcard exist Log.v("MewX", "dir0: " + Environment.getExternalStorageDirectory() + File.separator + "wenku8" + File.separator + "imgs"); Log.v("MewX", "dir1: " + getCacheDir() + File.separator + "imgs"); Log.v("MewX", "dir2: " + getFilesDir() + File.separator + "imgs"); LightCache.saveFile(GlobalConfig.getFirstStoragePath() + "imgs", ".nomedia", "".getBytes(), false); LightCache.saveFile(GlobalConfig.getSecondStoragePath() + "imgs", ".nomedia", "".getBytes(), false); // first: Environment.getExternalStorageDirectory(); then getCacheDir() UnlimitedDiscCache localUnlimitedDiscCache = new UnlimitedDiscCache( new File(GlobalConfig.getFirstStoragePath() + "cache"), new File(getCacheDir() + File.separator + "imgs")); DisplayImageOptions localDisplayImageOptions = new DisplayImageOptions.Builder() .resetViewBeforeLoading(true).cacheOnDisk(true) .cacheInMemory(true).bitmapConfig(Bitmap.Config.RGB_565) .resetViewBeforeLoading(true) .displayer(new FadeInBitmapDisplayer(250)).build(); ImageLoaderConfiguration localImageLoaderConfiguration = new ImageLoaderConfiguration.Builder( this).diskCache(localUnlimitedDiscCache) .defaultDisplayImageOptions(localDisplayImageOptions).build(); ImageLoader.getInstance().init(localImageLoaderConfiguration); // create menu items; setUpMenu(); if (savedInstanceState == null) { changeFragment(new LibraryFragment()); currentViewItemSave = itemLibrary; } return; }
Example #26
Source File: MYApplication.java From FanXin-based-HuanXin with GNU General Public License v2.0 | 4 votes |
@SuppressWarnings("deprecation") public void initImage() { DisplayImageOptions options = new DisplayImageOptions.Builder() .showStubImage(R.drawable.ic_stub) // 设置图片下载期间显示的图�? .showImageForEmptyUri(R.drawable.ic_empty) // 设置图片Uri为空或是错误的时候显示的图片 .showImageOnFail(R.drawable.ic_error) // 设置图片加载或解码过程中发生错误显示的图�? .bitmapConfig(Bitmap.Config.RGB_565) .imageScaleType(ImageScaleType.EXACTLY_STRETCHED) .cacheInMemory(true) // 设置下载的图片是否缓存在内存�? .cacheOnDisc(true) // 设置下载的图片是否缓存在SD卡中 // .displayer(new RoundedBitmapDisplayer(20)) // 设置成圆角图 .build(); // 创建配置过得DisplayImageOption对象 File cacheDir = StorageUtils.getCacheDirectory(getApplicationContext()); ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder( getApplicationContext()) .memoryCacheExtraOptions(480, 800) // max width, 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) .discCacheSize(50 * 1024 * 1024) .discCacheFileNameGenerator(new Md5FileNameGenerator()) // 将保存的时候的URI名称用MD5 加密 .tasksProcessingOrder(QueueProcessingType.LIFO) .discCacheFileCount(100) // 缓存的文件数量 .discCache(new UnlimitedDiscCache(cacheDir))// 自定义缓存路径 .defaultDisplayImageOptions(DisplayImageOptions.createSimple()) .imageDownloader( new BaseImageDownloader(getApplicationContext(), 5 * 1000, 30 * 1000)) // connectTimeout (5 s), // readTimeout (30 // s)超时时间 .writeDebugLogs() // Remove for release app .build();// 开始构建 ImageLoader.getInstance().init(config); }
Example #27
Source File: LetvCacheConfiguration.java From letv with Apache License 2.0 | 4 votes |
public static DiskCache getDiscCache() { return new UnlimitedDiscCache(new File(ConstantTool.IMAGE_CACHE_PATH), null, new Md5FileNameGenerator()); }