summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wei <markwei@google.com>2013-11-11 12:54:32 -0800
committerMark Wei <markwei@google.com>2013-11-11 14:42:01 -0800
commit88e3100ef41cf50e4f40bbaab661df41e176dae2 (patch)
treefd1df6fb485cca189bf2921839660b5c15f587ab
parentbe9a52bfb24c55b6b0e0bcc5ed1859245d63dc8e (diff)
downloadbitmap-88e3100ef41cf50e4f40bbaab661df41e176dae2.tar.gz
Fix NPE in Robolectric tests.
Change-Id: Ib9422cd23940409c8301ea59f72e041972f5c58b
-rw-r--r--src/com/android/bitmap/drawable/ExtendedBitmapDrawable.java14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/com/android/bitmap/drawable/ExtendedBitmapDrawable.java b/src/com/android/bitmap/drawable/ExtendedBitmapDrawable.java
index b8b28da..b7a5c77 100644
--- a/src/com/android/bitmap/drawable/ExtendedBitmapDrawable.java
+++ b/src/com/android/bitmap/drawable/ExtendedBitmapDrawable.java
@@ -81,11 +81,17 @@ public class ExtendedBitmapDrawable extends BasicBitmapDrawable implements
final int fadeOutDurationMs = res.getInteger(R.integer.bitmap_fade_animation_duration);
mProgressDelayMs = res.getInteger(R.integer.bitmap_progress_animation_delay);
- // Placeholder is not optional because of backgroundColor.
+ // Placeholder is not optional because backgroundColor is part of it.
+ Drawable placeholder = null;
+ if (opts.placeholder != null) {
+ ConstantState constantState = opts.placeholder.getConstantState();
+ if (constantState != null) {
+ placeholder = constantState.newDrawable(res);
+ }
+ }
int placeholderSize = res.getDimensionPixelSize(R.dimen.placeholder_size);
- mPlaceholder = new Placeholder(
- opts.placeholder != null ? opts.placeholder.getConstantState().newDrawable(res)
- : null, res, placeholderSize, placeholderSize, fadeOutDurationMs, opts);
+ mPlaceholder = new Placeholder(placeholder, res, placeholderSize, placeholderSize,
+ fadeOutDurationMs, opts);
mPlaceholder.setCallback(this);
// Progress bar is optional.