diff options
author | Christine Chen <christinech@google.com> | 2013-09-06 16:29:45 -0700 |
---|---|---|
committer | Christine Chen <christinech@google.com> | 2013-09-11 10:58:04 -0700 |
commit | 54204d9ca705845eee0dc3ddcaf830b9b922fca9 (patch) | |
tree | 57e7e9b995d1e658b0ad7ae8983054f0210d4724 | |
parent | a4f0add23f17283d58912170977f211bd4b0faf0 (diff) |
Adds null pointer check for AnimationUtils.
Bug: 10637805
Change-Id: Ia3574902b2f34d8150d6abdd47037985b88325e1
-rw-r--r-- | InCallUI/src/com/android/incallui/AnimationUtils.java | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/InCallUI/src/com/android/incallui/AnimationUtils.java b/InCallUI/src/com/android/incallui/AnimationUtils.java index aef3cdfb6..d214c8569 100644 --- a/InCallUI/src/com/android/incallui/AnimationUtils.java +++ b/InCallUI/src/com/android/incallui/AnimationUtils.java @@ -209,11 +209,14 @@ public class AnimationUtils { final ImageView imageView, final Drawable from, final Drawable to) { // We skip the cross-fade when those two Drawables are equal, or they are BitmapDrawables // pointing to the same Bitmap. - final boolean areSameImage = from.equals(to) || - ((from instanceof BitmapDrawable) - && (to instanceof BitmapDrawable) - && ((BitmapDrawable) from).getBitmap() - .equals(((BitmapDrawable) to).getBitmap())); + final boolean drawableIsEqual = (from != null && to != null && from.equals(to)); + final boolean hasFromImage = ((from instanceof BitmapDrawable) && + ((BitmapDrawable) from).getBitmap() != null); + final boolean hasToImage = ((to instanceof BitmapDrawable) && + ((BitmapDrawable) to).getBitmap() != null); + final boolean areSameImage = drawableIsEqual || (hasFromImage && hasToImage && + ((BitmapDrawable) from).getBitmap().equals(((BitmapDrawable) to).getBitmap())); + if (!areSameImage) { if (FADE_DBG) { log("Start cross-fade animation for " + imageView @@ -263,6 +266,9 @@ public class AnimationUtils { imageView.setImageDrawable(transitionDrawable); transitionDrawable.startTransition(ANIMATION_DURATION); */ imageView.setTag(to); + } else if (!hasFromImage && hasToImage) { + imageView.setImageDrawable(to); + imageView.setTag(to); } else { if (FADE_DBG) { log("*Not* start cross-fade. " + imageView); |