From 8529b30b91a3af235cda52ea0889ae9af7590129 Mon Sep 17 00:00:00 2001 From: Chet Haase Date: Thu, 12 Sep 2013 11:19:32 -0700 Subject: Fix TechChange's assumption about TextView targets Some of the code in the TextChange transition assumed that the start values for a transition were for a TextView object. This may not be the case, and we should return early (without creating an animator) when it is not. Issue #10725388 Frequent Framework crashes across apps Change-Id: I6999eb2288f107f4b93ddb5b77cd068069d831ed --- core/java/android/transition/TextChange.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/java/android/transition/TextChange.java b/core/java/android/transition/TextChange.java index 4f14d462675d..0b1e4e1373e8 100644 --- a/core/java/android/transition/TextChange.java +++ b/core/java/android/transition/TextChange.java @@ -137,14 +137,17 @@ public class TextChange extends Transition { @Override public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) { - if (startValues == null || endValues == null || !(endValues.view instanceof TextView)) { + if (startValues == null || endValues == null || + !(startValues.view instanceof TextView) || !(endValues.view instanceof TextView)) { return null; } final TextView view = (TextView) endValues.view; Map startVals = startValues.values; Map endVals = endValues.values; - final CharSequence startText = (CharSequence) startVals.get(PROPNAME_TEXT); - final CharSequence endText = (CharSequence) endVals.get(PROPNAME_TEXT); + final CharSequence startText = startVals.get(PROPNAME_TEXT) != null ? + (CharSequence) startVals.get(PROPNAME_TEXT) : ""; + final CharSequence endText = endVals.get(PROPNAME_TEXT) != null ? + (CharSequence) endVals.get(PROPNAME_TEXT) : ""; if (!startText.equals(endText)) { view.setText(startText); Animator anim; -- cgit v1.2.3-59-g8ed1b