Skip to content

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

License

Notifications You must be signed in to change notification settings

frog1014/lazy_count_animation

Repository files navigation

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)

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages