A convenient and continued number count animation. It makes very easier progress TextView or any purposes.
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.frog1014:lazy_count_animation:1.0'
}
Initate
progressAnimation = LazyCountAnimation.Builder(
beginNumber = 0,
targetNumber = 100
)
.setCanCountdown(true)
.setGranularity(3)
.setFps(30)
.doOnNextNumber {
view.text = "$it"
}
.build()
Set target number
progressAnimation.setTargetNumber(77)
Set the next target number, you don't need to do extra works. Lazy count will animate to the next number upon previous number.
progressAnimation.setTargetNumber(86)
Set a negative number, you have to enable the countdown when initiating
progressAnimation.setTargetNumber(-186)
Stop
progressAnimation.stop()
Start
progressAnimation.start()
Callback, here is a returned current number
progressAnimation.doOnNextNumber{ currentNumber ->
// update a TextView or do something...
view.text = currentNumber.toString()
}
Set FPS
progressAnimation.setFps(30)