diff --git a/library/src/main/java/com/bumptech/glide/request/BaseRequestOptions.java b/library/src/main/java/com/bumptech/glide/request/BaseRequestOptions.java index 072bc63cc8..a3822e08fa 100644 --- a/library/src/main/java/com/bumptech/glide/request/BaseRequestOptions.java +++ b/library/src/main/java/com/bumptech/glide/request/BaseRequestOptions.java @@ -1363,11 +1363,21 @@ public final int getErrorId() { return errorId; } + @SuppressWarnings("WeakerAccess") + public final boolean hasErrorId() { + return isSet(ERROR_ID); + } + @SuppressWarnings("WeakerAccess") public final int getPlaceholderId() { return placeholderId; } + @SuppressWarnings("WeakerAccess") + public final boolean hasPlaceholderId() { + return isSet(PLACEHOLDER_ID); + } + @SuppressWarnings("WeakerAccess") @Nullable public final Drawable getPlaceholderDrawable() { @@ -1379,6 +1389,11 @@ public final int getFallbackId() { return fallbackId; } + @SuppressWarnings("WeakerAccess") + public final boolean hasFallbackId() { + return isSet(FALLBACK_ID); + } + @SuppressWarnings("WeakerAccess") @Nullable public final Drawable getFallbackDrawable() { diff --git a/library/src/main/java/com/bumptech/glide/request/SingleRequest.java b/library/src/main/java/com/bumptech/glide/request/SingleRequest.java index 211936b20e..b658115a54 100644 --- a/library/src/main/java/com/bumptech/glide/request/SingleRequest.java +++ b/library/src/main/java/com/bumptech/glide/request/SingleRequest.java @@ -4,6 +4,7 @@ import android.content.res.Resources.Theme; import android.graphics.drawable.Drawable; import android.util.Log; + import androidx.annotation.DrawableRes; import androidx.annotation.GuardedBy; import androidx.annotation.NonNull; @@ -387,7 +388,7 @@ public boolean isAnyResourceSet() { private Drawable getErrorDrawable() { if (errorDrawable == null) { errorDrawable = requestOptions.getErrorPlaceholder(); - if (errorDrawable == null && requestOptions.getErrorId() > 0) { + if (errorDrawable == null && requestOptions.hasErrorId()) { errorDrawable = loadDrawable(requestOptions.getErrorId()); } } @@ -398,7 +399,7 @@ private Drawable getErrorDrawable() { private Drawable getPlaceholderDrawable() { if (placeholderDrawable == null) { placeholderDrawable = requestOptions.getPlaceholderDrawable(); - if (placeholderDrawable == null && requestOptions.getPlaceholderId() > 0) { + if (placeholderDrawable == null && requestOptions.hasPlaceholderId()) { placeholderDrawable = loadDrawable(requestOptions.getPlaceholderId()); } } @@ -409,7 +410,7 @@ private Drawable getPlaceholderDrawable() { private Drawable getFallbackDrawable() { if (fallbackDrawable == null) { fallbackDrawable = requestOptions.getFallbackDrawable(); - if (fallbackDrawable == null && requestOptions.getFallbackId() > 0) { + if (fallbackDrawable == null && requestOptions.hasFallbackId()) { fallbackDrawable = loadDrawable(requestOptions.getFallbackId()); } }