AdapterLibrary

A rxjava2 timer for android

License

License

GroupId

GroupId

com.github.thepacific
ArtifactId

ArtifactId

rx2timer
Last Version

Last Version

0.0.3
Release Date

Release Date

Type

Type

aar
Description

Description

AdapterLibrary
A rxjava2 timer for android
Project URL

Project URL

https://github.com/thepacific/rx2-timer
Source Code Management

Source Code Management

https://github.com/thepacific/rx2-timer

Download rx2timer

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.thepacific/rx2timer/ -->
<dependency>
    <groupId>com.github.thepacific</groupId>
    <artifactId>rx2timer</artifactId>
    <version>0.0.3</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/com.github.thepacific/rx2timer/
implementation 'com.github.thepacific:rx2timer:0.0.3'
// https://jarcasting.com/artifacts/com.github.thepacific/rx2timer/
implementation ("com.github.thepacific:rx2timer:0.0.3")
'com.github.thepacific:rx2timer:aar:0.0.3'
<dependency org="com.github.thepacific" name="rx2timer" rev="0.0.3">
  <artifact name="rx2timer" type="aar" />
</dependency>
@Grapes(
@Grab(group='com.github.thepacific', module='rx2timer', version='0.0.3')
)
libraryDependencies += "com.github.thepacific" % "rx2timer" % "0.0.3"
[com.github.thepacific/rx2timer "0.0.3"]

Dependencies

compile (2)

Group / Artifact Type Version
io.reactivex.rxjava2 : rxjava jar 2.1.6
io.reactivex.rxjava2 : rxandroid jar 2.0.1

Project Modules

There are no modules declared in this project.

This is a simple rxjava2/rxjava3/kotlin-flow timer. I copy this class into all the little apps I make. I'm tired of doing it. Now it's a library

Download

Usage

timer = Rx2Timer.builder()
                .initialDelay(0) //default is 0
                .period(1) //default is 1
                .take(30) //default is 60
                .unit(TimeUnit.SECONDS) // default is TimeUnit.SECONDS
                .onEmit(count -> {
                    if (count < 10) {
                        binding.text.setText("0" + count + " s");
                    } else {
                        binding.text.setText(count + " s");
                    }
                })
                .onError(e -> binding.text.setText(R.string.count))
                .onComplete(() -> binding.text.setText(R.string.count))
                .build();

timer.start();
timer.stop();
timer.restart();
timer.pause();
timer.resume();
                

Gradle

// rxjava2
implementation 'com.github.thepacific:rx2-timer:1.0.0'
// rxjava3
implementation 'com.github.thepacific:rx3-timer:1.0.0'

License

The MIT License

com.github.thepacific

thepacific

Thepacific Corp

Versions

Version
0.0.3
0.0.2
0.0.1