本文整理汇总了Java中com.facebook.react.views.text.ReactTagSpan类的典型用法代码示例。如果您正苦于以下问题:Java ReactTagSpan类的具体用法?Java ReactTagSpan怎么用?Java ReactTagSpan使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ReactTagSpan类属于com.facebook.react.views.text包,在下文中一共展示了ReactTagSpan类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: manageSpans
import com.facebook.react.views.text.ReactTagSpan; //导入依赖的package包/类
/**
* Remove and/or add {@link Spanned.SPAN_EXCLUSIVE_EXCLUSIVE} spans, since they should only exist
* as long as the text they cover is the same. All other spans will remain the same, since they
* will adapt to the new text, hence why {@link SpannableStringBuilder#replace} never removes
* them.
*/
private void manageSpans(SpannableStringBuilder spannableStringBuilder) {
Object[] spans = getText().getSpans(0, length(), Object.class);
for (int spanIdx = 0; spanIdx < spans.length; spanIdx++) {
// Remove all styling spans we might have previously set
if (ForegroundColorSpan.class.isInstance(spans[spanIdx]) ||
BackgroundColorSpan.class.isInstance(spans[spanIdx]) ||
AbsoluteSizeSpan.class.isInstance(spans[spanIdx]) ||
CustomStyleSpan.class.isInstance(spans[spanIdx]) ||
ReactTagSpan.class.isInstance(spans[spanIdx])) {
getText().removeSpan(spans[spanIdx]);
}
if ((getText().getSpanFlags(spans[spanIdx]) & Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) !=
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) {
continue;
}
Object span = spans[spanIdx];
final int spanStart = getText().getSpanStart(spans[spanIdx]);
final int spanEnd = getText().getSpanEnd(spans[spanIdx]);
final int spanFlags = getText().getSpanFlags(spans[spanIdx]);
// Make sure the span is removed from existing text, otherwise the spans we set will be
// ignored or it will cover text that has changed.
getText().removeSpan(spans[spanIdx]);
if (sameTextForSpan(getText(), spannableStringBuilder, spanStart, spanEnd)) {
spannableStringBuilder.setSpan(span, spanStart, spanEnd, spanFlags);
}
}
}