spyglass/src/main/java/com/linkedin/android/spyglass/ui/MentionsEditText.java
@Nullable
    protected MentionSpan getTouchedSpan(MotionEvent event) {
        Layout layout = getLayout();
        // Note: Layout can be null if text or width has recently changed, see MOB-38193
        if (event == null || layout == null) {
            return null;
        }

        int x = (int) event.getX();
        int y = (int) event.getY();

        x -= getTotalPaddingLeft();
        y -= getTotalPaddingTop();

        x += getScrollX();
        y += getScrollY();

        int line = layout.getLineForVertical(y);
        int off = layout.getOffsetForHorizontal(line, x);
        Editable text = getText();
        if (text != null && off >= getText().length()) {
            return null;
        }

        // Get the MentionSpans in the area that the user tapped
        // If one exists, call the onClick method manually
        MentionSpan[] spans = getText().getSpans(off, off, MentionSpan.class);
        if (spans.length > 0) {
            return spans[0];
        }
        return null;
    }
@Nullable
    protected MentionSpan getTouchedSpan(MotionEvent event) {
        Layout layout = getLayout();
        // Note: Layout can be null if text or width has recently changed, see MOB-38193
        if (event == null || layout == null) {
            return null;
        }

        int x = (int) event.getX();
        int y = (int) event.getY();

        x -= getTotalPaddingLeft();
        y -= getTotalPaddingTop();

        x += getScrollX();
        y += getScrollY();

        int line = layout.getLineForVertical(y);
        int off = layout.getOffsetForHorizontal(line, x);
        Editable text = getText();
        if (text != null && off >= getText().length()) {
            return null;
        }

        // Get the MentionSpans in the area that the user tapped
        // If one exists, call the onClick method manually
        MentionSpan[] spans = getText().getSpans(off, off, MentionSpan.class);
        if (spans.length > 0) {
            return spans[0];
        }
        return null;
    }
@ Nullable protected MentionSpan getTouchedSpan ( MotionEvent event ) { Layout layout = getLayout ( ) ; // Note: Layout can be null if text or width has recently changed, see MOB-38193 if ( event == null || layout == null ) { return null ; } int x = ( int ) event . getX ( ) ; int y = ( int ) event . getY ( ) ; x -= getTotalPaddingLeft ( ) ; y -= getTotalPaddingTop ( ) ; x += getScrollX ( ) ; y += getScrollY ( ) ; int line = layout . getLineForVertical ( y ) ; int off = layout . getOffsetForHorizontal ( line , x ) ; Editable text = getText ( ) ; if ( text != null && off >= getText ( ) . length ( ) ) { return null ; } // Get the MentionSpans in the area that the user tapped // If one exists, call the onClick method manually MentionSpan [ ] spans = getText ( ) . getSpans ( off , off , MentionSpan . class ) ; if ( spans . length > 0 ) { return spans [ 0 ] ; } return null ; }
Gets the {@link MentionSpan} from the {@link MentionsEditText} that was tapped.
<p>
Note: Almost all of this code is taken directly from the Android source code, see:
{@link LinkMovementMethod#onTouchEvent(TextView, Spannable, MotionEvent)}

@param event the given (@link MotionEvent}

@return the tapped {@link MentionSpan}, or null if one was not tapped
Gets the { @link MentionSpan } from the { @link MentionsEditText } that was tapped . <p > Note : Almost all of this code is taken directly from the Android source code see : { @link LinkMovementMethod#onTouchEvent ( TextView Spannable MotionEvent ) }