From 0c6fe7e60e7550e56ad1982d0d5833b64eea6f97 Mon Sep 17 00:00:00 2001 From: mindyp Date: Sat, 29 Sep 2012 12:39:15 -0700 Subject: cherrypick: Fix crashes associated with new logic to replace entire address with name + address Fixes b/7257614 crash when replying to a message Change-Id: I6dcda376073f941fba4b09a647bdb00a92e4ccce --- chips/src/com/android/ex/chips/RecipientEditTextView.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/chips/src/com/android/ex/chips/RecipientEditTextView.java b/chips/src/com/android/ex/chips/RecipientEditTextView.java index 013a238..a604807 100644 --- a/chips/src/com/android/ex/chips/RecipientEditTextView.java +++ b/chips/src/com/android/ex/chips/RecipientEditTextView.java @@ -2361,12 +2361,11 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements mHandler.post(new Runnable() { @Override public void run() { - SpannableStringBuilder text = new SpannableStringBuilder(getText() - .toString()); Editable oldText = getText(); int start, end; int i = 0; for (RecipientChip chip : originalRecipients) { + // Find the location of the chip in the text currently shown. start = oldText.getSpanStart(chip); if (start != -1) { end = oldText.getSpanEnd(chip); @@ -2378,13 +2377,14 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements createAddressText(replacement.getEntry()).trim()); displayText.setSpan(replacement, 0, displayText.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); - text.replace(start, end, displayText); + // Replace the old text we found with with the new display text, + // which now may also contain the display name of the recipient. + oldText.replace(start, end, displayText); replacement.setOriginalText(displayText.toString()); } i++; } originalRecipients.clear(); - setText(text); } }); } -- cgit v1.2.3