Cleanup calling Spannable.setSpan() to set character style span

This change is followup of Iadc11992

Bug: 3230726
Change-Id: I4f6692c3dbfb42986d478f4315105726ff89723a
main
Tadashi G. Takaoka 2010-12-09 14:31:17 +09:00
parent 71890a78b0
commit 8ec36be4f5
1 changed files with 6 additions and 4 deletions

View File

@ -55,7 +55,7 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
private final int mColorNormal;
private final int mColorRecommended;
private final int mColorOther;
private static final StyleSpan BOLD_SPAN = new StyleSpan(Typeface.BOLD);
private static final CharacterStyle BOLD_SPAN = new StyleSpan(Typeface.BOLD);
private static final CharacterStyle UNDERLINE_SPAN = new UnderlineSpan();
private boolean mShowingCompletions;
@ -146,13 +146,15 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
tv.setTextColor(mColorNormal);
if (haveMinimalSuggestion
&& ((i == 1 && !typedWordValid) || (i == 0 && typedWordValid))) {
final Spannable word = new SpannableString(suggestion);
final CharacterStyle style;
if (mConfigCandidateHighlightFontColorEnabled) {
word.setSpan(BOLD_SPAN, 0, wordLength, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
style = BOLD_SPAN;
tv.setTextColor(mColorRecommended);
} else {
word.setSpan(UNDERLINE_SPAN, 0, wordLength, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
style = UNDERLINE_SPAN;
}
final Spannable word = new SpannableString(suggestion);
word.setSpan(style, 0, wordLength, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
suggestion = word;
existsAutoCompletion = true;
} else if (i != 0 || (wordLength == 1 && count > 1)) {