TextChangedBindingFunction implements BindingFunction { private static void removeTextWatcher(TextView textView) { textView.removeTextChangedListener( (TextWatcher) textView.getTag(R.id.onTextChangedListener) ); textView.setTag(R.id.onTextChangedListener, null); } private  TextChangedBindingFunction(@Nullable OnTextChangedListener listener); static BindingFunction create(@Nullable OnTextChangedListener listener); @Override void bind(View view);  }
@Test public void removeTextWatcher() throws Exception { TextWatcher watcher = mock(TextWatcher.class); given(view.getTag(anyInt())) .willReturn(watcher); BindingFunction function = TextChangedBindingFunction.create(null); function.bind(view); verify(view).removeTextChangedListener(watcher); verify(view).setTag(R.id.onTextChangedListener, null); }