@Test public void testOnTextChanged_whenEmojiCompatLoading() { final Spannable testString = new SpannableString("abc"); when(mEmojiCompat.getLoadState()).thenReturn(EmojiCompat.LOAD_STATE_LOADING); mTextWatcher.onTextChanged(testString, 0, 0, 1); verify(mEmojiCompat, times(0)).process(any(Spannable.class), anyInt(), anyInt(), anyInt(), anyInt()); verify(mEmojiCompat, times(1)).registerInitCallback(any(EmojiCompat.InitCallback.class)); }
@Override public void onTextChanged(CharSequence charSequence, final int start, final int before, final int after) { if (mEditText.isInEditMode()) { return; } if (before <= after && charSequence instanceof Spannable) { switch (EmojiCompat.get().getLoadState()){ case EmojiCompat.LOAD_STATE_SUCCEEDED: final Spannable s = (Spannable) charSequence; EmojiCompat.get().process(s, start, start + after, mMaxEmojiCount, mEmojiReplaceStrategy); break; case EmojiCompat.LOAD_STATE_LOADING: case EmojiCompat.LOAD_STATE_DEFAULT: EmojiCompat.get().registerInitCallback(getInitCallback()); break; case EmojiCompat.LOAD_STATE_FAILED: default: break; } } }
EmojiTextWatcher implements android.text.TextWatcher { @Override public void onTextChanged(CharSequence charSequence, final int start, final int before, final int after) { if (mEditText.isInEditMode()) { return; } if (before <= after && charSequence instanceof Spannable) { switch (EmojiCompat.get().getLoadState()){ case EmojiCompat.LOAD_STATE_SUCCEEDED: final Spannable s = (Spannable) charSequence; EmojiCompat.get().process(s, start, start + after, mMaxEmojiCount, mEmojiReplaceStrategy); break; case EmojiCompat.LOAD_STATE_LOADING: case EmojiCompat.LOAD_STATE_DEFAULT: EmojiCompat.get().registerInitCallback(getInitCallback()); break; case EmojiCompat.LOAD_STATE_FAILED: default: break; } } } }
EmojiTextWatcher implements android.text.TextWatcher { @Override public void onTextChanged(CharSequence charSequence, final int start, final int before, final int after) { if (mEditText.isInEditMode()) { return; } if (before <= after && charSequence instanceof Spannable) { switch (EmojiCompat.get().getLoadState()){ case EmojiCompat.LOAD_STATE_SUCCEEDED: final Spannable s = (Spannable) charSequence; EmojiCompat.get().process(s, start, start + after, mMaxEmojiCount, mEmojiReplaceStrategy); break; case EmojiCompat.LOAD_STATE_LOADING: case EmojiCompat.LOAD_STATE_DEFAULT: EmojiCompat.get().registerInitCallback(getInitCallback()); break; case EmojiCompat.LOAD_STATE_FAILED: default: break; } } } EmojiTextWatcher(EditText editText); }
EmojiTextWatcher implements android.text.TextWatcher { @Override public void onTextChanged(CharSequence charSequence, final int start, final int before, final int after) { if (mEditText.isInEditMode()) { return; } if (before <= after && charSequence instanceof Spannable) { switch (EmojiCompat.get().getLoadState()){ case EmojiCompat.LOAD_STATE_SUCCEEDED: final Spannable s = (Spannable) charSequence; EmojiCompat.get().process(s, start, start + after, mMaxEmojiCount, mEmojiReplaceStrategy); break; case EmojiCompat.LOAD_STATE_LOADING: case EmojiCompat.LOAD_STATE_DEFAULT: EmojiCompat.get().registerInitCallback(getInitCallback()); break; case EmojiCompat.LOAD_STATE_FAILED: default: break; } } } EmojiTextWatcher(EditText editText); @Override void onTextChanged(CharSequence charSequence, final int start, final int before,
            final int after); @Override void beforeTextChanged(CharSequence s, int start, int count, int after); @Override void afterTextChanged(Editable s); }
EmojiTextWatcher implements android.text.TextWatcher { @Override public void onTextChanged(CharSequence charSequence, final int start, final int before, final int after) { if (mEditText.isInEditMode()) { return; } if (before <= after && charSequence instanceof Spannable) { switch (EmojiCompat.get().getLoadState()){ case EmojiCompat.LOAD_STATE_SUCCEEDED: final Spannable s = (Spannable) charSequence; EmojiCompat.get().process(s, start, start + after, mMaxEmojiCount, mEmojiReplaceStrategy); break; case EmojiCompat.LOAD_STATE_LOADING: case EmojiCompat.LOAD_STATE_DEFAULT: EmojiCompat.get().registerInitCallback(getInitCallback()); break; case EmojiCompat.LOAD_STATE_FAILED: default: break; } } } EmojiTextWatcher(EditText editText); @Override void onTextChanged(CharSequence charSequence, final int start, final int before,
            final int after); @Override void beforeTextChanged(CharSequence s, int start, int count, int after); @Override void afterTextChanged(Editable s);  }