use of com.tool.common.widget.imageloader.BaseImageLoader in project MVPFrames by RockyQu.
the class GlideConfiguration method applyOptions.
@Override
public void applyOptions(Context context, GlideBuilder builder) {
final AppComponent component = AppUtils.obtainAppComponentFromContext(context);
builder.setDiskCache(new DiskCache.Factory() {
@Override
public DiskCache build() {
// Careful: the external cache directory doesn't enforce permissions
return DiskLruCacheWrapper.get(FileUtils.makeDirs(new File(component.getCacheFile(), "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));
// 图片框架最终会走到 GlideImageLoader 的 load 方法中进行处理
// 如果你想自己自定义图片框架或自己实现 Glide BaseImageLoader 你需要实现 GlideAppliesOptions 接口
BaseImageLoader baseImageLoader = component.getImageLoader().getImageLoader();
if (baseImageLoader instanceof GlideAppliesOptions) {
((GlideAppliesOptions) baseImageLoader).applyGlideOptions(context, builder);
}
}
Aggregations