List of usage examples for android.text Spanned SPAN_PARAGRAPH
int SPAN_PARAGRAPH
To view the source code for android.text Spanned SPAN_PARAGRAPH.
Click Source Link
From source file:org.miaowo.miaowo.util.Html.java
private static void withinBlockquoteIndividual(StringBuilder out, Spanned text, int start, int end, Context context) {/*from w w w . j a v a2s. c om*/ boolean isInList = false; int next; for (int i = start; i <= end; i = next) { next = TextUtils.indexOf(text, '\n', i, end); if (next < 0) { next = end; } boolean isListItem = false; ParagraphStyle[] paragraphStyles = text.getSpans(i, next, ParagraphStyle.class); for (ParagraphStyle paragraphStyle : paragraphStyles) { final int spanFlags = text.getSpanFlags(paragraphStyle); if ((spanFlags & Spanned.SPAN_PARAGRAPH) == Spanned.SPAN_PARAGRAPH && paragraphStyle instanceof BulletSpan) { isListItem = true; break; } } if (isListItem && !isInList) { // Current paragraph is the first item in a list isInList = true; out.append("<ul>\n"); } if (isInList && !isListItem) { // Current paragraph is no longer a list item; close the previously opened list isInList = false; out.append("</ul>\n"); } String tagType = isListItem ? "li" : "p"; out.append("<").append(tagType).append(getTextDirection(text, start, next)) .append(getTextStyles(text, start, next)).append(">"); if (next - i == 0) { out.append("<br>"); } else { withinParagraph(out, text, i, next, context); } out.append("</"); out.append(tagType); out.append(">\n"); if (next == end && isInList) { isInList = false; out.append("</ul>\n"); } next++; } }