Skip to content
Snippets Groups Projects
Commit 8ec36be4 authored by Tadashi G. Takaoka's avatar Tadashi G. Takaoka
Browse files

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

This change is followup of Iadc11992

Bug: 3230726
Change-Id: I4f6692c3dbfb42986d478f4315105726ff89723a
parent 71890a78
No related branches found
No related tags found
No related merge requests found
...@@ -55,7 +55,7 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo ...@@ -55,7 +55,7 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
private final int mColorNormal; private final int mColorNormal;
private final int mColorRecommended; private final int mColorRecommended;
private final int mColorOther; 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 static final CharacterStyle UNDERLINE_SPAN = new UnderlineSpan();
private boolean mShowingCompletions; private boolean mShowingCompletions;
...@@ -146,13 +146,15 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo ...@@ -146,13 +146,15 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
tv.setTextColor(mColorNormal); tv.setTextColor(mColorNormal);
if (haveMinimalSuggestion if (haveMinimalSuggestion
&& ((i == 1 && !typedWordValid) || (i == 0 && typedWordValid))) { && ((i == 1 && !typedWordValid) || (i == 0 && typedWordValid))) {
final Spannable word = new SpannableString(suggestion); final CharacterStyle style;
if (mConfigCandidateHighlightFontColorEnabled) { if (mConfigCandidateHighlightFontColorEnabled) {
word.setSpan(BOLD_SPAN, 0, wordLength, Spannable.SPAN_INCLUSIVE_EXCLUSIVE); style = BOLD_SPAN;
tv.setTextColor(mColorRecommended); tv.setTextColor(mColorRecommended);
} else { } 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; suggestion = word;
existsAutoCompletion = true; existsAutoCompletion = true;
} else if (i != 0 || (wordLength == 1 && count > 1)) { } else if (i != 0 || (wordLength == 1 && count > 1)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment