Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TonyTangAndroid/35bd8c9d2eb0fba8206c955dbf1dc1d5 to your computer and use it in GitHub Desktop.
Save TonyTangAndroid/35bd8c9d2eb0fba8206c955dbf1dc1d5 to your computer and use it in GitHub Desktop.
The submit button only gets enabled if username and password have a length>=3
emailChangeObservable = RxTextView.textChangeEvents(email);
passwordChangeObservable = RxTextView.textChangeEvents(password);
// force-disable the button
submitButton.setEnabled(false);
Observable.combineLatest(emailChangeObservable, passwordChangeObservable,
(emailObservable, passwordObservable) -> {
boolean emailCheck = emailObservable.text().length() >= 3;
boolean passwordCheck = passwordObservable.text().length() >= 3;
return emailCheck && passwordCheck;
}).subscribe(aBoolean -> {
submitButton.setEnabled(aBoolean);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment