本文整理汇总了Java中com.bumptech.glide.GlideBuilder.setDecodeFormat方法的典型用法代码示例。如果您正苦于以下问题:Java GlideBuilder.setDecodeFormat方法的具体用法?Java GlideBuilder.setDecodeFormat怎么用?Java GlideBuilder.setDecodeFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.bumptech.glide.GlideBuilder
的用法示例。
在下文中一共展示了GlideBuilder.setDecodeFormat方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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); // 默认
}
示例2: 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);
}
示例3: 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);
}
示例4: applyOptions
import com.bumptech.glide.GlideBuilder; //导入方法依赖的package包/类
@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);
}
示例5: applyOptions
import com.bumptech.glide.GlideBuilder; //导入方法依赖的package包/类
@Override
public void applyOptions(Context context, GlideBuilder builder) {
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));
}
示例6: applyOptions
import com.bumptech.glide.GlideBuilder; //导入方法依赖的package包/类
@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); // 默认(中等质量)
}
示例7: applyOptions
import com.bumptech.glide.GlideBuilder; //导入方法依赖的package包/类
@Override
public void applyOptions(Context context, GlideBuilder builder) {
// Apply options to the builder here.
builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888);
}
示例8: applyOptions
import com.bumptech.glide.GlideBuilder; //导入方法依赖的package包/类
@Override
public void applyOptions(Context context, GlideBuilder builder) {
// Set Glide decode format to the higher quality ARGB_8888 format
builder.setDecodeFormat(DecodeFormat.PREFER_RGB_565);
}
示例9: applyOptions
import com.bumptech.glide.GlideBuilder; //导入方法依赖的package包/类
@Override
public void applyOptions(Context context, GlideBuilder builder) {
builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888);
}
示例10: applyOptions
import com.bumptech.glide.GlideBuilder; //导入方法依赖的package包/类
@Override public void applyOptions(Context context, GlideBuilder builder) {
// Do nothing.
builder.setDecodeFormat(DecodeFormat.PREFER_RGB_565);
}
示例11: applyOptions
import com.bumptech.glide.GlideBuilder; //导入方法依赖的package包/类
@Override public void applyOptions(Context context, GlideBuilder builder) {
builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888);
builder.setBitmapPool(new LruBitmapPool(MAX_POOL));
builder.setMemoryCache(new LruResourceCache(MAX_POOL));
builder.setDecodeFormat(DecodeFormat.PREFER_RGB_565);
}