Linear Timer is a custom view for Android that enables circular progress animation with respect to given duration.
Linear Timer supports following features -
- Progress animation in clock-wise or counter clock-wise direction.
- Get time elapsed since timer started or time left for the counter to complete.
- Provide Start and finish points for the animation.
- Pre-fill the progress up-till certain point.
- Resume the animation on the basis of duration elapsed from total duration.
...and much more.
If you're using this library, please let me know; I'll feature your app in this readme.
Linear Timer follows the Semantic Versioning System.
It is currently on version v2.0.1
.
[] (https://jitpack.io/#krtkush/LinearTimer)
Setup is pretty straight forward.
In your project's build.gradle
add the following -
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
And, in your app's build.gradle
add this under dependencies
block -
compile 'com.github.krtkush:LinearTimer:v2.0.1'
Following is how you can implement LinearTimer in its simplest form.
First, you need to add LinearTimerView
into your XML layout -
xmlns:app="http://schemas.android.com/apk/res-auto"
<io.github.krtkush.lineartimer.LinearTimerView
android:id="@+id/linearTimer"
android:layout_centerHorizontal="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:radius="20dp"
app:strokeWidth="3dp"/>
Note that "wrap_content"
for height
and width
is the correct argument. Using other values might lead incorrect rendering of the view on different devices.
After adding the view, here is how the View is initialized and used -
LinearTimerView linearTimerView = (LinearTimerView) findViewById(R.id.linearTimer);
LinearTimer linearTimer = new LinearTimer.Builder()
.linearTimerView(linearTimerView)
.duration(10 * 1000)
.build();
// Start the timer.
findViewById(R.id.startTimer).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
linearTimer.startTimer();
}
});
For detailed documentation and on how to customise and use LinearTimer see the wiki.
Any kind of contribution will be appreciated; feel free to create a pull request or file issues on the issue tracker.