From af7dcdf35a37d7a7dbaad7d9869c1c91bce2272b Mon Sep 17 00:00:00 2001 From: Victoria Lease Date: Thu, 24 Oct 2013 12:35:42 -0700 Subject: use SpannedStringBuilder to build a SpannedString It turns out that copy constructors do not respect NoCopySpan. Using SpannedStringBuilder addresses this oversight. Bug: 11326070 Change-Id: I949ef4f477d65cf645f3b1b2651f8ce423995237 --- core/java/android/widget/TextView.java | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'core/java/android/widget/TextView.java') diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index cb930d6fbcb2..7a9809fda605 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -56,6 +56,7 @@ import android.text.Selection; import android.text.SpanWatcher; import android.text.Spannable; import android.text.SpannableString; +import android.text.SpannableStringBuilder; import android.text.Spanned; import android.text.SpannedString; import android.text.StaticLayout; @@ -3494,19 +3495,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener ss.selEnd = end; if (mText instanceof Spanned) { - /* - * Calling setText() strips off any ChangeWatchers; - * strip them now to avoid leaking references. - * But do it to a copy so that if there are any - * further changes to the text of this view, it - * won't get into an inconsistent state. - */ - - Spannable sp = new SpannableString(mText); - - for (ChangeWatcher cw : sp.getSpans(0, sp.length(), ChangeWatcher.class)) { - sp.removeSpan(cw); - } + Spannable sp = new SpannableStringBuilder(mText); if (mEditor != null) { removeMisspelledSpans(sp); -- cgit v1.2.3