@Test public void testFilter_withSpannable() { final Spannable testString = new SpannableString("abc"); when(mEmojiCompat.process(any(Spannable.class), anyInt(), anyInt())).thenReturn(testString); final CharSequence result = mInputFilter.filter(testString, 0, 1, null, 0, 1); assertNotNull(result); assertSame(result, testString); verify(mEmojiCompat, times(1)).process(sameCharSequence(testString.subSequence(0, 1)), eq(0), eq(1)); }
@Override public CharSequence filter(final CharSequence source, final int sourceStart, final int sourceEnd, final Spanned dest, final int destStart, final int destEnd) { if (mTextView.isInEditMode()) { return source; } switch (EmojiCompat.get().getLoadState()){ case EmojiCompat.LOAD_STATE_SUCCEEDED: boolean process = true; if (destEnd == 0 && destStart == 0 && dest.length() == 0) { final CharSequence oldText = mTextView.getText(); if (source == oldText) { process = false; } } if (process && source != null) { final CharSequence text; if (sourceStart == 0 && sourceEnd == source.length()) { text = source; } else { text = source.subSequence(sourceStart, sourceEnd); } return EmojiCompat.get().process(text, 0, text.length()); } return source; case EmojiCompat.LOAD_STATE_LOADING: case EmojiCompat.LOAD_STATE_DEFAULT: EmojiCompat.get().registerInitCallback(getInitCallback()); return source; case EmojiCompat.LOAD_STATE_FAILED: default: return source; } }
EmojiInputFilter implements android.text.InputFilter { @Override public CharSequence filter(final CharSequence source, final int sourceStart, final int sourceEnd, final Spanned dest, final int destStart, final int destEnd) { if (mTextView.isInEditMode()) { return source; } switch (EmojiCompat.get().getLoadState()){ case EmojiCompat.LOAD_STATE_SUCCEEDED: boolean process = true; if (destEnd == 0 && destStart == 0 && dest.length() == 0) { final CharSequence oldText = mTextView.getText(); if (source == oldText) { process = false; } } if (process && source != null) { final CharSequence text; if (sourceStart == 0 && sourceEnd == source.length()) { text = source; } else { text = source.subSequence(sourceStart, sourceEnd); } return EmojiCompat.get().process(text, 0, text.length()); } return source; case EmojiCompat.LOAD_STATE_LOADING: case EmojiCompat.LOAD_STATE_DEFAULT: EmojiCompat.get().registerInitCallback(getInitCallback()); return source; case EmojiCompat.LOAD_STATE_FAILED: default: return source; } } }
EmojiInputFilter implements android.text.InputFilter { @Override public CharSequence filter(final CharSequence source, final int sourceStart, final int sourceEnd, final Spanned dest, final int destStart, final int destEnd) { if (mTextView.isInEditMode()) { return source; } switch (EmojiCompat.get().getLoadState()){ case EmojiCompat.LOAD_STATE_SUCCEEDED: boolean process = true; if (destEnd == 0 && destStart == 0 && dest.length() == 0) { final CharSequence oldText = mTextView.getText(); if (source == oldText) { process = false; } } if (process && source != null) { final CharSequence text; if (sourceStart == 0 && sourceEnd == source.length()) { text = source; } else { text = source.subSequence(sourceStart, sourceEnd); } return EmojiCompat.get().process(text, 0, text.length()); } return source; case EmojiCompat.LOAD_STATE_LOADING: case EmojiCompat.LOAD_STATE_DEFAULT: EmojiCompat.get().registerInitCallback(getInitCallback()); return source; case EmojiCompat.LOAD_STATE_FAILED: default: return source; } } EmojiInputFilter(@NonNull final TextView textView); }
EmojiInputFilter implements android.text.InputFilter { @Override public CharSequence filter(final CharSequence source, final int sourceStart, final int sourceEnd, final Spanned dest, final int destStart, final int destEnd) { if (mTextView.isInEditMode()) { return source; } switch (EmojiCompat.get().getLoadState()){ case EmojiCompat.LOAD_STATE_SUCCEEDED: boolean process = true; if (destEnd == 0 && destStart == 0 && dest.length() == 0) { final CharSequence oldText = mTextView.getText(); if (source == oldText) { process = false; } } if (process && source != null) { final CharSequence text; if (sourceStart == 0 && sourceEnd == source.length()) { text = source; } else { text = source.subSequence(sourceStart, sourceEnd); } return EmojiCompat.get().process(text, 0, text.length()); } return source; case EmojiCompat.LOAD_STATE_LOADING: case EmojiCompat.LOAD_STATE_DEFAULT: EmojiCompat.get().registerInitCallback(getInitCallback()); return source; case EmojiCompat.LOAD_STATE_FAILED: default: return source; } } EmojiInputFilter(@NonNull final TextView textView); @Override CharSequence filter(final CharSequence source, final int sourceStart,
            final int sourceEnd, final Spanned dest, final int destStart, final int destEnd); }
EmojiInputFilter implements android.text.InputFilter { @Override public CharSequence filter(final CharSequence source, final int sourceStart, final int sourceEnd, final Spanned dest, final int destStart, final int destEnd) { if (mTextView.isInEditMode()) { return source; } switch (EmojiCompat.get().getLoadState()){ case EmojiCompat.LOAD_STATE_SUCCEEDED: boolean process = true; if (destEnd == 0 && destStart == 0 && dest.length() == 0) { final CharSequence oldText = mTextView.getText(); if (source == oldText) { process = false; } } if (process && source != null) { final CharSequence text; if (sourceStart == 0 && sourceEnd == source.length()) { text = source; } else { text = source.subSequence(sourceStart, sourceEnd); } return EmojiCompat.get().process(text, 0, text.length()); } return source; case EmojiCompat.LOAD_STATE_LOADING: case EmojiCompat.LOAD_STATE_DEFAULT: EmojiCompat.get().registerInitCallback(getInitCallback()); return source; case EmojiCompat.LOAD_STATE_FAILED: default: return source; } } EmojiInputFilter(@NonNull final TextView textView); @Override CharSequence filter(final CharSequence source, final int sourceStart,
            final int sourceEnd, final Spanned dest, final int destStart, final int destEnd);  }