Cleanup calling Spannable.setSpan() to set character style span
This change is followup of Iadc11992 Bug: 3230726 Change-Id: I4f6692c3dbfb42986d478f4315105726ff89723a
This commit is contained in:
parent
71890a78b0
commit
8ec36be4f5
1 changed files with 6 additions and 4 deletions
|
@ -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
|
||||||
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)) {
|
||||||
|
|
Loading…
Reference in a new issue