Java Code Examples for android.text.Selection#SELECTION_END

The following examples show how to use android.text.Selection#SELECTION_END . 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: MentionsEditable.java    From Spyglass with Apache License 2.0 6 votes vote down vote up
@Override
public void setSpan(Object what, int start, int end, int flags) {
    // Do not add any spans that affect the character appearance of a mention (i.e. they overlap
    // with a MentionSpan). This helps prevent mentions from having a red underline due to the spell
    // checker. Note: SuggestionSpan was added in ICS, and different keyboards may use other kinds
    // of spans (i.e. the Motorola SpellCheckerMarkupSpan). Therefore, we cannot just filter out
    // SuggestionSpans, but rather, any span that would change the appearance of our MentionSpans.
    if (what instanceof CharacterStyle) {
        MentionSpan[] mentionSpans = getSpans(start, end, MentionSpan.class);
        if (mentionSpans != null && mentionSpans.length > 0) {
            return;
        }
    }

    // Ensure that the start and end points are set at zero initially
    // Note: This issue was seen on a Gingerbread device (start and end were both -1) and
    // prevents the device from crashing.
    if ((what == Selection.SELECTION_START || what == Selection.SELECTION_END) && length() == 0) {
        start = 0;
        end = 0;
    }

    super.setSpan(what, start, end, flags);
}
 
Example 2
Source File: MultiTapKeyListener.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public void onSpanChanged(Spannable buf,
                          Object what, int s, int e, int start, int stop) {
    if (what == Selection.SELECTION_END) {
        buf.removeSpan(TextKeyListener.ACTIVE);
        removeTimeouts(buf);
    }
}
 
Example 3
Source File: Autocomplete.java    From Autocomplete with Apache License 2.0 5 votes vote down vote up
@Override
public void onSpanChanged(Spannable text, Object what, int ostart, int oend, int nstart, int nend) {
    if (disabled || block) return;
    if (what == Selection.SELECTION_END) {
        // Selection end changed from ostart to nstart. Trigger a check.
        log("onSpanChanged: selection end moved from "+ostart+" to "+nstart);
        log("onSpanChanged: block is "+block);
        boolean b = block;
        block = true;
        if (!isPopupShowing() && policy.shouldShowPopup(text, nstart)) {
            showPopup(policy.getQuery(text));
        }
        block = b;
    }
}
 
Example 4
Source File: TextKeyListener.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
public void onSpanChanged(Spannable s, Object what, int start, int end,
                          int st, int en) {
    if (what == Selection.SELECTION_END) {
        s.removeSpan(ACTIVE);
    }
}
 
Example 5
Source File: MongolEditText.java    From mongol-library with MIT License 4 votes vote down vote up
private boolean isNonIntermediateSelectionSpan(final Spanned text, final Object span) {
    return (Selection.SELECTION_START == span || Selection.SELECTION_END == span)
            && (text.getSpanFlags(span) & Spanned.SPAN_INTERMEDIATE) == 0;
}