CountDownTask Save Abandoned

⌛️A countdown library for Android.

Project README

CountDownTask

CountDownTask is a countdown library. It can work with a single view or a adapter view, etc.

Gradle

implementation 'com.zhjl37.countdowntask:countdowntask:1.0.0'

Usage

Create a countdown task:

CountDownTask countDownTask = CountDownTask.create()

Build the target time since the system was booted, and include deep sleep. For example, 6 seconds later:

long targetMillis = CountDownTask.elapsedRealtime() + 1000 * 60;

Apply the countdown to a view, e.g. a TextView, and 1 second countdown interval:

final int CD_INTERVAL = 1000;

countDownTask.until(textView, targetMillis, CD_INTERVAL, new OnCountDownListener() {
    @Override
    public void onTick(View view, long millisUntilFinished) {
        ((TextView)view).setText(String.valueOf(millisUntilFinished / CD_INTERVAL));
    }
    @Override
    public void onFinish(View view) {
        ((TextView)view).setText("DONE.");
    }
});

When the count task is no longer needed, cancel it:

countDownTask.cancel(textView);

or

countDownTask.cancel();
Open Source Agenda is not affiliated with "CountDownTask" Project. README Source: zhjl37/CountDownTask
Stars
71
Open Issues
0
Last Commit
2 years ago
License

Open Source Agenda Badge

Open Source Agenda Rating