当前位置: 首页>>代码示例>>Java>>正文


Java DiskLruCacheFactory类代码示例

本文整理汇总了Java中com.bumptech.glide.load.engine.cache.DiskLruCacheFactory的典型用法代码示例。如果您正苦于以下问题:Java DiskLruCacheFactory类的具体用法?Java DiskLruCacheFactory怎么用?Java DiskLruCacheFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DiskLruCacheFactory类属于com.bumptech.glide.load.engine.cache包,在下文中一共展示了DiskLruCacheFactory类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: applyOptions

import com.bumptech.glide.load.engine.cache.DiskLruCacheFactory; //导入依赖的package包/类
@Override
public void applyOptions(Context context, GlideBuilder builder) {
    //定义缓存大小为100M
    int  diskCacheSize =  100 * 1024 * 1024;

    //自定义缓存 路径 和 缓存大小
    String diskCachePath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/glideCache" ;

    //提高图片质量
    builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888);

    //自定义磁盘缓存:这种缓存只有自己的app才能访问到
    // builder.setDiskCache( new InternalCacheDiskCacheFactory( context , diskCacheSize )) ;
    // builder.setDiskCache( new InternalCacheDiskCacheFactory( context , diskCachePath , diskCacheSize  )) ;

    //自定义磁盘缓存:这种缓存存在SD卡上,所有的应用都可以访问到
    builder.setDiskCache(new DiskLruCacheFactory( diskCachePath , diskCacheSize ));

}
 
开发者ID:zyj1609wz,项目名称:GlideDemo,代码行数:20,代码来源:SimpleGlideModule.java

示例2: applyOptions

import com.bumptech.glide.load.engine.cache.DiskLruCacheFactory; //导入依赖的package包/类
@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);
        }
    });

}
 
开发者ID:dalingge,项目名称:GankGirl,代码行数:26,代码来源:GlideConfiguration.java

示例3: applyOptions

import com.bumptech.glide.load.engine.cache.DiskLruCacheFactory; //导入依赖的package包/类
@Override
public void applyOptions(Context context, GlideBuilder builder) {
    //解决setTag问题
    ViewTarget.setTagId(R.id.glide_tag_id);
    //磁盘缓存
    builder.setDiskCache(new DiskLruCacheFactory(AppFileHelper.getAppCachePath(), 50 * 1024 * 1024));
    builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888);
    //内存缓存
    MemorySizeCalculator calculator = new MemorySizeCalculator(context);
    int defaultMemoryCacheSize = calculator.getMemoryCacheSize();
    int defaultBitmapPoolSize = calculator.getBitmapPoolSize();
    //设置比默认大小大1.5倍的缓存和图片池大小
    int customMemoryCacheSize = (int) (1.5 * defaultMemoryCacheSize);
    int customBitmapPoolSize = defaultBitmapPoolSize;


    KLog.i("poolSize", "bitmapPoolSize >>>>>   "
            + android.text.format.Formatter.formatFileSize(context, customBitmapPoolSize)
            + "          memorySize>>>>>>>>   " +
            android.text.format.Formatter.formatFileSize(context, customMemoryCacheSize));

    builder.setMemoryCache(new LruResourceCache(customMemoryCacheSize));
    builder.setBitmapPool(new LruBitmapPool(customBitmapPoolSize));

}
 
开发者ID:razerdp,项目名称:FriendCircle,代码行数:26,代码来源:GlobalGlideConfiguration.java

示例4: applyOptions

import com.bumptech.glide.load.engine.cache.DiskLruCacheFactory; //导入依赖的package包/类
@Override
public void applyOptions(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 ));

    int cacheSize50MegaBytes = 52428800;

    /*builder.setDiskCache(
            new InternalCacheDiskCacheFactory(context, cacheSize100MegaBytes)
    );*/

    /*builder.setDiskCache(
    new ExternalCacheDiskCacheFactory());*/
    builder.setDiskCache(new DiskLruCacheFactory(Constants.OwnCacheDirectory,"Cache",cacheSize50MegaBytes)) ;
    builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888); //PREFER_RGB_565
}
 
开发者ID:yeming1001,项目名称:GankMeiZhi,代码行数:24,代码来源:MyGlideModule.java

示例5: applyOptions

import com.bumptech.glide.load.engine.cache.DiskLruCacheFactory; //导入依赖的package包/类
@Override
public void applyOptions(Context context, GlideBuilder builder) {
    // Apply options to the builder here.
    builder.setDecodeFormat(DecodeFormat.PREFER_RGB_565);

    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));

    int cacheSize100MegaBytes = 104857600;
    String downloadDirectoryPath = Environment.getDownloadCacheDirectory().getPath();
    builder.setDiskCache(
            new DiskLruCacheFactory(downloadDirectoryPath, cacheSize100MegaBytes)
    );
}
 
开发者ID:Ksj7,项目名称:BandWith,代码行数:22,代码来源:GlideCustomModule.java

示例6: applyOptions

import com.bumptech.glide.load.engine.cache.DiskLruCacheFactory; //导入依赖的package包/类
@Override
public void applyOptions(final Context context, GlideBuilder builder) {
    builder.setDiskCache(new DiskLruCacheFactory(new DiskLruCacheFactory.CacheDirectoryGetter
            () {
        @Override
        public File getCacheDirectory() {
            return context.getExternalCacheDir();
        }
    }, DiskCache.Factory.DEFAULT_DISK_CACHE_SIZE));
}
 
开发者ID:zuoweitan,项目名称:Hitalk,代码行数:11,代码来源:VideoListGlideModule.java

示例7: applyOptions

import com.bumptech.glide.load.engine.cache.DiskLruCacheFactory; //导入依赖的package包/类
@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);
  }
 
开发者ID:lujianzhao,项目名称:AndroidBase,代码行数:13,代码来源:OkHttpGlideModule.java

示例8: applyOptions

import com.bumptech.glide.load.engine.cache.DiskLruCacheFactory; //导入依赖的package包/类
@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));
}
 
开发者ID:waynell,项目名称:VideoListPlayer,代码行数:12,代码来源:VideoListGlideModule.java

示例9: applyOptions

import com.bumptech.glide.load.engine.cache.DiskLruCacheFactory; //导入依赖的package包/类
@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 ) );

}
 
开发者ID:fs-opensource,项目名称:android-tutorials-glide,代码行数:37,代码来源:CustomCachingGlideModule.java

示例10: applyOptions

import com.bumptech.glide.load.engine.cache.DiskLruCacheFactory; //导入依赖的package包/类
@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));

    }
 
开发者ID:XinRan5312,项目名称:QxGradleConfig,代码行数:51,代码来源:GlideConfiguration.java


注:本文中的com.bumptech.glide.load.engine.cache.DiskLruCacheFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。