Skip to content

Instantly share code, notes, and snippets.

@sddamico
Last active August 29, 2015 14:04
Show Gist options
  • Save sddamico/9ccb0ea27a0a7f739774 to your computer and use it in GitHub Desktop.
Save sddamico/9ccb0ea27a0a7f739774 to your computer and use it in GitHub Desktop.
Rx Enable Developer Settings
ObservableButton v = (ObservableButton) findViewById(R.id.button);
v.observeOnClick()
.skip(3)
.takeWhileWithIndex(new Func2<ObservableButton.OnClick, Integer, Boolean>() {
@Override
public Boolean call(ObservableButton.OnClick onClick, Integer index) {
int countdown = 3 - index;
if (countdown > 0) {
Toast.makeText(MainActivity.this, "You are now " + countdown + " clicks away from being a developer!", Toast.LENGTH_SHORT).show();
return true;
} else {
Toast.makeText(MainActivity.this, "You are now a developer!", Toast.LENGTH_SHORT).show();
return false;
}
}
}).subscribe();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment