Java 类com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory 实例源码

项目:moebooru-android    文件:MoeGlideModule.java   
@Override
    public void applyOptions(Context context, GlideBuilder builder) {
        MemorySizeCalculator calculator = new MemorySizeCalculator.Builder(context)
                .setMemoryCacheScreens(2)
                .build();
        // default
//        builder.setMemoryCache(new LruResourceCache(calculator.getMemoryCacheSize()));
        Integer m = new SharedPreferencesUtils().getIntValue(mPref, mCacheMemory);
        if (m == 0){
            m = 256;
        }
        int memoryCacheSizeBytes = 1024 * 1024 * m;
        builder.setMemoryCache(new LruResourceCache(memoryCacheSizeBytes));

        Integer d = new SharedPreferencesUtils().getIntValue(mPref, mCacheDisk);
        if (d == 0){
            d = 256;
        }
        int diskCacheSizeBytes = 1024 * 1024 * d;
        builder.setDiskCache(new InternalCacheDiskCacheFactory(context, diskCacheSizeBytes));
        builder.setDefaultRequestOptions(
                new RequestOptions()
                        .diskCacheStrategy(DiskCacheStrategy.ALL));

    }
项目:GeekZone    文件:GlideConfiguration.java   
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
public void applyOptions(Context context, GlideBuilder builder) {
    MemorySizeCalculator calculator = new MemorySizeCalculator(context);
    // Get default memory cache size
    int defaultMemoryCacheSize = calculator.getMemoryCacheSize();
    int defaultBitmapPoolSize = calculator.getBitmapPoolSize();
    // Set custom memory cache size
    int customMemoryCacheSize = (int) (1.5 * defaultMemoryCacheSize);
    int customBitmapPoolSize = (int) (1.5 * defaultBitmapPoolSize);
    builder.setMemoryCache(new LruResourceCache(customMemoryCacheSize));
    builder.setBitmapPool(new LruBitmapPool(customBitmapPoolSize));

    // Set disk cache size
    int diskCacheSize = 1024 * 1024 * 100;
    builder.setDiskCache(new InternalCacheDiskCacheFactory(context, "glide", diskCacheSize));

    // Prefer higher quality images unless we're on a low RAM device
    ActivityManager activityManager = (ActivityManager) context
            .getSystemService(Context.ACTIVITY_SERVICE);
    builder.setDecodeFormat(activityManager.isLowRamDevice() ?
            DecodeFormat.PREFER_RGB_565 : DecodeFormat.PREFER_ARGB_8888);
}
项目:Simpler    文件:MyGlideModule.java   
@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);
    }
