com.bumptech.glide.load.engine.cache.DiskLruCacheFactory Java Examples
The following examples show how to use
com.bumptech.glide.load.engine.cache.DiskLruCacheFactory.
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: DefaultGlideModule.java From star-zone-android with Apache License 2.0 | 6 votes |
@Override public void applyOptions(Context context, GlideBuilder builder) { //磁盘缓存 builder.setDiskCache(new DiskLruCacheFactory(context.getCacheDir().getAbsolutePath(), 50 * 1024 * 1024)); KLog.d("Glide", "glide cache file path >>> " + context.getCacheDir().getAbsolutePath()); //内存缓存 MemorySizeCalculator calculator = new MemorySizeCalculator.Builder(context).build(); int defaultMemoryCacheSize = calculator.getMemoryCacheSize(); int defaultBitmapPoolSize = calculator.getBitmapPoolSize(); //设置比默认大小大1.5倍的缓存和图片池大小 int customMemoryCacheSize = (int) (1.5 * defaultMemoryCacheSize); int customBitmapPoolSize = defaultBitmapPoolSize; builder.setMemoryCache(new LruResourceCache(customMemoryCacheSize)); builder.setBitmapPool(new LruBitmapPool(customBitmapPoolSize)); KLog.d("Glide", "bitmapPoolSize >>>>> " + formatFileSize(context, customBitmapPoolSize) + " / memorySize>>>>>>>> " + formatFileSize(context, customMemoryCacheSize)); builder.setLogLevel(Log.ERROR); }
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: FCGlideModules.java From FamilyChat with Apache License 2.0 | 6 votes |
@Override public void applyOptions(Context context, GlideBuilder builder) { //修改内存容量和位图缓存池大小 MemorySizeCalculator calculator = new MemorySizeCalculator(context); int defaultMemoryCacheSize = calculator.getMemoryCacheSize(); int defaultBitmapPoolSize = calculator.getBitmapPoolSize(); int customMemoryCacheSize = (int) (MEMORY_CACHE_COUNT * defaultMemoryCacheSize); int customBitmapPoolSize = (int) (MEMORY_CACHE_COUNT * defaultBitmapPoolSize); builder.setMemoryCache(new LruResourceCache(customMemoryCacheSize)); builder.setBitmapPool(new LruBitmapPool(customBitmapPoolSize)); //设置磁盘缓存 String diskCachePath = FCCache.getInstance().getImageCachePath(); int cacheSize = 0; long availableSize = SdUtils.getAvailableExternalMemorySize(); if (availableSize < MAX_DISK_CACHE_SIZE) cacheSize = (int) availableSize; else cacheSize = MAX_DISK_CACHE_SIZE; builder.setDiskCache(new DiskLruCacheFactory(diskCachePath, cacheSize)); }
Example #4
Source File: QtalkGlideModule.java From imsdk-android with MIT License | 5 votes |
@Override public void applyOptions(Context context, GlideBuilder builder) { final String dir = "/files/glide"; int diskCacheSize = 1024 * 1024 * 1024;//最多可以缓存多少字节的数据 // builder.setDiskCache(new ExternalCacheDiskCacheFactory(context, dir, diskCacheSize)); builder.setDiskCache(new DiskLruCacheFactory(new DiskLruCacheFactory.CacheDirectoryGetter() { @Override public File getCacheDirectory() { return new File(MyDiskCache.getDirectory().getAbsolutePath() + "/files/glide"); } }, diskCacheSize)); }
Example #5
Source File: OkHttpGlideModule.java From AndroidBase with Apache License 2.0 | 5 votes |
@Override public void applyOptions(Context context, GlideBuilder builder) { // int deskacheize = 1024 * 1024 * 30; int maxMemory = (int)Runtime.getRuntime().maxMemory(); int memoryCheSize = maxMemory / 8; // builder.setDiskCache(new InternalCacheDiskCacheFactory(context, "glide", deskacheize)); builder.setDiskCache(new DiskLruCacheFactory(FileUtil.getCacheDir(),"glide", DiskCache.Factory.DEFAULT_DISK_CACHE_SIZE)); builder.setMemoryCache(new LruResourceCache(memoryCheSize)); builder.setBitmapPool(new LruBitmapPool(memoryCheSize)); builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888); }
Example #6
Source File: VideoListGlideModule.java From VideoListPlayer with MIT License | 5 votes |
@Override public void applyOptions(final Context context, GlideBuilder builder) { ViewTarget.setTagId(R.id.glide_loader); builder.setDiskCache(new DiskLruCacheFactory(new DiskLruCacheFactory.CacheDirectoryGetter () { @Override public File getCacheDirectory() { return context.getExternalCacheDir(); } }, DiskCache.Factory.DEFAULT_DISK_CACHE_SIZE)); }
Example #7
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 #8
Source File: ExploreGlideModule.java From WanAndroid with MIT License | 4 votes |
@Override public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) { builder.setDiskCache(new DiskLruCacheFactory(fileName, diskSize)) .setMemoryCache(new LruResourceCache(memorySize)) .setDefaultRequestOptions(new RequestOptions().format(DecodeFormat.PREFER_RGB_565)); }
Example #9
Source File: MyAppGlideModule.java From v9porn with MIT License | 4 votes |
@Override public void applyOptions(@NonNull Context context, GlideBuilder builder) { int diskCacheSizeBytes = 1024 * 1024 * 250; builder.setDiskCache(new DiskLruCacheFactory(AppCacheUtils.getGlideDiskCacheDir(context).getAbsolutePath(), diskCacheSizeBytes)); }
Example #10
Source File: MyAppGlideModule.java From v9porn with MIT License | 4 votes |
@Override public void applyOptions(@NonNull Context context, GlideBuilder builder) { int diskCacheSizeBytes = 1024 * 1024 * 250; builder.setDiskCache(new DiskLruCacheFactory(AppCacheUtils.getGlideDiskCacheDir(context).getAbsolutePath(), diskCacheSizeBytes)); }
Example #11
Source File: Glide.java From giffun with Apache License 2.0 | 2 votes |
/** * Returns a directory with a default name in the private cache directory of the application to use to store * retrieved media and thumbnails. * * @see #getPhotoCacheDir(Context, String) * * @param context A context. */ public static File getPhotoCacheDir(Context context) { return getPhotoCacheDir(context, DiskLruCacheFactory.DEFAULT_DISK_CACHE_DIR); }