use of org.wordpress.android.util.helpers.WPQuoteSpan in project WordPress-Android by wordpress-mobile.
the class HtmlUtils method fromHtml.
/**
* An alternative to Html.fromHtml() supporting {@code <ul>}, {@code <ol>}, {@code <blockquote>}
* tags and replacing EmoticonsUtils with Emojis
* @param source
* @param wpImageGetter
*/
public static SpannableStringBuilder fromHtml(String source, WPImageGetter wpImageGetter) {
SpannableStringBuilder html;
try {
html = (SpannableStringBuilder) Html.fromHtml(source, wpImageGetter, new WPHtmlTagHandler());
} catch (RuntimeException runtimeException) {
// In case our tag handler fails
html = (SpannableStringBuilder) Html.fromHtml(source, wpImageGetter, null);
}
EmoticonsUtils.replaceEmoticonsWithEmoji(html);
QuoteSpan[] spans = html.getSpans(0, html.length(), QuoteSpan.class);
for (QuoteSpan span : spans) {
html.setSpan(new WPQuoteSpan(), html.getSpanStart(span), html.getSpanEnd(span), html.getSpanFlags(span));
html.setSpan(new ForegroundColorSpan(0xFF666666), html.getSpanStart(span), html.getSpanEnd(span), html.getSpanFlags(span));
html.removeSpan(span);
}
return html;
}
Aggregations