use of com.m2mobi.markymarkcommon.markdownitems.MarkDownList in project MarkyMark-Android by M2Mobi.
the class ListRule method parseMarkDownList.
/**
* Recursive method that constructs a MarkDownList from markDown
*
* @param pMarkDownList
* Root MarkDownList item
* @param currentLevel
* current nesting level
* @return Returns a MarkDownList
*/
private void parseMarkDownList(final MarkDownList pMarkDownList, int currentLevel) {
String line = mMarkDownLines.get(mCurrentLine);
while (isList(line)) {
final int level = getNestingLevel(line);
if (level > currentLevel) {
// Create sub-list
final MarkDownList childMarkDownList = new MarkDownList(isOrdered(line), level);
pMarkDownList.getLastListItem().addChild(childMarkDownList);
parseMarkDownList(childMarkDownList, level);
} else if (level == currentLevel) {
// Add a list item
pMarkDownList.addListItem(new ListItem(getTextForLine(line)));
mCurrentLine++;
} else {
break;
}
if (mCurrentLine >= mMarkDownLines.size()) {
break;
}
line = mMarkDownLines.get(mCurrentLine);
}
}
use of com.m2mobi.markymarkcommon.markdownitems.MarkDownList in project MarkyMark-Android by M2Mobi.
the class ListDisplayItem method createLayout.
private LinearLayout createLayout(final MarkDownList pMarkDownItem, final InlineConverter<Spanned> pInlineConverter) {
LinearLayout layout = new LinearLayout(mContext);
layout.setLayoutParams(new LayoutParams(MATCH_PARENT, WRAP_CONTENT));
layout.setOrientation(LinearLayout.VERTICAL);
final List<ListItem> items = pMarkDownItem.getListItems();
for (int i = 0; i < items.size(); i++) {
final ListItem item = items.get(i);
final View view = getTextView(pMarkDownItem, pInlineConverter.convert(item.getText()), i);
layout.addView(view);
if (item.hasChild()) {
for (MarkDownList list : item.getChild()) {
final LinearLayout nestedLayout = createLayout(list, pInlineConverter);
LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params.setMargins(mIndentationSpacingPixels, 0, 0, 0);
nestedLayout.setLayoutParams(params);
layout.addView(nestedLayout);
}
}
}
return layout;
}
use of com.m2mobi.markymarkcommon.markdownitems.MarkDownList in project MarkyMark-Android by M2Mobi.
the class ListRule method toMarkDownItem.
@Override
public MarkDownItem toMarkDownItem(final List<String> pMarkDownLines) {
mMarkDownLines = pMarkDownLines;
mCurrentLine = 0;
MarkDownList list = new MarkDownList(isOrdered(mMarkDownLines.get(mCurrentLine)), 0);
parseMarkDownList(list, getNestingLevel(mMarkDownLines.get(mCurrentLine)));
return list;
}
Aggregations