Skip to content

Instantly share code, notes, and snippets.

@anitaa1990
Last active August 7, 2018 18:50
Show Gist options
  • Save anitaa1990/473922afb15481549eba09e6c884eda9 to your computer and use it in GitHub Desktop.
Save anitaa1990/473922afb15481549eba09e6c884eda9 to your computer and use it in GitHub Desktop.
/*
* There are 3 methods to the TextWatcher interface.
* But in most scenarios we need to use only one method.
* This means ideally the remaining two methods have no use and should
* not be part of the interface. This is in violation of the ISP principle
*/
editText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
/* In most of the scenarios this is the only method we use. The other methods are pointless in these cases. */
}
@Override
public void afterTextChanged(Editable editable) {
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment