Skip to content

Commit

Permalink
Fixes issue where loading a null image with a placeholder but without…
Browse files Browse the repository at this point in the history
… a fallback drawable or error drawable would cause the loaded image to be null.

Patched from [] by angelorhoit@.
  • Loading branch information
angelorohit authored and sjudd committed Jun 15, 2017
1 parent 48d1f14 commit 41cc06c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -381,11 +381,14 @@ private void setErrorPlaceholder() {
if (model == null) {
error = getFallbackDrawable();
}
// Either the model isn't null, or there was no fallback drawable set. Either way we should show
// the error Drawable.
// Either the model isn't null, or there was no fallback drawable set.
if (error == null) {
error = getErrorDrawable();
}
// The model isn't null, no fallback drawable was set or no error drawable was set.
if (error == null) {
error = getPlaceholderDrawable();
}
target.onLoadFailed(error);
}

Expand Down
12 changes: 12 additions & 0 deletions library/src/test/java/com/bumptech/glide/GlideTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,18 @@ public void testNullModelPrefersFallbackDrawable() {
verify(target).onLoadFailed(eq(fallback));
}

@Test
public void testNullModelResolvesToUsePlaceholder() {
Drawable placeholder = new ColorDrawable(Color.GREEN);

requestManager
.load(null)
.apply(placeholderOf(placeholder))
.into(target);

verify(target).onLoadFailed(eq(placeholder));
}

@Test
public void testByteData() {
byte[] data = new byte[] { 1, 2, 3, 4, 5, 6 };
Expand Down

0 comments on commit 41cc06c

Please sign in to comment.