Skip to content

Latest commit

 

History

History
87 lines (72 loc) · 2.09 KB

README.md

File metadata and controls

87 lines (72 loc) · 2.09 KB

Lazy Count Animation

A convenient and continued number count animation. It makes very easier progress TextView or any purposes.

It supports not only positive but also negative numbers.

Preview

Install

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' }
		}
	}

Step 2. Add the dependency

dependencies {
        implementation 'com.github.frog1014:lazy_count_animation:1.0'
	}

Usage

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)