项目:ImageSwitcher    文件:CustomGlideModule.java   
@Override
public void applyOptions(Context context, GlideBuilder builder) {
    // 设置格式
    builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888);
    // 缓存到data目录下最大50M
    // 缓存目录为程序内部缓存目录
    // /data/data/your_package_name/image_manager_disk_cache/
    // (不能被其它应用访问)且缓存最大为250MB
    builder.setDiskCache(new InternalCacheDiskCacheFactory(context,
            DiskCache.Factory.DEFAULT_DISK_CACHE_DIR,
            DiskCache.Factory.DEFAULT_DISK_CACHE_SIZE));
    // 缓存到外部磁盘SD卡上,字节
    // builder.setDiskCache(new ExternalCacheDiskCacheFactory(
    // context,DiskCache.Factory.DEFAULT_DISK_CACHE_DIR,
    // DiskCache.Factory.DEFAULT_DISK_CACHE_SIZE));
    // 设置内存缓存大小
    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));
}
项目:GankGirl    文件:GlideConfiguration.java   
@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);
        }
    });

}
项目:WhiteRead    文件:GlideConfigModule.java   
@Override
public void applyOptions(Context context, GlideBuilder builder) {
    // 指定位置在packageName/cache/glide_cache,大小为MAX_CACHE_DISK_SIZE的磁盘缓存
    // 设置一个用来创建DiskCache的工厂。默认情况下Glide使用InternalCacheDiskCacheFactory内部工厂类创建DiskCache,
    // 缓存目录为程序内部缓存目录/data/data/your_package_name/image_manager_disk_cache/(不能被其它应用访问)且缓存最大为250MB。
    // 当然,可以通过InternalCacheDiskCacheFactory构造器更改缓存的目录和最大缓存大小
    builder.setDiskCache(new InternalCacheDiskCacheFactory(context, "glide_cache", ConfigConstants.MAX_CACHE_DISK_SIZE));
    // 指定内存缓存大小
    // MemoryCache用来把resources 缓存在内存里,以便能马上能拿出来显示。
    // 默认情况下Glide使用LruResourceCache,我们可以通过它的构造器设置最大缓存内存大小。
    builder.setMemoryCache(new LruResourceCache(ConfigConstants.MAX_CACHE_MEMORY_SIZE));
    // 全部的内存缓存用来作为图片缓存
    // Bitmap池用来允许不同尺寸的Bitmap被重用,这可以显著地减少因为图片解码像素数组分配内存而引发的垃圾回收。
    // 默认情况下Glide使用LruBitmapPool作为Bitmap池,LruBitmapPool采用LRU算法保存最近使用的尺寸的Bitmap。
    // 我们可以通过它的构造器设置最大缓存内存大小。
    builder.setBitmapPool(new LruBitmapPool(ConfigConstants.MAX_CACHE_MEMORY_SIZE));
    // 为所有的默认解码器设置解码格式。如DecodeFormat.PREFER_ARGB_8888。
    // 默认是DecodeFormat.PREFER_RGB_565,因为相对于ARGB_8888的4字节/像素可以节省一半的内存,但不支持透明度且某些图片会出现条带。
    builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888);//和Picasso配置一样
}
项目:ImageLoaderDemo    文件:CustomGlideModule.java   
@Override
public void applyOptions(Context context, GlideBuilder builder) {
    // 设置格式
    builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888);
    // 缓存到data目录下最大50M
    // 缓存目录为程序内部缓存目录
    // /data/data/your_package_name/image_manager_disk_cache/
    // (不能被其它应用访问)且缓存最大为250MB
    builder.setDiskCache(new InternalCacheDiskCacheFactory(context,
            DiskCache.Factory.DEFAULT_DISK_CACHE_DIR,
            DiskCache.Factory.DEFAULT_DISK_CACHE_SIZE));
    // 缓存到外部磁盘SD卡上,字节
    // builder.setDiskCache(new ExternalCacheDiskCacheFactory(
    // context,DiskCache.Factory.DEFAULT_DISK_CACHE_DIR,
    // DiskCache.Factory.DEFAULT_DISK_CACHE_SIZE));
    // 设置内存缓存大小
    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));
}
项目:CustomListView    文件:GlideConfiguration.java   
@Override
public void applyOptions(Context context, GlideBuilder builder) {
    builder.setDiskCache(new InternalCacheDiskCacheFactory(context, IMAGE_DISK_CACHE_MAX_SIZE));

    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.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888);
}
项目:yyox    文件:GlideCacheUtil.java   
/**
 * 获取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 "";
}
项目:MVVM-JueJin    文件:GlideConfig.java   
@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));
    }
项目:BaseVLayoutAdapterHelper    文件:CustomGlideModule.java   
@Override
public void applyOptions(Context context, GlideBuilder builder) {
    MemorySizeCalculator calculator = new MemorySizeCalculator.Builder(context)
            .setMemoryCacheScreens(2)
            .build();
    //设置手机默认推荐缓存大小
    builder.setMemoryCache(new LruResourceCache(calculator.getMemoryCacheSize()));
    // 自定义缓存大小.
    int memoryCacheSizeBytes = 1024 * 1024 * 20; // 20mb
    builder.setMemoryCache(new LruResourceCache(memoryCacheSizeBytes));
    //自定义内置磁盘缓存大小(可以指明路径)
    int diskCacheSizeBytes = 1024 * 1024 * 100; // 100 MB
    builder.setDiskCache(new InternalCacheDiskCacheFactory(context, diskCacheSizeBytes));

}
项目:lrs_android    文件:MyGlideModuleConfig.java   
@Override
    public void applyOptions(Context context, GlideBuilder builder) {
//        builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888);
        if (AppUtil.hasSDCard()) {
            builder.setDiskCache(new ExternalCacheDiskCacheFactory(context, "GlideCache", 500 * 1024 * 1024));
            LogUtil.e("Glide使用SD卡缓存");
        } else {
            builder.setDiskCache(new InternalCacheDiskCacheFactory(context, "GlideCache", 250 * 1024 * 1024));
            LogUtil.e("Glide使用内部缓存");
        }
        builder.setMemoryCache(new LruResourceCache(100 * 1024 * 1024));
    }
项目:Tribe    文件:GlideCathUtil.java   
/**
 * 获取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 "";
}
项目:Coder    文件:GlideConfig.java   
@Override
    public void applyOptions(Context context, GlideBuilder builder) {
        // 定义缓存大小和位置
        builder.setDiskCache(new InternalCacheDiskCacheFactory(context, diskSize));  // 内存中
        builder.setDiskCache(new ExternalCacheDiskCacheFactory(context, "cache", diskSize)); // sd卡中

        // 自定义内存和图片池大小
        builder.setMemoryCache(new LruResourceCache(memorySize)); // 自定义内存大小
        builder.setBitmapPool(new LruBitmapPool(memorySize)); // 自定义图片池大小

        // 定义图片格式
         builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888); // 高质量
//        builder.setDecodeFormat(DecodeFormat.PREFER_RGB_565); // 默认(中等质量)
    }
项目:ZoomPreviewPicture    文件:MyGlideModule.java   
@Override
public void applyOptions(final Context context, GlideBuilder builder) {
    ViewTarget.setTagId(R.id.glide_tag_id);
    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));
}
项目:Cashew    文件:GlideCacheUtil.java   
/**
 * 获取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 "";
}
项目:LiveGiftLayout    文件:GlideCacheUtil.java   
/**
 * 获取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 "";
}
项目:RLibrary    文件:GlideCacheUtil.java   
/**
 * 获取Glide造成的缓存大小
 *
 * @return CacheSize
 */
