本文整理汇总了Java中com.onegravity.rteditor.spans.IndentationSpan类的典型用法代码示例。如果您正苦于以下问题:Java IndentationSpan类的具体用法?Java IndentationSpan怎么用?Java IndentationSpan使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IndentationSpan类属于com.onegravity.rteditor.spans包,在下文中一共展示了IndentationSpan类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getIndentation
import com.onegravity.rteditor.spans.IndentationSpan; //导入依赖的package包/类
public int getIndentation() {
if (mType.isIndentation()) {
float margin = Helper.getLeadingMarging();
float indentation = ((IndentationSpan) mStyle).getValue();
return Math.round(indentation / margin);
} else if (mType.isBullet() || mType.isNumbering()) {
return 1;
}
return 0;
}
示例2: applyToSelection
import com.onegravity.rteditor.spans.IndentationSpan; //导入依赖的package包/类
@Override
public void applyToSelection(RTEditText editor, Selection selectedParagraphs, Integer increment) {
final Spannable str = editor.getText();
mSpans2Process.clear();
for (Paragraph paragraph : editor.getParagraphs()) {
// find existing IndentationSpan and add them to mSpans2Process to be removed
List<RTSpan<Integer>> existingSpans = getSpans(str, paragraph, SpanCollectMode.EXACT);
mSpans2Process.removeSpans(existingSpans, paragraph);
// compute the indentation
int indentation = 0;
for (RTSpan<Integer> span : existingSpans) {
indentation += span.getValue();
// Only consider the first span since the span flags (SPAN_EXCLUSIVE_INCLUSIVE)
// can lead to a paragraph having two IndentationSpans after hitting enter/return.
break;
}
// if the paragraph is selected inc/dec the existing indentation
int incIndentation = increment == null ? 0 : increment;
indentation += paragraph.isSelected(selectedParagraphs) ? incIndentation : 0;
// if we have an indentation then apply a new span
if (indentation > 0) {
IndentationSpan leadingMarginSpan = new IndentationSpan(indentation, paragraph.isEmpty(), paragraph.isFirst(), paragraph.isLast());
mSpans2Process.addSpan(leadingMarginSpan, paragraph);
}
}
// add or remove spans
mSpans2Process.process(str);
}
示例3: applyToSelection
import com.onegravity.rteditor.spans.IndentationSpan; //导入依赖的package包/类
public void applyToSelection(RTEditText editor, Selection selectedParagraphs, Integer increment) {
final Spannable str = editor.getText();
mSpans2Process.clear();
for (Paragraph paragraph : editor.getParagraphs()) {
// find existing IndentationSpan and add them to mSpans2Process to be removed
List<RTSpan<Integer>> existingSpans = getSpans(str, paragraph, SpanCollectMode.EXACT);
mSpans2Process.removeSpans(existingSpans, paragraph);
// compute the indentation
int indentation = 0;
for (RTSpan<Integer> span : existingSpans) {
indentation += span.getValue();
// Only consider the first span since the span flags (SPAN_EXCLUSIVE_INCLUSIVE)
// can lead to a paragraph having two IndentationSpans after hitting enter/return.
break;
}
// if the paragraph is selected inc/dec the existing indentation
int incIndentation = increment == null ? 0 : increment;
indentation += paragraph.isSelected(selectedParagraphs) ? incIndentation : 0;
// if we have an indentation then apply a new span
if (indentation > 0) {
IndentationSpan leadingMarginSpan = new IndentationSpan(indentation, paragraph.isEmpty(), paragraph.isFirst(), paragraph.isLast());
mSpans2Process.addSpan(leadingMarginSpan, paragraph);
}
}
// add or remove spans
mSpans2Process.process(str);
}
示例4: applyToSelection
import com.onegravity.rteditor.spans.IndentationSpan; //导入依赖的package包/类
public void applyToSelection(RTEditText editor, Selection selectedParagraphs, Integer increment) {
final Spannable str = editor.getText();
mSpans2Process.clear();
// a manual for loop is faster than the for-each loop for an ArrayList:
// see https://developer.android.com/training/articles/perf-tips.html#Loops
ArrayList<Paragraph> paragraphs = editor.getParagraphs();
for (int i = 0, size = paragraphs.size(); i < size; i++) {
Paragraph paragraph = paragraphs.get(i);
// find existing IndentationSpan and add them to mSpans2Process to be removed
List<RTSpan<Integer>> existingSpans = getSpans(str, paragraph, SpanCollectMode.EXACT);
mSpans2Process.removeSpans(existingSpans, paragraph);
// compute the indentation
int indentation = 0;
for (RTSpan<Integer> span : existingSpans) {
indentation += span.getValue();
// Only consider the first span since the span flags (SPAN_EXCLUSIVE_INCLUSIVE)
// can lead to a paragraph having two IndentationSpans after hitting enter/return.
break;
}
// if the paragraph is selected inc/dec the existing indentation
int incIndentation = increment == null ? 0 : increment;
indentation += paragraph.isSelected(selectedParagraphs) ? incIndentation : 0;
// if we have an indentation then apply a new span
if (indentation > 0) {
IndentationSpan leadingMarginSpan = new IndentationSpan(indentation, paragraph.isEmpty(), paragraph.isFirst(), paragraph.isLast());
mSpans2Process.addSpan(leadingMarginSpan, paragraph);
}
}
// add or remove spans
mSpans2Process.process(str);
}