提交 48754e61 编写于 作者: S Sam Judd

Fix lint/pmd/findbugs errors.

上级 d836ac20
......@@ -27,7 +27,7 @@ public enum DecodeFormat {
/**
* Identical to {@link #PREFER_ARGB_8888} but prevents Glide from using {@link
* android.graphics.Bitmap.Config#HARDWARE} on Android O+
* android.graphics.Bitmap.Config#HARDWARE} on Android O+.
*
* @deprecated If you must disable hardware bitmaps, set
* {@link com.bumptech.glide.load.resource.bitmap.Downsampler#ALLOW_HARDWARE_CONFIG} to false
......
......@@ -478,7 +478,9 @@ class DecodeJob<R> implements DataFetcherGenerator.FetcherReadyCallback,
Options options = getOptionsWithHardwareConfig(dataSource);
DataRewinder<Data> rewinder = glideContext.getRegistry().getRewinder(data);
try {
return path.load(rewinder, options, width, height, new DecodeCallback<>(dataSource));
// ResourceType in DecodeCallback below is required for compilation to work with gradle.
return path.load(
rewinder, options, width, height, new DecodeCallback<ResourceType>(dataSource));
} finally {
rewinder.cleanup();
}
......
......@@ -142,16 +142,23 @@ public class LruBitmapPool implements BitmapPool {
return result;
}
@Nullable
private synchronized Bitmap getDirtyOrNull(int width, int height, Bitmap.Config config) {
@TargetApi(Build.VERSION_CODES.O)
private static void assertNotHardwareConfig(Bitmap.Config config) {
// Avoid short circuiting on sdk int since it breaks on some versions of Android.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (config == Bitmap.Config.HARDWARE) {
throw new IllegalArgumentException("Cannot create a mutable Bitmap with config: " + config
+ ". Consider setting Downsampler#ALLOW_HARDWARE_CONFIG to false in your RequestOptions"
+ " and/or in GlideBuilder.setDefaultRequestOptions");
}
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
return;
}
if (config == Bitmap.Config.HARDWARE) {
throw new IllegalArgumentException("Cannot create a mutable Bitmap with config: " + config
+ ". Consider setting Downsampler#ALLOW_HARDWARE_CONFIG to false in your RequestOptions"
+ " and/or in GlideBuilder.setDefaultRequestOptions");
}
}
@Nullable
private synchronized Bitmap getDirtyOrNull(int width, int height, Bitmap.Config config) {
assertNotHardwareConfig(config);
// Config will be null for non public config types, which can lead to transformations naively
// passing in null as the requested config here. See issue #194.
final Bitmap result = strategy.get(width, height, config != null ? config : DEFAULT_CONFIG);
......
......@@ -194,8 +194,8 @@ public final class Downsampler {
DecodeFormat decodeFormat = options.get(DECODE_FORMAT);
DownsampleStrategy downsampleStrategy = options.get(DOWNSAMPLE_STRATEGY);
boolean fixBitmapToRequestedDimensions = options.get(FIX_BITMAP_SIZE_TO_REQUESTED_DIMENSIONS);
boolean isHardwareConfigAllowed = options.get(ALLOW_HARDWARE_CONFIG) != null
? options.get(ALLOW_HARDWARE_CONFIG) : false;
boolean isHardwareConfigAllowed =
options.get(ALLOW_HARDWARE_CONFIG) != null && options.get(ALLOW_HARDWARE_CONFIG);
if (decodeFormat == DecodeFormat.PREFER_ARGB_8888_DISALLOW_HARDWARE) {
isHardwareConfigAllowed = false;
}
......
package com.bumptech.glide.load.resource.bitmap;
import android.annotation.TargetApi;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Build;
......@@ -70,6 +71,7 @@ final class HardwareConfigState {
// Singleton constructor.
}
@TargetApi(Build.VERSION_CODES.O)
boolean setHardwareConfigIfAllowed(
int targetWidth,
int targetHeight,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册