4
4
import android .content .res .Resources .Theme ;
5
5
import android .graphics .drawable .Drawable ;
6
6
import android .util .Log ;
7
+
8
+ import androidx .annotation .AnyRes ;
7
9
import androidx .annotation .DrawableRes ;
8
10
import androidx .annotation .GuardedBy ;
9
11
import androidx .annotation .NonNull ;
@@ -387,8 +389,7 @@ public boolean isAnyResourceSet() {
387
389
private Drawable getErrorDrawable () {
388
390
if (errorDrawable == null ) {
389
391
errorDrawable = requestOptions .getErrorPlaceholder ();
390
- if (errorDrawable == null && requestOptions .getErrorId () != -1 &&
391
- (requestOptions .getErrorId () & 0xff000000 ) != 0 && (requestOptions .getErrorId () & 0x00ff0000 ) != 0 ) {
392
+ if (errorDrawable == null && isValidId (requestOptions .getErrorId ())) {
392
393
errorDrawable = loadDrawable (requestOptions .getErrorId ());
393
394
}
394
395
}
@@ -399,8 +400,7 @@ private Drawable getErrorDrawable() {
399
400
private Drawable getPlaceholderDrawable () {
400
401
if (placeholderDrawable == null ) {
401
402
placeholderDrawable = requestOptions .getPlaceholderDrawable ();
402
- if (placeholderDrawable == null && requestOptions .getPlaceholderId () != -1 &&
403
- (requestOptions .getPlaceholderId () & 0xff000000 ) != 0 && (requestOptions .getPlaceholderId () & 0x00ff0000 ) != 0 ) {
403
+ if (placeholderDrawable == null && isValidId (requestOptions .getPlaceholderId ())) {
404
404
placeholderDrawable = loadDrawable (requestOptions .getPlaceholderId ());
405
405
}
406
406
}
@@ -411,14 +411,20 @@ private Drawable getPlaceholderDrawable() {
411
411
private Drawable getFallbackDrawable () {
412
412
if (fallbackDrawable == null ) {
413
413
fallbackDrawable = requestOptions .getFallbackDrawable ();
414
- if (fallbackDrawable == null && requestOptions .getFallbackId () != -1 &&
415
- (requestOptions .getFallbackId () & 0xff000000 ) != 0 && (requestOptions .getFallbackId () & 0x00ff0000 ) != 0 ) {
414
+ if (fallbackDrawable == null && isValidId (requestOptions .getFallbackId ())) {
416
415
fallbackDrawable = loadDrawable (requestOptions .getFallbackId ());
417
416
}
418
417
}
419
418
return fallbackDrawable ;
420
419
}
421
420
421
+ /**
422
+ * @see android.content.res.ResourceId.isValid
423
+ */
424
+ private static boolean isValidId (int id ) {
425
+ return id != -1 && (id & 0xff000000 ) != 0 && (id & 0x00ff0000 ) != 0 ;
426
+ }
427
+
422
428
@ GuardedBy ("requestLock" )
423
429
private Drawable loadDrawable (@ DrawableRes int resourceId ) {
424
430
Theme theme =
0 commit comments