use of android.text.style.BulletSpan in project android_frameworks_base by DirtyUnicorns.
the class HtmlToSpannedConverter method withinBlockquoteIndividual.
private static void withinBlockquoteIndividual(StringBuilder out, Spanned text, int start, int end) {
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;
}
if (next == i) {
if (isInList) {
// Current paragraph is no longer a list item; close the previously opened list
isInList = false;
out.append("</ul>\n");
}
out.append("<br>\n");
} else {
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").append(getTextStyles(text, i, next, true, false)).append(">\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, i, next)).append(getTextStyles(text, i, next, !isListItem, true)).append(">");
withinParagraph(out, text, i, next);
out.append("</");
out.append(tagType);
out.append(">\n");
if (next == end && isInList) {
isInList = false;
out.append("</ul>\n");
}
}
next++;
}
}
use of android.text.style.BulletSpan in project android_frameworks_base by crdroidandroid.
the class HtmlToSpannedConverter method withinBlockquoteIndividual.
private static void withinBlockquoteIndividual(StringBuilder out, Spanned text, int start, int end) {
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;
}
if (next == i) {
if (isInList) {
// Current paragraph is no longer a list item; close the previously opened list
isInList = false;
out.append("</ul>\n");
}
out.append("<br>\n");
} else {
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").append(getTextStyles(text, i, next, true, false)).append(">\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, i, next)).append(getTextStyles(text, i, next, !isListItem, true)).append(">");
withinParagraph(out, text, i, next);
out.append("</");
out.append(tagType);
out.append(">\n");
if (next == end && isInList) {
isInList = false;
out.append("</ul>\n");
}
}
next++;
}
}
Aggregations