CircleProgressView
is support for countdown process or show up process to view with util time through function OnPlayListener()
- Step 1. Add the JitPack repository to your build file
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
...
implementation 'com.github.duonghd7:hd-circle-progress-view:0.6.3'
}
.setTotalTime(int cpvTotalTime)
.setTotalTime(int cpvTotalTime, CircleProgressTime circleProgressTime)
You can set total time
for process with default value is 30 second
.
.setCountDownInterval(int countDownInterval)
.setCountDownInterval(int countDownInterval, CircleProgressTime circleProgressTime)
You can set countdown interval
for process with default value and minimum of value is 20 millisecond
.
.setStartAngle(float cpvStartAngle)
You can set start angle
before process is run with default value is -90f
.
.setSweepAngle(float cpvSweepAngle)
You can set sweep angle
before process is run with default value is 0f
.
.cpvStart()
Process run and update each countdown interval.
.cpvPause()
Pause process
.cpvResume()
Resume process
.setOnPlayListener(CircleProgressView.OnPlayListener onPlayListener)
You will receive execution time after each countdown interval.
circleProgress.setTotalTime(10, CircleProgressTime.SECOND)
.setCountDownInterval(20, CircleProgressTime.MILLI_SECOND)
.setOnPlayListener(new CircleProgressView1.OnPlayListener() {
@Override
public void onPlay(int momentTime) {
int min = momentTime / 60000;
int second = (momentTime / 1000) % 60;
int milliSecond = (momentTime % 1000) / 10;
String time = String.format("%s:%s:%s"
, min < 10 ? String.format("0%s", min) : min
, second < 10 ? String.format("0%s", second) : second
, milliSecond < 10 ? String.format("0%s", milliSecond) : milliSecond);
tvMomentTime.setText(time);
}
@Override
public void onFinish() {
Toast.makeText(MainActivity.this, "Done!", Toast.LENGTH_SHORT).show();
}
});
circleProgress.cpvStart();
circleProgress.setTotalTime(10, CircleProgressTime.SECOND)
.setCountDownInterval(20, CircleProgressTime.MILLI_SECOND)
.setMode(CircleProgressView2.CircleProgressMode.STROKE_BUTT_2)
.setOnPlayListener(new CircleProgressView2.OnPlayListener() {
@Override
public void onPlay(int momentTime) {
int min = momentTime / 60000;
int second = (momentTime / 1000) % 60;
int milliSecond = (momentTime % 1000) / 10;
String time = String.format("%s:%s:%s"
, min < 10 ? String.format("0%s", min) : min
, second < 10 ? String.format("0%s", second) : second
, milliSecond < 10 ? String.format("0%s", milliSecond) : milliSecond);
tvMomentTime.setText(time);
}
@Override
public void onFinish() {
circleProgress.setTotalTime(10, CircleProgressTime.SECOND)
.setCountDownInterval(20, CircleProgressTime.MILLI_SECOND)
.setMode(i % 2 == 0 ? CircleProgressView2.CircleProgressMode.STROKE_BUTT_1 : CircleProgressView2.CircleProgressMode.STROKE_BUTT_2);
i++;
circleProgress.cpvStart();
}
});
circleProgress.cpvStart();
Copyright (c) 2019 Hà Đại Dương
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.