Skip to content

Commit 41cc06c

Browse files
angelorohitsjudd
angelorohit
authored andcommitted
Fixes issue where loading a null image with a placeholder but without a fallback drawable or error drawable would cause the loaded image to be null.
Patched from [] by angelorhoit@.
1 parent 48d1f14 commit 41cc06c

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

library/src/main/java/com/bumptech/glide/request/SingleRequest.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -381,11 +381,14 @@ private void setErrorPlaceholder() {
381381
if (model == null) {
382382
error = getFallbackDrawable();
383383
}
384-
// Either the model isn't null, or there was no fallback drawable set. Either way we should show
385-
// the error Drawable.
384+
// Either the model isn't null, or there was no fallback drawable set.
386385
if (error == null) {
387386
error = getErrorDrawable();
388387
}
388+
// The model isn't null, no fallback drawable was set or no error drawable was set.
389+
if (error == null) {
390+
error = getPlaceholderDrawable();
391+
}
389392
target.onLoadFailed(error);
390393
}
391394

library/src/test/java/com/bumptech/glide/GlideTest.java

+12
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,18 @@ public void testNullModelPrefersFallbackDrawable() {
523523
verify(target).onLoadFailed(eq(fallback));
524524
}
525525

526+
@Test
527+
public void testNullModelResolvesToUsePlaceholder() {
528+
Drawable placeholder = new ColorDrawable(Color.GREEN);
529+
530+
requestManager
531+
.load(null)
532+
.apply(placeholderOf(placeholder))
533+
.into(target);
534+
535+
verify(target).onLoadFailed(eq(placeholder));
536+
}
537+
526538
@Test
527539
public void testByteData() {
528540
byte[] data = new byte[] { 1, 2, 3, 4, 5, 6 };

0 commit comments

Comments
 (0)