use of com.winsonchiu.reader.data.reddit.TagHandlerReddit in project Reader by TheKeeperOfPie.
the class UtilsReddit method getFormattedHtml.
public static CharSequence getFormattedHtml(String html) {
if (TextUtils.isEmpty(html)) {
return new SpannedString("");
}
html = html.replaceAll("\n", "<br>");
CharSequence sequence = Html.fromHtml(Html.fromHtml(html).toString(), null, new TagHandlerReddit());
// Trims leading and trailing whitespace
int start = 0;
int end = sequence.length();
while (start < end && Character.isWhitespace(sequence.charAt(start))) {
start++;
}
while (end > start && Character.isWhitespace(sequence.charAt(end - 1))) {
end--;
}
return sequence.subSequence(start, end);
}
Aggregations