本文整理汇总了Java中com.onegravity.rteditor.utils.Helper.getLeadingMarging方法的典型用法代码示例。如果您正苦于以下问题:Java Helper.getLeadingMarging方法的具体用法?Java Helper.getLeadingMarging怎么用?Java Helper.getLeadingMarging使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.onegravity.rteditor.utils.Helper
的用法示例。
在下文中一共展示了Helper.getLeadingMarging方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getIndentation
import com.onegravity.rteditor.utils.Helper; //导入方法依赖的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.utils.Helper; //导入方法依赖的package包/类
@Override
public synchronized void applyToSelection(RTEditText editor, Selection selectedParagraphs, Boolean enable) {
final Spannable str = editor.getText();
mSpans2Process.clear();
for (Paragraph paragraph : editor.getParagraphs()) {
// find existing BulletSpan and add them to mSpans2Process to be removed
List<RTSpan<Boolean>> existingSpans = getSpans(str, paragraph, SpanCollectMode.SPAN_FLAGS);
mSpans2Process.removeSpans(existingSpans, paragraph);
// if the paragraph is selected then we sure have a bullet
boolean hasExistingSpans = !existingSpans.isEmpty();
boolean hasBullet = paragraph.isSelected(selectedParagraphs) ? enable : hasExistingSpans;
// if we have a bullet then apply a new span
if (hasBullet) {
int margin = Helper.getLeadingMarging();
BulletSpan bulletSpan = new BulletSpan(margin, paragraph.isEmpty(), paragraph.isFirst(), paragraph.isLast());
mSpans2Process.addSpan(bulletSpan, paragraph);
// if the paragraph has number spans, then remove them
Effects.NUMBER.findSpans2Remove(str, paragraph, mSpans2Process);
}
}
// add or remove spans
mSpans2Process.process(str);
}
示例3: applyToSelection
import com.onegravity.rteditor.utils.Helper; //导入方法依赖的package包/类
@Override
public synchronized void applyToSelection(RTEditText editor, Selection selectedParagraphs, Boolean enable) {
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 BulletSpan and add them to mSpans2Process to be removed
List<RTSpan<Boolean>> existingSpans = getSpans(str, paragraph, SpanCollectMode.SPAN_FLAGS);
mSpans2Process.removeSpans(existingSpans, paragraph);
// if the paragraph is selected then we sure have a bullet
boolean hasExistingSpans = !existingSpans.isEmpty();
boolean hasBullet = paragraph.isSelected(selectedParagraphs) ? enable : hasExistingSpans;
// if we have a bullet then apply a new span
if (hasBullet) {
int margin = Helper.getLeadingMarging();
BulletSpan bulletSpan = new BulletSpan(margin, paragraph.isEmpty(), paragraph.isFirst(), paragraph.isLast());
mSpans2Process.addSpan(bulletSpan, paragraph);
// if the paragraph has number spans, then remove them
Effects.NUMBER.findSpans2Remove(str, paragraph, mSpans2Process);
}
}
// add or remove spans
mSpans2Process.process(str);
}
示例4: applyToSelection
import com.onegravity.rteditor.utils.Helper; //导入方法依赖的package包/类
@Override
public synchronized void applyToSelection(RTEditText editor, Selection selectedParagraphs, Boolean enable) {
final Spannable str = editor.getText();
mSpans2Process.clear();
int lineNr = 1;
SparseIntArray indentations = new SparseIntArray();
SparseIntArray numbers = new SparseIntArray();
for (Paragraph paragraph : editor.getParagraphs()) {
/*
* We need to know the indentation for each paragraph to be able
* to determine which paragraphs belong together (same indentation)
*/
int currentIndentation = 0;
List<RTSpan<Integer>> indentationSpans = Effects.INDENTATION.getSpans(str, paragraph, SpanCollectMode.EXACT);
if (! indentationSpans.isEmpty()) {
for (RTSpan<Integer> span : indentationSpans) {
currentIndentation += span.getValue();
}
}
indentations.put(lineNr, currentIndentation);
// find existing NumberSpans and add them to mSpans2Process to be removed
List<RTSpan<Boolean>> existingSpans = getSpans(str, paragraph, SpanCollectMode.SPAN_FLAGS);
mSpans2Process.removeSpans(existingSpans, paragraph);
/*
* If the paragraph is selected then we sure have a number
*/
boolean hasExistingSpans = ! existingSpans.isEmpty();
boolean hasNumber = paragraph.isSelected(selectedParagraphs) ? enable : hasExistingSpans;
/*
* If we have a number then apply a new span
*/
if (hasNumber) {
// let's determine the number for this paragraph
int nr = 1;
for (int line = 1; line < lineNr; line++) {
int indentation = indentations.get(line);
int number = numbers.get(line);
if (indentation < currentIndentation) {
// 1) less indentation -> number 1
nr = 1;
} else if (indentation == currentIndentation) {
// 2) same indentation + no numbering -> number 1
// 3) same indentation + numbering -> increment number
nr = number == 0 ? 1 : number + 1;
}
}
numbers.put(lineNr, nr);
int margin = Helper.getLeadingMarging();
NumberSpan numberSpan = new NumberSpan(nr++, margin, paragraph.isEmpty(), paragraph.isFirst(), paragraph.isLast());
mSpans2Process.addSpan(numberSpan, paragraph);
// if the paragraph has bullet spans, then remove them
Effects.BULLET.findSpans2Remove(str, paragraph, mSpans2Process);
}
lineNr++;
}
// add or remove spans
mSpans2Process.process(str);
}
示例5: applyToSelection
import com.onegravity.rteditor.utils.Helper; //导入方法依赖的package包/类
@Override
public synchronized void applyToSelection(RTEditText editor, Selection selectedParagraphs, Boolean enable) {
final Spannable str = editor.getText();
mSpans2Process.clear();
int lineNr = 1;
SparseIntArray indentations = new SparseIntArray();
SparseIntArray numbers = new SparseIntArray();
// 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);
/*
* We need to know the indentation for each paragraph to be able
* to determine which paragraphs belong together (same indentation)
*/
int currentIndentation = 0;
List<RTSpan<Integer>> indentationSpans = Effects.INDENTATION.getSpans(str, paragraph, SpanCollectMode.EXACT);
if (! indentationSpans.isEmpty()) {
for (RTSpan<Integer> span : indentationSpans) {
currentIndentation += span.getValue();
}
}
indentations.put(lineNr, currentIndentation);
// find existing NumberSpans and add them to mSpans2Process to be removed
List<RTSpan<Boolean>> existingSpans = getSpans(str, paragraph, SpanCollectMode.SPAN_FLAGS);
mSpans2Process.removeSpans(existingSpans, paragraph);
/*
* If the paragraph is selected then we sure have a number
*/
boolean hasExistingSpans = ! existingSpans.isEmpty();
boolean hasNumber = paragraph.isSelected(selectedParagraphs) ? enable : hasExistingSpans;
/*
* If we have a number then apply a new span
*/
if (hasNumber) {
// let's determine the number for this paragraph
int nr = 1;
for (int line = 1; line < lineNr; line++) {
int indentation = indentations.get(line);
int number = numbers.get(line);
if (indentation < currentIndentation) {
// 1) less indentation -> number 1
nr = 1;
} else if (indentation == currentIndentation) {
// 2) same indentation + no numbering -> number 1
// 3) same indentation + numbering -> increment number
nr = number == 0 ? 1 : number + 1;
}
}
numbers.put(lineNr, nr);
int margin = Helper.getLeadingMarging();
NumberSpan numberSpan = new NumberSpan(nr++, margin, paragraph.isEmpty(), paragraph.isFirst(), paragraph.isLast());
mSpans2Process.addSpan(numberSpan, paragraph);
// if the paragraph has bullet spans, then remove them
Effects.BULLET.findSpans2Remove(str, paragraph, mSpans2Process);
}
lineNr++;
}
// add or remove spans
mSpans2Process.process(str);
}