Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ufreedom/countdowntextview
https://github.com/ufreedom/countdowntextview
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/ufreedom/countdowntextview
- Owner: UFreedom
- Created: 2015-11-06T12:18:41.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-12-04T04:40:43.000Z (about 9 years ago)
- Last Synced: 2023-02-26T10:47:44.556Z (almost 2 years ago)
- Language: Java
- Size: 918 KB
- Stars: 31
- Watchers: 2
- Forks: 19
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# CountDownTextView
A simple countdown widget and easy to use.###Simple
------![demo](./screenshots/demo.gif)
###Usage
------```` java
compile 'com.ufreedom.countdowntextview:library:0.1.0'
````You can give it a start time in the `SystemClock.elapsedRealtime` timebase, and it counts down from that.
By default it will not update the time value in text but give a callback `onTick()`,If you want to display the current timer value ,Please use `setAutoDisplayText(true)`.
By default the display timer value is in the form "MM:SS" or "HH:MM:SS", you can use setTimeFormat() to use other format :
| Time Format | Display |
| -------- | ---- |
| TIME_FORMAT_D_H_M_S | DD:HH:MM:SS |
| TIME_FORMAT_H_M_S | HH:MM:SS |
| TIME_FORMAT_M_S | MM:SS |
| TIME_SHOW_S | SS |``` java
long timeInFuture = SystemClock.elapsedRealtime + 1000 * 60 * 20;//20 minutesCountDownTextView countDownTextView = findViewById(R.id.countDownTextView)
countDownTextView.setTimeInFuture(timeInFuture);
countDownTextView.setAutoShowText(true);
countDownTextView.start();```
###Callback
------``` java
public interface CountDownCallback {/**
* Callback fired on regular interval.
* @param millisUntilFinished The amount of time until finished.
*/
void onTick(CountDownTextView countDownTextView,long millisUntilFinished);/**
* Callback fired when the time is up.
*/
void onFinish(CountDownTextView countDownTextView);
}
```