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

Fix lint/pmd/findbugs errors.

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