public String getCacheSize(Context context) {
    try {
        return Formatter.formatFileSize(context,
                getFolderSize(new File(context.getCacheDir() + "/" + InternalCacheDiskCacheFactory.DEFAULT_DISK_CACHE_DIR))
        );
        //return getFormatSize(getFolderSize(new File(context.getCacheDir() + "/" + InternalCacheDiskCacheFactory.DEFAULT_DISK_CACHE_DIR)));
    } catch (Exception e) {
        e.printStackTrace();
    }
    return "";
}
项目:ImageSwitcherJarPackage    文件:CustomGlideModule.java   
@Override
public void applyOptions(Context context, GlideBuilder builder) {
    builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888);
    builder.setDiskCache(new InternalCacheDiskCacheFactory(context,
            DiskCache.Factory.DEFAULT_DISK_CACHE_DIR,
            DiskCache.Factory.DEFAULT_DISK_CACHE_SIZE));
    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));
}
项目:Android-SleepingForLess    文件:GlideConfiguration.java   
@Override
public void applyOptions(Context context, GlideBuilder builder) {
    // Apply options to the builder here.
    int cacheSize = 1024 * 1024 * 20;
    int memorySize = 1024 * 1024 * 20;
    String cacheDirectory = context.getCacheDir().getAbsolutePath();
    builder.setDiskCache(new InternalCacheDiskCacheFactory(context, cacheDirectory, cacheSize));
    builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888);
    builder.setMemoryCache(new LruResourceCache(memorySize));
}
项目:LLApp    文件:GlideCacheUtil.java   
/**
 * 获取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 "";
}
项目:ImageLoadPK    文件:GlideConfigModule.java   
@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配置一样
}
项目:S1-Next    文件:S1NextGlideModule.java   
@Override
public void applyOptions(Context context, GlideBuilder builder) {
    // set max size of the disk cache for images
    builder.setDiskCache(new InternalCacheDiskCacheFactory(
            context, App.getAppComponent().getDownloadPreferencesManager()
            .getTotalImageCacheSize()));

    ViewTarget.setTagId(R.id.tag_glide);

    //从默认的RGB_565改为ARGB_8888显示
    builder.setDefaultRequestOptions(new RequestOptions().format(DecodeFormat.PREFER_ARGB_8888));
}
项目:Gallery    文件:GlideSetup.java   
@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));
}
项目:GeneqiaoGallery    文件:MyGlideModule.java   
@Override
public void applyOptions(final Context context, GlideBuilder builder) {
    ViewTarget.setTagId(R.id.glide_tag_id);
    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));
}
项目:MoeGallery    文件:GlideSetup.java   
@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));
}
项目:android-tutorials-glide    文件:CustomCachingGlideModule.java   
@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 ) );

}
项目:OpenHub    文件:MyAppGlideModel.java   
@Override
public void applyOptions(Context context, GlideBuilder builder) {
    super.applyOptions(context, builder);
    builder.setDiskCache(new InternalCacheDiskCacheFactory(context, AppConfig.IMAGE_MAX_CACHE_SIZE));
}
项目:glide-support    文件:GlideModule.java   
@Override public void applyOptions(Context context, GlideBuilder builder) {
    builder.setDiskCache(new StealingDiskCacheFactory(new InternalCacheDiskCacheFactory(context)));
}
项目:QxGradleConfig    文件:GlideConfiguration.java   
@Override
    public void applyOptions(Context context, GlideBuilder builder) {
        // Apply options to the builder here.
//        builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888);
        builder.setDecodeFormat(DecodeFormat.PREFER_RGB_565); //默认的

        final int size = 1024 * 1024 * 50;

        builder.setDiskCache(
                new InternalCacheDiskCacheFactory(context, size));
        builder.setDiskCache(
                new InternalCacheDiskCacheFactory(context, "pics", size));//内部缓存目录
        builder.setDiskCache(
                new ExternalCacheDiskCacheFactory(context, "outpics", size));//外部sdcard缓存目录

        // If you can figure out the folder without I/O:
// Calling Context and Environment class methods usually do I/O.
        builder.setDiskCache(
                new DiskLruCacheFactory("diskCacheFolder", size)); //指定sdcard缓存目录

// In case you want to specify a cache folder ("glide"):
        builder.setDiskCache(
                new DiskLruCacheFactory("diskCacheFolder_glide", "diskCacheName", size));//sdcard缓存目录

// In case you need to query the file system while determining the folder:
        GlideBuilder diskCacheFolder = builder.setDiskCache(new DiskLruCacheFactory(new DiskLruCacheFactory.CacheDirectoryGetter() {
            @Override
            public File getCacheDirectory() {
                return new File("diskCacheFolder");
            }
        }, size));


        builder.setDiskCache(new DiskCache.Factory() {
            @Override public DiskCache build() {
                File cacheLocation = new File("diskCacheFolder");
                if (!cacheLocation.exists())
                    cacheLocation.mkdirs();
                return DiskLruCacheWrapper.get(cacheLocation, size);
            }
        });


        //----------- memory cache  -------------
        builder.setMemoryCache(new LruResourceCache(size/10));

        //----------- bitmap pool  -------------
        builder.setBitmapPool(new LruBitmapPool(size/20));

    }
项目:GitPath    文件:MyGlideMode.java   
@Override
public void applyOptions(Context context, GlideBuilder builder) {
    builder.setDiskCache(new InternalCacheDiskCacheFactory(context,1024*200));
    builder.setMemoryCache(new LruResourceCache(1024*100));
}
项目:mage-android    文件:MageGlideModule.java   
@Override
public void applyOptions(Context context, GlideBuilder builder) {
    builder.setDiskCache(new InternalCacheDiskCacheFactory(context, DEFAULT_DISK_CACHE_SIZE));
}
项目:Android-Tech    文件:GustomCachingGlideModule.java   
@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));


    }