当前位置: 首页>>代码示例>>Java>>正文


Java IndentationSpan类代码示例

本文整理汇总了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;
}
 
开发者ID:Ronak-LM,项目名称:memoir,代码行数:11,代码来源:SingleParagraphStyle.java

示例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);
}
 
开发者ID:Ronak-LM,项目名称:memoir,代码行数:36,代码来源:IndentationEffect.java

示例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);
}
 
开发者ID:Ronak-LM,项目名称:memoir,代码行数:35,代码来源:IndentationEffect.java

示例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);
}
 
开发者ID:1gravity,项目名称:Android-RTEditor,代码行数:39,代码来源:IndentationEffect.java


注:本文中的com.onegravity.rteditor.spans.IndentationSpan类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。