}
}
+ private void addBoldSpans(String token, String col1Text, Spannable col1Spannable) {
+ int startPos = 0;
+ while ((startPos = col1Text.indexOf(token, startPos)) != -1) {
+ col1Spannable.setSpan(new StyleSpan(Typeface.BOLD), startPos, startPos
+ + token.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
+ startPos += token.length();
+ }
+ }
+
private TableLayout getView(final int position, PairEntry.Row row, ViewGroup parent,
TableLayout result) {
final Context context = parent.getContext();
final Spannable col2Spannable = new SpannableString(col2Text);
// Bold the token instances in col1.
- final Set<String> toBold = toHighlight != null ? this.toHighlight : Collections
- .singleton(row.getTokenRow(true).getToken());
- for (final String token : toBold) {
- int startPos = 0;
- while ((startPos = col1Text.indexOf(token, startPos)) != -1) {
- col1Spannable.setSpan(new StyleSpan(Typeface.BOLD), startPos, startPos
- + token.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
- startPos += token.length();
+ if (toHighlight != null) {
+ for (final String token : toHighlight) {
+ addBoldSpans(token, col1Text, col1Spannable);
}
- }
+ } else
+ addBoldSpans(row.getTokenRow(true).getToken(), col1Text, col1Spannable);
createTokenLinkSpans(col1, col1Spannable, col1Text);
createTokenLinkSpans(col2, col2Spannable, col2Text);
// Make it so we can long-click on these token rows, too:
final Spannable textSpannable = new SpannableString(text);
createTokenLinkSpans(textView, textSpannable, text);
- textView.setText(textSpannable);
if (!htmlEntries.isEmpty()) {
final ClickableSpan clickableSpan = new ClickableSpan() {
public void onClick(View widget) {
}
};
- ((Spannable) textView.getText()).setSpan(clickableSpan, 0, text.length(),
+ textSpannable.setSpan(clickableSpan, 0, text.length(),
Spannable.SPAN_INCLUSIVE_INCLUSIVE);
textView.setOnClickListener(new OnClickListener() {
@Override
}
});
}
+ textView.setText(textSpannable);
return textView;
}
textView.setMovementMethod(LinkMovementMethod.getInstance());
final Matcher matcher = CHAR_DASH.matcher(text);
while (matcher.find()) {
- spannable.setSpan(new NonLinkClickableSpan(textColorFg), matcher.start(),
+ spannable.setSpan(new NonLinkClickableSpan(), matcher.start(),
matcher.end(),
Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
}