Here are the examples of the java api com.bumptech.glide.GlideBuilder taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
81 Examples
18
Source : GlideImageLoaderStrategy.java
with Apache License 2.0
from Zweihui
with Apache License 2.0
from Zweihui
@Override
public void applyGlideOptions(Context context, GlideBuilder builder) {
Timber.w("applyGlideOptions");
}
18
Source : VideoListGlideModule.java
with Apache License 2.0
from zuoweitan
with Apache License 2.0
from zuoweitan
@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));
}
18
Source : AppGlideModuleHelper.java
with MIT License
from YassinAJDI
with MIT License
from YassinAJDI
@Override
public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
builder.setDefaultRequestOptions(new RequestOptions().placeholder(R.color.md_grey_200));
}
18
Source : GlideConfigModule.java
with Apache License 2.0
from y1xian
with Apache License 2.0
from y1xian
@Override
public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
// 修改默认配置,如缓存配置
builder.setDefaultRequestOptions(new RequestOptions().format(DecodeFormat.PREFER_RGB_565));
}
18
Source : GlideConfiguration.java
with MIT License
from xiaolongonly
with MIT License
from xiaolongonly
@Override
public void applyOptions(Context context, GlideBuilder builder) {
// 如果你对默认的RGB_565效果还比较满意,可以不做任何事,但是如果你觉得难以接受,可以创建一个新的GlideModule将Bitmap格式转换到ARGB_8888:
builder.setDecodeFormat(DecodeFormat.PREFER_RGB_565);
}
18
Source : SignalGlideModule.java
with GNU General Public License v3.0
from XecureIT
with GNU General Public License v3.0
from XecureIT
@Override
public void applyOptions(Context context, GlideBuilder builder) {
builder.setLogLevel(Log.ERROR);
// builder.setDiskCache(new NoopDiskCacheFactory());
}
18
Source : MyGlideMoudle.java
with MIT License
from w0080626
with MIT License
from w0080626
@Override
public void applyOptions(Context context, GlideBuilder builder) {
ViewTarget.setTagId(R.id.image_tag);
}
18
Source : TyGlide.java
with GNU General Public License v3.0
from tysqapp
with GNU General Public License v3.0
from tysqapp
@Override
public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
}
18
Source : CustomGlideModule.java
with GNU General Public License v3.0
from timusus
with GNU General Public License v3.0
from timusus
@Override
public void applyOptions(Context context, GlideBuilder builder) {
}
18
Source : GlideConfiguration.java
with Apache License 2.0
from tianshaojie
with Apache License 2.0
from tianshaojie
@Override
public void applyOptions(Context context, GlideBuilder builder) {
// 自定义缓存目录,磁盘缓存给150M 另外一种设置缓存方式
builder.setDiskCache(new InternalCacheDiskCacheFactory(context, GLIDE_CARCH_DIR, GLIDE_CATCH_SIZE));
}
18
Source : DemoGlideModule.java
with Apache License 2.0
from threeloe
with Apache License 2.0
from threeloe
@Override
public void applyOptions(Context context, GlideBuilder builder) {
RequestOptions options = new RequestOptions().diskCacheStrategy(DiskCacheStrategy.ALL).format(DecodeFormat.PREFER_RGB_565);
builder.setLogLevel(Log.DEBUG).setDefaultRequestOptions(options);
}
18
Source : MyAppGlideModule.java
with MIT License
from techGay
with MIT License
from techGay
@Override
public void applyOptions(@NonNull Context context, GlideBuilder builder) {
int diskCacheSizeBytes = 1024 * 1024 * 250;
builder.setDiskCache(new DiskLruCacheFactory(AppCacheUtils.getGlideDiskCacheDir(context).getAbsolutePath(), diskCacheSizeBytes));
}
18
Source : QiitaGlideModule.java
with Apache License 2.0
from sumio
with Apache License 2.0
from sumio
@Override
public void applyOptions(Context context, GlideBuilder builder) {
// do nothing
}
18
Source : OkHttpGlide.java
with Apache License 2.0
from shengjunhu
with Apache License 2.0
from shengjunhu
@Override
public void applyOptions(Context context, GlideBuilder builder) {
/**
* 1、内存缓存、bitmap缓存池 : 采用默认
* 2、磁盘缓存:
*/
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
File sdDir = Environment.getExternalStorageDirectory();
long usableSpace = sdDir.getUsableSpace();
String usableSpaceFormat = Formatter.formatFileSize(context, usableSpace);
if (usableSpace < DEFAULT_IMAGE_CACHE_SIZE) {
Toast.makeText(context, context.getString(R.string.storage_hint) + usableSpaceFormat, Toast.LENGTH_SHORT).show();
} else {
builder.setDiskCache(new ExternalCacheDiskCacheFactory(context, "image", DEFAULT_IMAGE_CACHE_SIZE));
}
} else {
File dataDir = Environment.getDataDirectory();
long usableSpace = dataDir.getUsableSpace();
String usableSpaceFormat = Formatter.formatFileSize(context, usableSpace);
if (usableSpace < DEFAULT_IMAGE_CACHE_SIZE) {
Toast.makeText(context, context.getString(R.string.storage_hint) + usableSpaceFormat, Toast.LENGTH_SHORT).show();
} else {
builder.setDiskCache(new InternalCacheDiskCacheFactory(context, "image", DEFAULT_IMAGE_CACHE_SIZE));
}
}
}
18
Source : DankAppGlideModule.java
with Apache License 2.0
from saket
with Apache License 2.0
from saket
@Override
public void applyOptions(Context context, GlideBuilder builder) {
builder.setLogLevel(Log.ERROR);
}
18
Source : GlideImageLoaderStrategy.java
with Apache License 2.0
from RockyQu
with Apache License 2.0
from RockyQu
@Override
public void applyGlideOptions(Context context, GlideBuilder builder) {
}
18
Source : QtalkGlideModule.java
with MIT License
from qunarcorp
with MIT License
from qunarcorp
@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));
}
18
Source : GlideAPI.java
with MIT License
from Njack-IITP
with MIT License
from Njack-IITP
// TODO: Modify the options here according to the need
@Override
public void applyOptions(Context context, GlideBuilder builder) {
// 10mb
int diskCacheSizeBytes = 1024 * 1024 * 10;
builder.setDiskCache(new InternalCacheDiskCacheFactory(context, diskCacheSizeBytes));
}
18
Source : OkHttpGlideModule.java
with Apache License 2.0
from nicolite
with Apache License 2.0
from nicolite
@Override
public void applyOptions(Context context, GlideBuilder builder) {
// Do nothing.
}
18
Source : MyAppGlideModule.java
with MIT License
from medyas
with MIT License
from medyas
// leave empty for now
@Override
public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
}
18
Source : HulkAppGlideModule.java
with Apache License 2.0
from madreain
with Apache License 2.0
from madreain
/**
* glide设置的相关配置
* @param context
* @param builder
*/
@Override
public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
RequestOptions requestOptions = new RequestOptions().centerCrop().dontAnimate().disallowHardwareConfig().placeholder(HulkConfig.getGlidePlaceHolder()).error(HulkConfig.getGlidePlaceHolder()).diskCacheStrategy(DiskCacheStrategy.AUTOMATIC).format(DecodeFormat.PREFER_RGB_565);
builder.setDefaultRequestOptions(requestOptions);
}
18
Source : MyGlideModule.java
with Apache License 2.0
from liying2008
with Apache License 2.0
from liying2008
// private int memorySize = (int) (Runtime.getRuntime().maxMemory()) / 8; // 取1/8最大内存作为最大缓存
@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);
}
18
Source : MGlideModule.java
with GNU General Public License v3.0
from liaoheng
with GNU General Public License v3.0
from liaoheng
@Override
public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
try {
File imgCache = FileUtils.getProjectSpaceCacheDirectory(context, Constants.DISK_CACHE_DIR);
builder.setDiskCache(new DiskLruCacheFactory(imgCache.getAbsolutePath(), Constants.IMAGE_DISK_CACHE_SIZE));
} catch (IOException ignored) {
}
builder.setLogLevel(BuildConfig.DEBUG ? Log.DEBUG : Log.INFO);
}
18
Source : GlobalConfiguration.java
with Apache License 2.0
from LeviWGG
with Apache License 2.0
from LeviWGG
@Override
public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
super.applyOptions(context, builder);
}
18
Source : MyGlideModule.java
with GNU Affero General Public License v3.0
from KianIranian-STDG
with GNU Affero General Public License v3.0
from KianIranian-STDG
@Override
public void applyOptions(Context context, GlideBuilder builder) {
super.applyOptions(context, builder);
}
18
Source : MyAppGlideModule.java
with Apache License 2.0
from jsyjst
with Apache License 2.0
from jsyjst
@Override
public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
builder.setDefaultRequestOptions(new RequestOptions().format(DecodeFormat.PREFER_RGB_565));
}
18
Source : GlideImageLoaderStrategy.java
with Apache License 2.0
from JessYanCoding
with Apache License 2.0
from JessYanCoding
@Override
public void applyGlideOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
Timber.i("applyGlideOptions");
}
18
Source : CustomGlideModule.java
with MIT License
from Jadyli
with MIT License
from Jadyli
@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));
// 100 MB
int diskCacheSizeBytes = 1024 * 1024 * 100;
builder.setDiskCache(new InternalCacheDiskCacheFactory(context, diskCacheSizeBytes));
// builder.setDiskCache(new InternalCacheDiskCacheFactory(context, "cacheFolderName", diskCacheSizeBytes));
}
18
Source : PulseAppGlideModule.java
with GNU General Public License v3.0
from HardcodeCoder
with GNU General Public License v3.0
from HardcodeCoder
@Override
public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
super.applyOptions(context, builder);
RequestOptions requestOptions = new RequestOptions();
requestOptions = requestOptions.diskCacheStrategy(DiskCacheStrategy.RESOURCE);
builder.setDefaultRequestOptions(requestOptions);
if (BuildConfig.DEBUG)
builder.setLogLevel(Log.DEBUG);
else
builder.setLogLevel(Log.ERROR);
}
18
Source : AbstractGlideModule.java
with Apache License 2.0
from Dsiner
with Apache License 2.0
from Dsiner
@Override
public void applyOptions(Context context, GlideBuilder builder) {
builder.setDefaultRequestOptions(new RequestOptions().format(DecodeFormat.PREFER_RGB_565)).setDiskCache(new ExternalCacheDiskCacheFactory(context, getCachePath(), 1024 * 1024 * 1024)).setMemoryCache(new LruResourceCache(6 * 1024 * 1024)).setBitmapPool(new LruBitmapPool(6 * 1024 * 1024));
}
18
Source : CustomGlideModule.java
with GNU General Public License v3.0
from dkanada
with GNU General Public License v3.0
from dkanada
@Override
public void applyOptions(@NonNull Context context, GlideBuilder builder) {
File cacheDir = new File(context.getCacheDir(), "glide");
int size = PreferenceUtil.getInstance(context).getImageCacheSize();
builder.setDiskCache(new DiskLruCacheFactory(() -> cacheDir, size));
builder.setDefaultRequestOptions(new RequestOptions().format(DecodeFormat.PREFER_RGB_565));
}
18
Source : MyGlideModule.java
with Apache License 2.0
from Delsart
with Apache License 2.0
from Delsart
@Override
public void applyOptions(Context context, GlideBuilder builder) {
int diskCacheSizeBytes = 1024 * 1024 * 16;
builder.setDiskCache(new ExternalCacheDiskCacheFactory(context, diskCacheSizeBytes));
}
18
Source : GlideConfigModule.java
with Apache License 2.0
from d4rken
with Apache License 2.0
from d4rken
@Override
public void applyOptions(Context context, GlideBuilder builder) {
// builder.setDefaultRequestOptions(RequestOptions.diskCacheStrategyOf(DiskCacheStrategy.NONE));
}
18
Source : TextSecureGlideModule.java
with GNU General Public License v3.0
from CryptoGuardOSS
with GNU General Public License v3.0
from CryptoGuardOSS
@Override
public void applyOptions(Context context, GlideBuilder builder) {
builder.setDiskCache(new NoopDiskCacheFactory());
}
18
Source : MyAppGlideModule.java
with Apache License 2.0
from chongyucaiyan
with Apache License 2.0
from chongyucaiyan
@Override
public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
builder.setDefaultRequestOptions(new RequestOptions().format(DecodeFormat.PREFER_RGB_565)).setMemoryCache(new LruResourceCache(SIZE_MEMORY_CACHE)).setDiskCache(new InternalCacheDiskCacheFactory(context, SIZE_DISK_CACHE));
}
18
Source : ExploreGlideModule.java
with MIT License
from chejdj
with MIT License
from chejdj
@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));
}
18
Source : TextSecureGlideModule.java
with GNU General Public License v3.0
from CableIM
with GNU General Public License v3.0
from CableIM
@Override
public void applyOptions(Context context, GlideBuilder builder) {
// builder.setDiskCache(new NoopDiskCacheFactory());
}
18
Source : CustomGlideModule.java
with Apache License 2.0
from BrianSpace
with Apache License 2.0
from BrianSpace
@Override
public void applyOptions(final Context context, final GlideBuilder builder) {
builder.setDiskCache(new ExternalPreferredCacheDiskCacheFactory(context));
}
18
Source : CustomGlideModule.java
with GNU General Public License v3.0
from apcro
with GNU General Public License v3.0
from apcro
@Override
public void applyOptions(Context context, GlideBuilder builder) {
// Apply options to the builder here.
/*builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888);
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;
builder.setDiskCache(
new InternalCacheDiskCacheFactory(context, cacheSize100MegaBytes)
);*/
}
17
Source : GlideConfiguration.java
with Apache License 2.0
from Zweihui
with Apache License 2.0
from Zweihui
@Override
public void applyOptions(Context context, GlideBuilder builder) {
AppComponent appComponent = ArmsUtils.obtainAppComponentFromContext(context);
builder.setDiskCache(new DiskCache.Factory() {
@Override
public DiskCache build() {
// Careful: the external cache directory doesn't enforce permissions
return DiskLruCacheWrapper.get(DataHelper.makeDirs(new File(appComponent.cacheFile(), "Glide")), IMAGE_DISK_CACHE_MAX_SIZE);
}
});
MemorySizeCalculator calculator = new MemorySizeCalculator.Builder(context).build();
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));
// 将配置 Glide 的机会转交给 GlideImageLoaderStrategy,如你觉得框架提供的 GlideImageLoaderStrategy
// 并不能满足自己的需求,想自定义 BaseImageLoaderStrategy,那请你最好实现 GlideAppliesOptions
// 因为只有成为 GlideAppliesOptions 的实现类,这里才能调用 applyGlideOptions(),让你具有配置 Glide 的权利
BaseImageLoaderStrategy loadImgStrategy = appComponent.imageLoader().getLoadImgStrategy();
if (loadImgStrategy instanceof GlideAppliesOptions) {
((GlideAppliesOptions) loadImgStrategy).applyGlideOptions(context, builder);
}
}
17
Source : GlideConfigModule.java
with Apache License 2.0
from zetaapps
with Apache License 2.0
from zetaapps
@Override
public void applyOptions(Context context, GlideBuilder builder) {
builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888);
}
17
Source : MGlideModule.java
with Apache License 2.0
from Yuphee
with Apache License 2.0
from Yuphee
@Override
public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
int memorySize = activityManager.getMemoryClreplaced();
builder.setDefaultRequestOptions(new RequestOptions().format(DecodeFormat.PREFER_RGB_565).disallowHardwareConfig()).setMemoryCache(new LruResourceCache(memorySize / 4));
}
17
Source : GlideConfiguration.java
with Apache License 2.0
from yongjhih
with Apache License 2.0
from yongjhih
@Override
public void applyOptions(Context context, GlideBuilder builder) {
// 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);
}
17
Source : MyGlideModule.java
with Apache License 2.0
from yangchaojiang
with Apache License 2.0
from yangchaojiang
@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);
}
17
Source : GlideConfiguration.java
with Apache License 2.0
from xiaobailong24
with Apache License 2.0
from xiaobailong24
@Override
public void applyOptions(Context context, GlideBuilder builder) {
super.applyOptions(context, builder);
builder.setDiskCache(new DiskCache.Factory() {
@Nullable
@Override
public DiskCache build() {
// Careful: the external cache directory doesn't enforce permissions
return DiskLruCacheWrapper.get(DataHelper.makeDirs(new File(RepositoryUtils.INSTANCE.obtainRepositoryComponent(context).cacheFile(), "Glide")), IMAGE_DISK_CACHE_MAX_SIZE);
}
});
MemorySizeCalculator calculator = new MemorySizeCalculator.Builder(context).build();
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));
// 将配置 Glide 的机会转交给 GlideImageLoaderStrategy,如你觉得框架提供的 GlideImageLoaderStrategy
// 并不能满足自己的需求,想自定义 BaseImageLoaderStrategy,那请你最好实现 GlideAppliesOptions
// 因为只有成为 GlideAppliesOptions 的实现类,这里才能调用 applyGlideOptions(),让你具有配置 Glide 的权利
BaseImageLoaderStrategy imageLoaderStrategy = ArmsUtils.INSTANCE.obtainArmsComponent(context).imageLoader().getStrategy();
if (imageLoaderStrategy instanceof GlideAppliesOptions) {
((GlideAppliesOptions) imageLoaderStrategy).applyGlideOptions(context, builder);
}
}
17
Source : GlideConfiguration.java
with Apache License 2.0
from xiaobailong24
with Apache License 2.0
from xiaobailong24
@Override
public void applyOptions(Context context, GlideBuilder builder) {
AppComponent appComponent = ((App) context.getApplicationContext()).getAppComponent();
builder.setDiskCache(new DiskCache.Factory() {
@Override
public DiskCache build() {
// Careful: the external cache directory doesn't enforce permissions
return DiskLruCacheWrapper.get(DataHelper.makeDirs(new File(appComponent.cacheFile(), "Glide")), IMAGE_DISK_CACHE_MAX_SIZE);
}
});
MemorySizeCalculator calculator = new MemorySizeCalculator.Builder(context).build();
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));
// 将配置 Glide 的机会转交给 GlideImageLoaderStrategy,如你觉得框架提供的 GlideImageLoaderStrategy
// 并不能满足自己的需求,想自定义 BaseImageLoaderStrategy,那请你最好实现 GlideAppliesOptions
// 因为只有成为 GlideAppliesOptions 的实现类,这里才能调用 applyGlideOptions(),让你具有配置 Glide 的权利
BaseImageLoaderStrategy loadImgStrategy = appComponent.imageLoader().getLoadImgStrategy();
if (loadImgStrategy instanceof GlideAppliesOptions) {
((GlideAppliesOptions) loadImgStrategy).applyGlideOptions(context, builder);
}
}
17
Source : GlideConfig.java
with Apache License 2.0
from wzx54321
with Apache License 2.0
from wzx54321
@Override
public void applyOptions(final Context context, final GlideBuilder builder) {
builder.setDiskCache(new ExternalCacheDiskCacheFactory(context, 1024 * 1024 * 500));
MemorySizeCalculator calculator = new MemorySizeCalculator.Builder(context).build();
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));
}
17
Source : MyGlideModuleConfig.java
with GNU General Public License v2.0
from wzc25151
with GNU General Public License v2.0
from wzc25151
@Override
public void applyOptions(Context context, GlideBuilder builder) {
// builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888);
if (AppUtil.hreplacedDCard()) {
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));
}
17
Source : AuroraGlide.java
with GNU General Public License v3.0
from whyorean
with GNU General Public License v3.0
from whyorean
@Override
public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
int memoryCacheSizeBytes = 1024 * 1024 * 50;
builder.setMemoryCache(new LruResourceCache(memoryCacheSizeBytes));
builder.setDiskCache(new InternalCacheDiskCacheFactory(context, memoryCacheSizeBytes));
builder.setDefaultRequestOptions(requestOptions());
builder.setLogLevel(Log.ERROR);
}
17
Source : GlideModule.java
with Apache License 2.0
from velmurugan35
with Apache License 2.0
from velmurugan35
@Override
public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
builder.setDefaultRequestOptions(RequestOptions.formatOf(DecodeFormat.PREFER_ARGB_8888));
}
See More Examples