From 54204d9ca705845eee0dc3ddcaf830b9b922fca9 Mon Sep 17 00:00:00 2001 From: Christine Chen Date: Fri, 6 Sep 2013 16:29:45 -0700 Subject: Adds null pointer check for AnimationUtils. Bug: 10637805 Change-Id: Ia3574902b2f34d8150d6abdd47037985b88325e1 --- InCallUI/src/com/android/incallui/AnimationUtils.java | 16 +++++++++++----- 1 file 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); -- cgit v1.2.3