本文整理汇总了Java中com.onegravity.rteditor.spans.BulletSpan类的典型用法代码示例。如果您正苦于以下问题:Java BulletSpan类的具体用法?Java BulletSpan怎么用?Java BulletSpan使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BulletSpan类属于com.onegravity.rteditor.spans包,在下文中一共展示了BulletSpan类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onSpanAdded
import com.onegravity.rteditor.spans.BulletSpan; //导入依赖的package包/类
@Override
/* SpanWatcher */
public void onSpanAdded(Spannable text, Object what, int start, int end) {
mTextChanged = true;
// we need to keep track of ordered list spans
if (what instanceof BulletSpan) {
mIsBulletSpanSelected = true;
// if text was empty then append zero width char
// in order for the bullet to be shown when the span is selected
if (text.toString().isEmpty()) {
this.append("\u200B");
}
} else if (what instanceof NumberSpan) {
mIsNumberSpanSelected = true;
// if text was empty then append zero width char
// in order for the number to be shown when the span is selected
if (text.toString().isEmpty()) {
this.append("\u200B");
}
}
if (what instanceof RTSpan && what instanceof ParagraphStyle) {
setParagraphsAreUp2Date(false);
}
}
示例2: applyToSelection
import com.onegravity.rteditor.spans.BulletSpan; //导入依赖的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: onSpanRemoved
import com.onegravity.rteditor.spans.BulletSpan; //导入依赖的package包/类
@Override
/* SpanWatcher */
public void onSpanRemoved(Spannable text, Object what, int start, int end) {
mTextChanged = true;
// we need to keep track of ordered list spans
if (what instanceof BulletSpan) {
mIsBulletSpanSelected = false;
} else if (what instanceof NumberSpan) {
mIsNumberSpanSelected = false;
}
if (what instanceof RTSpan && what instanceof ParagraphStyle) {
setParagraphsAreUp2Date(false);
}
}
示例4: applyToSelection
import com.onegravity.rteditor.spans.BulletSpan; //导入依赖的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);
}