RichEditorView extends RelativeLayout implements TextWatcher, QueryTokenReceiver, SuggestionsResultListener, SuggestionsVisibilityManager { @NonNull public List<MentionSpan> getMentionSpans() { return (mMentionsEditText != null) ? mMentionsEditText.getMentionsText().getMentionSpans() : new ArrayList<>(); } RichEditorView(@NonNull Context context);  RichEditorView(@NonNull Context context, @Nullable AttributeSet attrs);  RichEditorView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr); void init(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr); void setInputFilters(@Nullable InputFilter... filters); @NonNull List<MentionSpan> getMentionSpans(); void setEditTextShouldWrapContent(boolean enabled); int getCurrentCursorLine(); void displayTextCounter(boolean display); boolean isDisplayingTextCounter(); @Override void beforeTextChanged(CharSequence s, int start, int count, int after); @Override void onTextChanged(CharSequence s, int start, int before, int count); @Override void afterTextChanged(Editable s); @NonNull @Override List<String> onQueryReceived(@NonNull QueryToken queryToken); @Override void onReceiveSuggestionsResult(final @NonNull SuggestionsResult result, final @NonNull String bucket); void displaySuggestions(boolean display); boolean isDisplayingSuggestions(); @NonNull String getCurrentTokenString(); @NonNull String getCurrentKeywordsString(); void updateSpan(@NonNull MentionSpan span); void deselectAllSpans(); void addTextChangedListener(@NonNull final TextWatcher hostTextWatcher); @NonNull MentionsEditable getText(); @Nullable Tokenizer getTokenizer(); void setText(final @NonNull CharSequence text); void setHint(final @NonNull CharSequence hint); void setInputType(final int type); void setSelection(final int index); void setTokenizer(final @NonNull Tokenizer tokenizer); void setMentionSpanFactory(@NonNull final MentionsEditText.MentionSpanFactory factory); void addMentionWatcher(@NonNull MentionsEditText.MentionWatcher watcher); void removeMentionWatcher(@NonNull MentionsEditText.MentionWatcher watcher); void setTextCountLimit(final int limit); void setWithinCountLimitTextColor(final int color); void setBeyondCountLimitTextColor(final int color); void setQueryTokenReceiver(final @Nullable QueryTokenReceiver client); void setOnRichEditorActionListener(final @Nullable OnSuggestionsVisibilityChangeListener listener); void setSuggestionsManager(final @NonNull SuggestionsVisibilityManager suggestionsVisibilityManager); void setSuggestionsListBuilder(final @NonNull SuggestionsListBuilder suggestionsListBuilder);  }
@Test public void testGetMentionSpans() { String hello = "Test mentions Shoulong Li and Deepank Gupta end test"; mRichEditor.setText(hello); assertEquals(0, mRichEditor.getMentionSpans().size()); Mentionable mention1 = new TestMention("Shoulong Li"); MentionSpan span1 = new MentionSpan(mention1); Mentionable mention2 = new TestMention("Deepank Gupta"); MentionSpan span2 = new MentionSpan(mention2); mRichEditor.getText().setSpan(span1, 14, 14 + mention1.getSuggestiblePrimaryText().length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); mRichEditor.getText().setSpan(span2, 30, 30 + mention2.getSuggestiblePrimaryText().length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); List<MentionSpan> spans = mRichEditor.getMentionSpans(); assertEquals(2, spans.size()); Mentionable result1 = spans.get(0).getMention(); Mentionable result2 = spans.get(1).getMention(); assertEquals(mention1.getSuggestiblePrimaryText(), result1.getSuggestiblePrimaryText()); assertEquals(mention1.getSuggestiblePrimaryText(), "Shoulong Li"); assertEquals(mention2.getSuggestiblePrimaryText(), result2.getSuggestiblePrimaryText()); assertEquals(mention2.getSuggestiblePrimaryText(), "Deepank Gupta"); }