Skip to content

Instantly share code, notes, and snippets.

@micer
Last active April 4, 2018 11:21
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 micer/93b02625bd078e52c5258eabaaea4449 to your computer and use it in GitHub Desktop.
Save micer/93b02625bd078e52c5258eabaaea4449 to your computer and use it in GitHub Desktop.
int delay = 25;
observableRemainingTime.setValue(TIME_FOR_ANSWER);
timerDisposable = Observable.timer(delay, TimeUnit.MILLISECONDS, Schedulers.computation())
.observeOn(AndroidSchedulers.mainThread())
.repeatUntil(() -> time <= 0)
.subscribe(tick -> {
time = time - delay;
observableRemainingTime.setValue(time);
},
Throwable::printStackTrace,
() -> onOptionSelected(null)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment