com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory Java Examples
The following examples show how to use
com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory.
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: XGlideModule.java From XKnife-Android with Apache License 2.0 | 6 votes |
@Override public void applyOptions(Context context, GlideBuilder builder) { //设置图片解码格式 builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888); //设置内存缓存大小 int maxMemory = (int) Runtime.getRuntime().maxMemory();//获取系统分配给应用的总内存大小 int memoryCacheSize = maxMemory / 8;//设置图片内存缓存占用八分之一 builder.setMemoryCache(new LruResourceCache(memoryCacheSize)); builder.setBitmapPool(new LruBitmapPool(memoryCacheSize)); // 存放路径和缓存控件大小 int diskCacheSize = 1024 * 1024 * 30; builder.setDiskCache(new InternalCacheDiskCacheFactory(context, diskCacheName, diskCacheSize)); // data/data/xx/cache/ builder.setDiskCache(new ExternalCacheDiskCacheFactory(context, diskCacheName, diskCacheSize)); //存放在外置文件浏览器 }
Example #2
Source File: GlideConfiguration.java From GankGirl with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void applyOptions(final Context context, GlideBuilder builder) { builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888);// Bitmap格式转换到ARGB_8888 //内存缓存 MemorySizeCalculator memorySizeCalculator = new MemorySizeCalculator(context); int defaultMemoryCacheSize = memorySizeCalculator.getMemoryCacheSize(); int defalutBitmapPoolSize = memorySizeCalculator.getBitmapPoolSize(); builder.setMemoryCache(new LruResourceCache((int) (defalutBitmapPoolSize * 1.2)));//内部 builder.setBitmapPool(new LruBitmapPool((int) (defalutBitmapPoolSize * 1.2))); //磁盘缓存 builder.setDiskCache(new InternalCacheDiskCacheFactory(context, 1024 * 1024 * 10));//内部磁盘缓存 builder.setDiskCache(new ExternalCacheDiskCacheFactory(context, 10 * 1024 * 1024));//磁盘缓存到外部存储 //指定缓存目录1 String downLoadPath = Environment.getDownloadCacheDirectory().getPath(); builder.setDiskCache(new DiskLruCacheFactory(downLoadPath, defaultMemoryCacheSize)); //指定缓存目录2 builder.setDiskCache(new DiskCache.Factory() { @Override public DiskCache build() { File cacheLocation = new File(FileUtils.getCacheDir(context), "GlideCache"); return DiskLruCacheWrapper.get(cacheLocation, 1024 * 1024 * 10); } }); }
Example #3
Source File: MyGlideModule.java From Simpler with Apache License 2.0 | 6 votes |
@Override public void applyOptions(Context context, GlideBuilder builder) { ViewTarget.setTagId(R.id.glide_tag_id); // Apply options to the builder here. // 默认内存和图片池大小 // MemorySizeCalculator calculator = new MemorySizeCalculator(context); // int defaultMemoryCacheSize = calculator.getMemoryCacheSize(); // 默认内存大小 // int defaultBitmapPoolSize = calculator.getBitmapPoolSize(); // 默认图片池大小 // builder.setMemoryCache(new LruResourceCache(defaultMemoryCacheSize)); // 该两句无需设置,是默认的 // builder.setBitmapPool(new LruBitmapPool(defaultBitmapPoolSize)); //定义图片的本地磁盘缓存 // File cacheDir = context.getExternalCacheDir();//指定的是数据的缓存地址 // int diskCacheSize = 1024 * 1024 * 1024;//最多可以缓存多少字节的数据 //设置磁盘缓存大小 // builder.setDiskCache(new DiskLruCacheFactory(cacheDir.getPath(), "glide", diskCacheSize)); // 定义缓存大小和位置 if (BaseConfig.sSDCardExist) { builder.setDiskCache(new ExternalCacheDiskCacheFactory(context, Constants.Dir.IMAGE_CACHE_DIR, extDiskSize)); //外部存储 } else { builder.setDiskCache(new InternalCacheDiskCacheFactory(context, Constants.Dir.IMAGE_CACHE_DIR, intDiskSize)); //内部存储 } // 自定义内存和图片池大小 // builder.setMemoryCache(new LruResourceCache(memorySize)); // builder.setBitmapPool(new LruBitmapPool(memorySize)); // builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888); }
Example #4
Source File: GlideSetup.java From MoeGallery with GNU General Public License v3.0 | 5 votes |
@Override public void applyOptions(Context context, GlideBuilder builder) { //builder.setMemoryCache(new LruResourceCache(64 * 1024 * 1024)); //builder.setBitmapPool(new LruBitmapPool(32 * 1024 * 1024)); builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888); builder.setDiskCache(new InternalCacheDiskCacheFactory(context, 2147483647)); builder.setResizeService(new FifoPriorityThreadPoolExecutor(2)); }
Example #5
Source File: MyAppGlideModule.java From Awesome-WanAndroid with Apache License 2.0 | 5 votes |
@Override public void applyOptions(Context context, GlideBuilder builder) { builder.setDefaultRequestOptions(new RequestOptions().format(DecodeFormat.PREFER_RGB_565)); int memoryCacheSizeBytes = 1024 * 1024 * 20; builder.setMemoryCache(new LruResourceCache(memoryCacheSizeBytes)); int bitmapPoolSizeBytes = 1024 * 1024 * 30; builder.setBitmapPool(new LruBitmapPool(bitmapPoolSizeBytes)); int diskCacheSizeBytes = 1024 * 1024 * 100; builder.setDiskCache(new InternalCacheDiskCacheFactory(context, diskCacheSizeBytes)); }
Example #6
Source File: CustomCachingGlideModule.java From android-tutorials-glide with MIT License | 5 votes |
@Override public void applyOptions(Context context, GlideBuilder builder) { builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888); // memory cache MemorySizeCalculator calculator = new MemorySizeCalculator(context); int defaultMemoryCacheSize = calculator.getMemoryCacheSize(); int defaultBitmapPoolSize = calculator.getBitmapPoolSize(); int customMemoryCacheSize = (int) (1.2 * defaultMemoryCacheSize); int customBitmapPoolSize = (int) (1.2 * defaultBitmapPoolSize); builder.setMemoryCache(new LruResourceCache(customMemoryCacheSize)); builder.setBitmapPool(new LruBitmapPool(customBitmapPoolSize)); // disk cache // set size & external vs. internal int cacheSize100MegaBytes = 104857600; builder.setDiskCache( new InternalCacheDiskCacheFactory(context, cacheSize100MegaBytes)); builder.setDiskCache( new ExternalCacheDiskCacheFactory(context, cacheSize100MegaBytes)); // set custom location String downloadDirectoryPath = Environment.getDownloadCacheDirectory().getPath(); builder.setDiskCache( new DiskLruCacheFactory(downloadDirectoryPath, cacheSize100MegaBytes)); // In case you want to specify a cache folder ("glide"): //builder.setDiskCache( // new DiskLruCacheFactory( downloadDirectoryPath, "glidecache", cacheSize100MegaBytes ) ); }
Example #7
Source File: GlideConfigModule.java From ImageLoadPK with Apache License 2.0 | 5 votes |
@Override public void applyOptions(Context context, GlideBuilder builder) { // 指定位置在packageName/cache/glide_cache,大小为MAX_CACHE_DISK_SIZE的磁盘缓存 builder.setDiskCache(new InternalCacheDiskCacheFactory(context, "glide_cache", ConfigConstants.MAX_CACHE_DISK_SIZE)); //指定内存缓存大小 builder.setMemoryCache(new LruResourceCache(ConfigConstants.MAX_CACHE_MEMORY_SIZE)); //全部的内存缓存用来作为图片缓存 builder.setBitmapPool(new LruBitmapPool(ConfigConstants.MAX_CACHE_MEMORY_SIZE)); builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888);//和Picasso配置一样 }
Example #8
Source File: GlideCacheUtil.java From LLApp with Apache License 2.0 | 5 votes |
/** * 获取Glide造成的缓存大小 * * @return CacheSize */ public String getCacheSize(Context context) { try { return getFormatSize(getFolderSize(new File(context.getCacheDir() + "/" + InternalCacheDiskCacheFactory.DEFAULT_DISK_CACHE_DIR))); } catch (Exception e) { e.printStackTrace(); } return ""; }
Example #9
Source File: MyAppGlideModule.java From nativescript-image-cache-it with Apache License 2.0 | 5 votes |
@Override public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) { int diskCacheSizeBytes = 1024 * 1024 * 1000; // 1GB builder.setDiskCache(new InternalCacheDiskCacheFactory(context, diskCacheSizeBytes)); /*MemorySizeCalculator calculator = new MemorySizeCalculator.Builder(context) .setMemoryCacheScreens(4) .build(); builder.setMemoryCache(new LruResourceCache(calculator.getMemoryCacheSize())); MemorySizeCalculator bpCalculator = new MemorySizeCalculator.Builder(context) .setBitmapPoolScreens(3) .build(); builder.setBitmapPool(new LruBitmapPool(bpCalculator.getBitmapPoolSize())); */ }
Example #10
Source File: GlideCacheUtil.java From LiveGiftLayout with Apache License 2.0 | 5 votes |
/** * 获取Glide造成的缓存大小 * * @return CacheSize */ public String getCacheSize(Context context) { try { return getFormatSize(getFolderSize(new File(context.getCacheDir() + "/" + InternalCacheDiskCacheFactory.DEFAULT_DISK_CACHE_DIR))); } catch (Exception e) { e.printStackTrace(); } return ""; }
Example #11
Source File: CustomGlideModule.java From RetrofitClient with MIT License | 5 votes |
@Override public void applyOptions(Context context, GlideBuilder builder) { // MemorySizeCalculator calculator = new MemorySizeCalculator.Builder(context) // .setMemoryCacheScreens(2) // .build(); // builder.setMemoryCache(new LruResourceCache(calculator.getMemoryCacheSize())); // builder.setDiskCache(new ExternalCacheDiskCacheFactory(context)); int diskCacheSizeBytes = 1024 * 1024 * 100; // 100 MB builder.setDiskCache(new InternalCacheDiskCacheFactory(context, diskCacheSizeBytes)); // builder.setDiskCache(new InternalCacheDiskCacheFactory(context, "cacheFolderName", diskCacheSizeBytes)); }
Example #12
Source File: GlideCacheUtil.java From Cashew with Apache License 2.0 | 5 votes |
/** * 获取Glide造成的缓存大小 * * @return CacheSize */ public String getCacheSize(Context context) { try { return getFormatSize(getFolderSize(new File(context.getCacheDir() + "/" + InternalCacheDiskCacheFactory.DEFAULT_DISK_CACHE_DIR))); } catch (Exception e) { e.printStackTrace(); } return ""; }
Example #13
Source File: MyAppGlideModel.java From OpenHub with GNU General Public License v3.0 | 5 votes |
@Override public void applyOptions(Context context, GlideBuilder builder) { super.applyOptions(context, builder); builder.setDiskCache(new InternalCacheDiskCacheFactory(context, AppConfig.IMAGE_MAX_CACHE_SIZE)); RequestOptions requestOptions = RequestOptions.placeholderOf(R.mipmap.logo); builder.setDefaultRequestOptions(requestOptions); }
Example #14
Source File: MyGlideModule.java From ZoomPreviewPicture with Apache License 2.0 | 5 votes |
@Override public void applyOptions(final Context context, GlideBuilder builder) { MemorySizeCalculator calculator = new MemorySizeCalculator(context); int defaultMemoryCacheSize = calculator.getMemoryCacheSize(); int defaultBitmapPoolSize = calculator.getBitmapPoolSize(); int customMemoryCacheSize = (int) (1.2 * defaultMemoryCacheSize); int customBitmapPoolSize = (int) (1.2 * defaultBitmapPoolSize); builder.setMemoryCache(new LruResourceCache(customMemoryCacheSize)); builder.setBitmapPool(new LruBitmapPool(customBitmapPoolSize)); builder.setDiskCache(new InternalCacheDiskCacheFactory(context, cacheSize100MegaBytes)); ViewTarget.setTagId(R.id.glide_tag_id); }
Example #15
Source File: GlideModelConfig.java From Android with MIT License | 5 votes |
@Override public void applyOptions(Context context, GlideBuilder builder) { // Define cache size and location builder.setDiskCache(new InternalCacheDiskCacheFactory(context, diskSize)); //Mobile disk //builder.setDiskCache(new ExternalCacheDiskCacheFactory(context, "cache", diskSize)); //sdcard disk // The custom memory pool size and pictures builder.setMemoryCache(new LruResourceCache(memorySize)); builder.setBitmapPool(new LruBitmapPool(memorySize)); // Define the image format //builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888); builder.setDecodeFormat(DecodeFormat.PREFER_RGB_565); }
Example #16
Source File: GlideConfig.java From MVVM-JueJin with MIT License | 5 votes |
@Override public void applyOptions(Context context, GlideBuilder builder) { builder // 下面三项都是默认的, 不必设置 // .setMemoryCache(new LruResourceCache(MEMORY_CACHE_SIZE)) // .setBitmapPool(new LruBitmapPool(MEMORY_CACHE_SIZE)) // 默认 rgb565 .setDecodeFormat(DecodeFormat.PREFER_ARGB_8888) .setDiskCache(new InternalCacheDiskCacheFactory(context, DISK_CACHE_SIZE)); }
Example #17
Source File: GlideModule.java From glide-support with The Unlicense | 4 votes |
@Override public void applyOptions(Context context, GlideBuilder builder) { builder.setDiskCache(new StealingDiskCacheFactory(new InternalCacheDiskCacheFactory(context))); }
Example #18
Source File: GustomCachingGlideModule.java From Android-Tech with Apache License 2.0 | 3 votes |
@Override public void applyOptions(Context context, GlideBuilder glideBuilder) { // 自定义内存缓存 MemorySizeCalculator calculator = new MemorySizeCalculator(context); int defaultMemoryCacheSize = calculator.getMemoryCacheSize(); int defaultBitmapPoolSize = calculator.getBitmapPoolSize(); int customMemoryCacheSize = (int) (1.2 * defaultMemoryCacheSize); int customBitmapPoolSize = (int) (1.2 * defaultBitmapPoolSize); glideBuilder.setMemoryCache(new LruResourceCache(customMemoryCacheSize)); glideBuilder.setBitmapPool(new LruBitmapPool(customBitmapPoolSize)); // 自定义磁盘缓存 // set size & external vs. internal int cacheSize100MegaBytes = 104857600; glideBuilder.setDiskCache(new InternalCacheDiskCacheFactory(context, cacheSize100MegaBytes)); // glideBuilder.setDiskCache(new ExternalCacheDiskCacheFactory(context, cacheSize100MegaBytes)); // 选一个特定的存储目录 // String downloadDirectoryPath = Environment.getDownloadCacheDirectory().getPath(); // glideBuilder.setDiskCache(new DiskLruCacheFactory(downloadDirectoryPath, cacheSize100MegaBytes)); }