summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Kennedy <skennedy@google.com>2013-04-11 13:58:25 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2013-04-11 13:58:25 -0700
commitaf7d2e85c72bebea248efd084f7f469206259d39 (patch)
tree510273eadffe25b85a33233d4ecee81565e367f0
parent15f7d4b327855c684d1ec11f48331642e8dcada1 (diff)
parentc9daed7a40dbbae4b5fd5b60f32cdca9253644aa (diff)
downloadandroid_frameworks_ex-af7d2e85c72bebea248efd084f7f469206259d39.tar.gz
android_frameworks_ex-af7d2e85c72bebea248efd084f7f469206259d39.tar.bz2
android_frameworks_ex-af7d2e85c72bebea248efd084f7f469206259d39.zip
am c9daed7a: Don\'t do chip resolving in place
* commit 'c9daed7a40dbbae4b5fd5b60f32cdca9253644aa': Don't do chip resolving in place
-rw-r--r--chips/src/com/android/ex/chips/RecipientEditTextView.java22
1 files changed, 11 insertions, 11 deletions
diff --git a/chips/src/com/android/ex/chips/RecipientEditTextView.java b/chips/src/com/android/ex/chips/RecipientEditTextView.java
index 60bb138..bfa9b6e 100644
--- a/chips/src/com/android/ex/chips/RecipientEditTextView.java
+++ b/chips/src/com/android/ex/chips/RecipientEditTextView.java
@@ -57,6 +57,7 @@ import android.text.InputType;
import android.text.Layout;
import android.text.Spannable;
import android.text.SpannableString;
+import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextPaint;
import android.text.TextUtils;
@@ -2545,11 +2546,10 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
final Runnable runnable = new Runnable() {
@Override
public void run() {
- Editable oldText = getText();
- int start, end;
+ final Editable text = new SpannableStringBuilder(getText());
int i = 0;
- for (DrawableRecipientChip chip : recipients) {
- DrawableRecipientChip replacement = replacements.get(i);
+ for (final DrawableRecipientChip chip : recipients) {
+ final DrawableRecipientChip replacement = replacements.get(i);
if (replacement != null) {
final RecipientEntry oldEntry = chip.getEntry();
final RecipientEntry newEntry = replacement.getEntry();
@@ -2559,25 +2559,24 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
if (isBetter) {
// Find the location of the chip in the text currently shown.
- start = oldText.getSpanStart(chip);
+ final int start = text.getSpanStart(chip);
if (start != -1) {
// Replacing the entirety of what the chip represented,
// including the extra space dividing it from other chips.
- end = oldText.getSpanEnd(chip) + 1;
- oldText.removeSpan(chip);
+ final int end = text.getSpanEnd(chip) + 1;
+ text.removeSpan(chip);
// Make sure we always have just 1 space at the end to
// separate this chip from the next chip.
- SpannableString displayText =
+ final SpannableString displayText =
new SpannableString(createAddressText(
- replacement.getEntry()).trim()
- + " ");
+ replacement.getEntry()).trim() + " ");
displayText.setSpan(replacement, 0,
displayText.length() - 1,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
// 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);
+ text.replace(start, end, displayText);
replacement.setOriginalText(displayText.toString());
replacements.set(i, null);
@@ -2587,6 +2586,7 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
}
i++;
}
+ setText(text);
}
};