Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Support Library for Chronometer in Android

If there any support Library function that could make the setCountDown function of the chronometer support by APIs lower than 24?

like image 702
Wali Muhammad Khubaib Avatar asked Jun 15 '17 23:06

Wali Muhammad Khubaib


Video Answer


1 Answers

You can try RXJava to simple handle threads, timers, and many other functionalities.

The documentation for the timer operator says this:

Create an Observable that emits a particular item after a given delay

Thus the behavior you are observing is expected- timer() emits just a single item after a delay.

The interval operator, on the other hand, will emit items spaced out with a given interval.

For example, this Observable will emit an item every second:

Observable.interval(1, TimeUnit.SECONDS);

And an complete example:

Observable.interval(1,TimeUnit.SECONDS, Schedulers.io())
        .take(300) // take 300 second
        .map(v -> 300 - v)
        .subscribe(
            onNext -> {
                //on every second pass trigger
            },
            onError -> {
                //do on error
            },
            () -> {
                //do on complete
            },
            onSubscribe -> {
                //do once on subscription
            });
like image 53
FarshidABZ Avatar answered Nov 09 '22 13:11

FarshidABZ