Skip to content

Commit

Permalink
Fix ResourceID validation check expression
Browse files Browse the repository at this point in the history
there are three methods which have wrong expression
getFallbackDrawable()
getErrorDrawable()
getPlaceholderDrawable()
According to the official documentation, resourceID can have a negative
value, so I modified the if statement logic to include correct validation.
  • Loading branch information
hyuns66 committed Sep 9, 2024
1 parent a7351b0 commit f452e11
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,8 @@ public boolean isAnyResourceSet() {
private Drawable getErrorDrawable() {
if (errorDrawable == null) {
errorDrawable = requestOptions.getErrorPlaceholder();
if (errorDrawable == null && requestOptions.getErrorId() > 0) {
if (errorDrawable == null && requestOptions.getErrorId() != -1 &&
(requestOptions.getErrorId() & 0xff000000) != 0 && (requestOptions.getErrorId() & 0x00ff0000) != 0) {
errorDrawable = loadDrawable(requestOptions.getErrorId());
}
}
Expand All @@ -398,7 +399,8 @@ private Drawable getErrorDrawable() {
private Drawable getPlaceholderDrawable() {
if (placeholderDrawable == null) {
placeholderDrawable = requestOptions.getPlaceholderDrawable();
if (placeholderDrawable == null && requestOptions.getPlaceholderId() > 0) {
if (placeholderDrawable == null && requestOptions.getPlaceholderId() != -1 &&
(requestOptions.getPlaceholderId() & 0xff000000) != 0 && (requestOptions.getPlaceholderId() & 0x00ff0000) != 0) {
placeholderDrawable = loadDrawable(requestOptions.getPlaceholderId());
}
}
Expand All @@ -409,7 +411,8 @@ private Drawable getPlaceholderDrawable() {
private Drawable getFallbackDrawable() {
if (fallbackDrawable == null) {
fallbackDrawable = requestOptions.getFallbackDrawable();
if (fallbackDrawable == null && requestOptions.getFallbackId() > 0) {
if (fallbackDrawable == null && requestOptions.getFallbackId() != -1 &&
(requestOptions.getFallbackId() & 0xff000000) != 0 && (requestOptions.getFallbackId() & 0x00ff0000) != 0) {
fallbackDrawable = loadDrawable(requestOptions.getFallbackId());
}
}
Expand Down

0 comments on commit f452e11

Please sign in to comment.