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


Java GlideBuilder类代码示例

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


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

示例1: applyOptions

import com.bumptech.glide.GlideBuilder; //导入依赖的package包/类
@Override
public void applyOptions(Context context, GlideBuilder builder) {
    builder.setDiskCache(new DiskCache.Factory() {
        @Override
        public DiskCache build() {
            // Careful: the external cache directory doesn't enforce permissions
            File cacheDirectory = new File(DataHelper.getCacheFile(UiUtils.getContext()), "Glide");
            return DiskLruCacheWrapper.get(DataHelper.makeDirs(cacheDirectory), 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));

}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:GlideConfiguration.java

示例2: applyOptions

import com.bumptech.glide.GlideBuilder; //导入依赖的package包/类
@Override
public void applyOptions(Context context, GlideBuilder builder) {
    builder.setDiskCache(new DiskCache.Factory() {
        @Override
        public DiskCache build() {
            // Careful: the external cache directory doesn't enforce permissions
            return DiskLruCacheWrapper.get(DataHelper.getCacheFile(UiUtils.getContext()), 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));

}
 
开发者ID:Zyj163,项目名称:yyox,代码行数:22,代码来源:GlideConfiguration.java

示例3: applyOptions

import com.bumptech.glide.GlideBuilder; //导入依赖的package包/类
@Override
public void applyOptions(final Context context, GlideBuilder builder) {

    // 缓存目录
    builder.setDiskCache(new DiskCache.Factory() {

        @Override
        public DiskCache build() {
            AppComponent component = ((App) context.getApplicationContext()).getAppComponent();
            return DiskLruCacheWrapper.get(FileUtils.makeDirs(new File(component.cacheFile(), "Glide")), DISK_SIZE);
        }
    });

    // 自定义内存缓存和图片池大小
    MemorySizeCalculator calculator = new MemorySizeCalculator(context);
    builder.setMemoryCache(new LruResourceCache((int) (1.2 * calculator.getMemoryCacheSize())));
    builder.setBitmapPool(new LruBitmapPool((int) (1.2 * calculator.getBitmapPoolSize())));

    // 图片格式
    builder.setDecodeFormat(DecodeFormat.PREFER_RGB_565); // 默认
}
 
开发者ID:RockyQu,项目名称:MVVMFrames,代码行数:22,代码来源:GlideConfiguration.java

示例4: applyOptions

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

    }
 
开发者ID:fiepi,项目名称:moebooru-android,代码行数:26,代码来源:MoeGlideModule.java

示例5: applyOptions

import com.bumptech.glide.GlideBuilder; //导入依赖的package包/类
@Override
public void applyOptions(final Context context, GlideBuilder builder) {
    builder.setDiskCache(new DiskCache.Factory() {
        @Override
        public DiskCache build() {
            // Careful: the external cache directory doesn't enforce permissions
            return DiskLruCacheWrapper.get(Glide.getPhotoCacheDir(context), ConfigConstants.MAX_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));

}
 
开发者ID:VK2012,项目名称:AppCommonFrame,代码行数:22,代码来源:GlideConfiguration.java

示例6: applyOptions

import com.bumptech.glide.GlideBuilder; //导入依赖的package包/类
@Override public void applyOptions(final Context context, GlideBuilder builder) {
        builder.setDiskCache(new DiskCache.Factory() {
            @Override
            public DiskCache build() {
                File cacheLocation = new File(AppUtils.getPath(context, AppUtils.StorageFile.cache));
                cacheLocation.mkdirs();
                return DiskLruCacheWrapper.get(cacheLocation, DISK_CACHE_SIZE);
            }
        });
//        MemorySizeCalculator calculator = new MemorySizeCalculator(context);
//        int defaultMemoryCacheSize = calculator.getMemoryCacheSize();
//        int defaultBitmapPoolSize = calculator.getBitmapPoolSize();
//
//        int customMemoryCacheSize = (int) (0.25 * defaultMemoryCacheSize);
//        int customBitmapPoolSize = (int) (0.25* defaultBitmapPoolSize);
//
//        builder.setMemoryCache( new LruResourceCache( customMemoryCacheSize ));
//        builder.setBitmapPool( new LruBitmapPool( customBitmapPoolSize ));
    }
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:20,代码来源:CustomCachingGlideModule.java

示例7: applyOptions

import com.bumptech.glide.GlideBuilder; //导入依赖的package包/类
@Override
public void applyOptions(Context context, GlideBuilder builder) {
    builder.setDiskCache(new DiskCache.Factory() {
        @Override
        public DiskCache build() {
            // Careful: the external cache directory doesn't enforce permissions
            AppComponent appComponent = ((App) context.getApplicationContext()).getAppComponent();
            return DiskLruCacheWrapper.get(DataHelper.makeDirs(new File(appComponent.cacheFile(), "Glide")), 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));

}
 
开发者ID:yangxp108,项目名称:MVPArms_Fragment-fragment,代码行数:23,代码来源:GlideConfiguration.java

示例8: applyOptions

import com.bumptech.glide.GlideBuilder; //导入依赖的package包/类
@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);
}
 
开发者ID:HanyeeWang,项目名称:GeekZone,代码行数:24,代码来源:GlideConfiguration.java

示例9: customCacheOptions

import com.bumptech.glide.GlideBuilder; //导入依赖的package包/类
/**
 * 设置缓存设置
 */
private void customCacheOptions(Context context, GlideBuilder builder) {
    //设置内存缓存大小和bitmap池大小
    MemorySizeCalculator calculator = new MemorySizeCalculator.Builder(context)
            .setMemoryCacheScreens(2)
            .build();
    int defaultMemoryCacheSize = calculator.getMemoryCacheSize();
    int defaultBitmapCacheSize = calculator.getBitmapPoolSize();
    //比默认的内存分配大20%
    int customMemoryCacheSize = (int) (4 * defaultMemoryCacheSize);
    int customBitmapPoolSize = (int) (4 * defaultBitmapCacheSize);
    builder.setMemoryCache(new LruResourceCache(customMemoryCacheSize));
    builder.setBitmapPool(new LruBitmapPool(customBitmapPoolSize));

    //设置磁盘缓存
    int cacheSize100MegaBytes =  1024 * 1024 * 100;//200M
    //外部磁盘缓存
    builder.setDiskCache(new ExternalCacheDiskCacheFactory(context, cacheSize100MegaBytes));

}
 
开发者ID:funnyzhaov,项目名称:Tribe,代码行数:23,代码来源:OvAppGlideModule.java

示例10: applyOptions

import com.bumptech.glide.GlideBuilder; //导入依赖的package包/类
/**
 * Lazily apply options to a {@link GlideBuilder} immediately before the Glide singleton is
 * created.
 * <p>
 * <p>
 * This method will be called once and only once per implementation.
 * </p>
 *
 * @param context An Application {@link Context}.
 * @param builder The {@link GlideBuilder} that will be used to create Glide.
 */
@Override
public void applyOptions(Context context, GlideBuilder builder) {
    ActivityManager activityManager =
            (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    MemorySizeCalculator calculator = new MemorySizeCalculator(context);
    // Increasing cache & pool by 25% - default is 250MB
    int memoryCacheSize = (int) (1.25 * calculator.getMemoryCacheSize());
    int bitmapPoolSize = (int) (1.25 * calculator.getBitmapPoolSize());
    int storageCacheSize = 1024 * 1024 * 350;
    if(context.getExternalCacheDir() != null) {
        long total = context.getExternalCacheDir().getUsableSpace();
        storageCacheSize = (int) (total*0.14);
    }

    builder.setMemoryCache(new LruResourceCache(memoryCacheSize));
    builder.setBitmapPool(new LruBitmapPool(bitmapPoolSize));
    builder.setDiskCache(new ExternalCacheDiskCacheFactory(context, storageCacheSize));
    builder.setDecodeFormat(ActivityManagerCompat.isLowRamDevice(activityManager) ?
            DecodeFormat.PREFER_RGB_565 : DecodeFormat.PREFER_ARGB_8888);
}
 
开发者ID:wax911,项目名称:anitrend-app,代码行数:32,代码来源:ConfigModule.java

示例11: applyOptions

import com.bumptech.glide.GlideBuilder; //导入依赖的package包/类
@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);
    }
 
开发者ID:liying2008,项目名称:Simpler,代码行数:27,代码来源:MyGlideModule.java

示例12: setUp

import com.bumptech.glide.GlideBuilder; //导入依赖的package包/类
@Before
public void setUp() {
  MockitoAnnotations.initMocks(this);
  context = RuntimeEnvironment.application;

  Glide.init(new GlideBuilder().setBitmapPool(bitmapPool).build(context));
  transformation = new GifDrawableTransformation(wrapped);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:GifDrawableTransformationTest.java

示例13: setUp

import com.bumptech.glide.GlideBuilder; //导入依赖的package包/类
@Before
public void setUp() {
  MockitoAnnotations.initMocks(this);
  bitmapWidth = 100;
  bitmapHeight = 100;
  Bitmap bitmap = Bitmap.createBitmap(bitmapWidth, bitmapHeight, Bitmap.Config.ARGB_8888);
  when(resource.get()).thenReturn(bitmap);

  BitmapPool pool = new BitmapPoolAdapter();
  context = RuntimeEnvironment.application;
  Glide.init(new GlideBuilder().setBitmapPool(pool).build(context));


  fitCenter = new FitCenter();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:FitCenterTest.java

示例14: setUp

import com.bumptech.glide.GlideBuilder; //导入依赖的package包/类
@Before
public void setUp() {
  MockitoAnnotations.initMocks(this);
  bitmapWidth = 100;
  bitmapHeight = 100;
  bitmap = Bitmap.createBitmap(bitmapWidth, bitmapHeight, Bitmap.Config.ARGB_8888);
  when(resource.get()).thenReturn(bitmap);

  when(pool.get(anyInt(), anyInt(), any(Bitmap.Config.class)))
      .thenAnswer(new Util.CreateBitmap());
  context = RuntimeEnvironment.application;
  Glide.init(new GlideBuilder().setBitmapPool(pool).build(context));

  centerCrop = new CenterCrop();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:CenterCropTest.java

示例15: setup

import com.bumptech.glide.GlideBuilder; //导入依赖的package包/类
@Before
public void setup() {
  MockitoAnnotations.initMocks(this);
  when(bitmapPool.get(anyInt(), anyInt(), any(Bitmap.Config.class)))
      .thenAnswer(new Util.CreateBitmap());
  Context context = RuntimeEnvironment.application;
  Glide.init(new GlideBuilder().setBitmapPool(bitmapPool).build(context));
  circleCrop = new CircleCrop();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:CircleCropTest.java


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