am 4113243f: am 324df4d5: am ba8a76b0: Merge "Fix NPE in decodedBitmapDrawable" into lmp-mr1-dev
* commit '4113243f115138cc4d9e4f487b29e133c91058f7':
Fix NPE in decodedBitmapDrawable
diff --git a/src/com/android/contacts/util/ImageViewDrawableSetter.java b/src/com/android/contacts/util/ImageViewDrawableSetter.java
index e926e54..6147c39 100644
--- a/src/com/android/contacts/util/ImageViewDrawableSetter.java
+++ b/src/com/android/contacts/util/ImageViewDrawableSetter.java
@@ -97,9 +97,10 @@
return previousBitmap();
}
- final Drawable newDrawable = (compressed == null)
- ? defaultDrawable()
- : decodedBitmapDrawable(compressed);
+ Drawable newDrawable = decodedBitmapDrawable(compressed);
+ if (newDrawable == null) {
+ newDrawable = defaultDrawable();
+ }
// Remember this for next time, so that we can check if it changed.
mCompressed = compressed;
@@ -159,8 +160,14 @@
}
private BitmapDrawable decodedBitmapDrawable(byte[] compressed) {
+ if (compressed == null) {
+ return null;
+ }
final Resources rsrc = mTarget.getResources();
Bitmap bitmap = BitmapFactory.decodeByteArray(compressed, 0, compressed.length);
+ if (bitmap == null) {
+ return null;
+ }
if (bitmap.getHeight() != bitmap.getWidth()) {
// Crop the bitmap into a square.
final int size = Math.min(bitmap.getWidth(), bitmap.getHeight());