Skip to content

Give effect for shifting the calculation of numbers from the starting value to the final value.

License

Notifications You must be signed in to change notification settings

eriffanani/CountAnimator

Repository files navigation

Number Counter Animator

Give effect for shifting the calculation of numbers from the starting value to the final value.

Installation

  • build.gradle (Old way)
maven { url 'https://jitpack.io' }
  • setting.gradle: dependencyResolutionManagement (New way)
maven { url 'https://jitpack.io' }

dependencies

implementation 'com.github.eriffanani:CountAnimator:1.0.1'

How To Use

Basic

  • Java
CountAnimator anim = new CountAnimator(1000, 0);
anim.doOnUpdate((value, valueStr) -> {
  // TODO ACTION            
});
anim.start();
  • Kotlin
val anim = CountAnimator(1000, 0)
anim.doOnUpdate { value, valueStr ->
  myTextView.text = valueStr
}
anim.start()

Action Support

anim.start();
anim.pause();
anim.resume();
anim.stop();

Input String Support

new CountAnimator("€10.000", "€100");

Duration

anim.duration(3); // 3 Seconds
anim.duration(3000L); // 3 Seconds

End Listener

  • Java
anim.doOnEnd(() -> {
  // TODO ACTION            
});
  • Kotlin
anim.doOnEnd {
  // TODO ACTION
}

Number Formatting

  • Decimal
anim.format(CountFormatDecimal("#,###"))
  • Currency Use your country code and set fraction digits ex: 2
anim.format(new CountFormatCurrency("EUR"));
anim.format(new CountFormatCurrency("EUR", 2));

Information

This library is still being developed further, please provide feedback if you find a bug. Thank you

Licence

Copyright 2022 Mukhammad Erif Fanani

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.