Skip to content

wrbl606/android-debouncer

 
 

Repository files navigation

Android debouncer

GitHub license Version Minimum API

Clean and simple solution for debouncing UI tasks (or any other).

  • Min SDK: 17 (JELLY_BEAN_MR1)
  • Footprint: Nearly none ♥

Implementation

Insert this into your build.gradle file:

    implementation 'com.github.wrbl606:debouncer:1.0'

and you are ready to go.

Usage

All you need to do is provide a unique identifier for your task. The task itself should be passed as Runnable. The last parameter is debounce delay (in milliseconds).

Example:

Debouncer.debounce("example-task", new Runnable() {
    @Override
    public void run() {
        // Will not be ran due to the call below
        ...
    }
}, 250);

Thread.sleep(100, 0);

Debouncer.debounce("example-task", new Runnable() {
    @Override
    public void run() {
        // Overrides the previous call with identifier "example-task", running after approx. 350ms.
        // 100ms simulated "wait" time, 250ms debounce time.
        ...
    }
}, 250);

About

Simple debouncer for Android Runnables

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%