Java Code Examples for android.text.Spanned#SPAN_INCLUSIVE_EXCLUSIVE

The following examples show how to use android.text.Spanned#SPAN_INCLUSIVE_EXCLUSIVE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RichUtils.java    From RichEditor with MIT License 5 votes vote down vote up
/**
 * 获取合并后的span flag
 *
 * @param mergedLeftSpanFlag  被合并的左侧span flag
 * @param mergedRightSpanFlag 被合并的右侧span flag
 * @return 合并后的flag
 */
private int getMergeSpanFlag(int mergedLeftSpanFlag, int mergedRightSpanFlag) {
    boolean isStartInclusive = false;  // 是否包括左端点
    boolean isEndInclusive = false;    // 是否包括右端点
    if (mergedLeftSpanFlag == Spanned.SPAN_INCLUSIVE_EXCLUSIVE
            || mergedLeftSpanFlag == Spanned.SPAN_INCLUSIVE_INCLUSIVE) {
        isStartInclusive = true;
    }

    if (mergedRightSpanFlag == Spanned.SPAN_INCLUSIVE_INCLUSIVE
            || mergedRightSpanFlag == Spanned.SPAN_EXCLUSIVE_INCLUSIVE) {
        isEndInclusive = true;
    }

    if (isStartInclusive && isEndInclusive) {
        return Spanned.SPAN_INCLUSIVE_INCLUSIVE;
    }

    if (isStartInclusive) {
        return Spanned.SPAN_INCLUSIVE_EXCLUSIVE;
    }

    if (isEndInclusive) {
        return Spanned.SPAN_EXCLUSIVE_INCLUSIVE;
    }

    return Spanned.SPAN_EXCLUSIVE_EXCLUSIVE;
}
 
Example 2
Source File: RichUtils.java    From RichEditor with MIT License 5 votes vote down vote up
/**
 * 处理行内样式各个按钮的状态(点亮或置灰)
 *
 * @param type 样式类型
 */
private boolean handleInlineStyleButtonStatus(@RichTypeEnum String type) {
    Editable editable = mRichEditText.getEditableText();
    int cursorPos = mRichEditText.getSelectionEnd();
    IInlineSpan[] inlineSpans = (IInlineSpan[]) editable.getSpans(cursorPos, cursorPos, getSpanClassFromType(type));
    if (inlineSpans.length <= 0) {
        return false;
    }

    boolean isLight = false; //是否点亮

    for (IInlineSpan span : inlineSpans) {
        int spanStart = editable.getSpanStart(span);
        int spanEnd = editable.getSpanEnd(span);
        int spanFlag = editable.getSpanFlags(span);
        if (spanStart < cursorPos && spanEnd > cursorPos) {
            isLight = true;
        } else if (spanStart == cursorPos
                && (spanFlag == Spanned.SPAN_INCLUSIVE_INCLUSIVE || spanFlag == Spanned.SPAN_INCLUSIVE_EXCLUSIVE)) {
            isLight = true;
        } else if (spanEnd == cursorPos
                && (spanFlag == Spanned.SPAN_INCLUSIVE_INCLUSIVE || spanFlag == Spanned.SPAN_EXCLUSIVE_INCLUSIVE)) {
            isLight = true;
        }
    }

    return isLight;
}
 
Example 3
Source File: LocaleSpanCompatUtils.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 5 votes vote down vote up
private static int getSpanPointMarkFlag(final boolean isStartExclusive,
        final boolean isEndExclusive) {
    if (isStartExclusive) {
        return isEndExclusive ? Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
                : Spanned.SPAN_EXCLUSIVE_INCLUSIVE;
    }
    return isEndExclusive ? Spanned.SPAN_INCLUSIVE_EXCLUSIVE
            : Spanned.SPAN_INCLUSIVE_INCLUSIVE;
}
 
Example 4
Source File: SpannableStringHelper.java    From revolution-irc with GNU General Public License v3.0 5 votes vote down vote up
public static boolean checkSpanInclude(int spanStart, int spanEnd, int spanFlags, int start, int end) {
    int pointFlags = spanFlags & Spanned.SPAN_POINT_MARK_MASK;
    boolean includesStart = pointFlags == Spanned.SPAN_INCLUSIVE_EXCLUSIVE ||
            pointFlags == Spanned.SPAN_INCLUSIVE_INCLUSIVE;
    boolean includesEnd = pointFlags == Spanned.SPAN_EXCLUSIVE_INCLUSIVE ||
            pointFlags == Spanned.SPAN_INCLUSIVE_INCLUSIVE;
    return (start > spanStart || (spanStart == start && includesStart)) &&
            (end < spanEnd || (spanEnd == end && includesEnd));
}
 
Example 5
Source File: LocaleSpanCompatUtils.java    From Indic-Keyboard with Apache License 2.0 5 votes vote down vote up
private static int getSpanPointMarkFlag(final boolean isStartExclusive,
        final boolean isEndExclusive) {
    if (isStartExclusive) {
        return isEndExclusive ? Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
                : Spanned.SPAN_EXCLUSIVE_INCLUSIVE;
    }
    return isEndExclusive ? Spanned.SPAN_INCLUSIVE_EXCLUSIVE
            : Spanned.SPAN_INCLUSIVE_INCLUSIVE;
}
 
Example 6
Source File: SpanEZ.java    From SpanEZ with Apache License 2.0 4 votes vote down vote up
@Override
public StyleEZ inclusiveExclusive() {
    spanFlags = Spanned.SPAN_INCLUSIVE_EXCLUSIVE;
    return this;
}
 
Example 7
Source File: WXTextDomObject.java    From ucar-weex-core with Apache License 2.0 4 votes vote down vote up
SetSpanOperation(int start, int end, Object what) {
  this(start, end, what, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
}
 
Example 8
Source File: WXTextDomObject.java    From weex-uikit with MIT License 4 votes vote down vote up
SetSpanOperation(int start, int end, Object what) {
  this(start, end, what, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
}