TextCounter


Source link: https://github.com/BullyBoo/TextCounter

TextCounter

Animation of text counter

Download

Gradle:

compile 'ru.bullyboo.animation:text_counter:1.0.2'

Maven:

<dependency>
 <groupId>ru.bullyboo.animation</groupId>
 <artifactId>text_counter</artifactId>
 <version>1.0.2</version>
 <type>pom</type>  </dependency>

Samples

Apk of Demo version

Usage

To use text counter you need to call TextCounter.newBuilder() and set properties of animation. For example:

TextCounter.newBuilder()

  .setTextView(textView)

  .setType(TextCounter.LONG)

  .setCustomAnimation(modeBuilder)

  .from(100l)

  .to(1000l)

  .build()

  .start();

The main method of TextCounter Builder is setTextView(); , from(); , to(); and setDuration(); . It's will not working without this.

Methods

setTextView(); You need to set TextView. which will show text animaton of counter.

from(); and to(); These methods support with:

byte, short, int, float, long, double  and
Byte, Short, Integer, Float, Long, Double, String 

You can also set Type of numbers directly, which will be used in counter. Use setType(); method for. All of them will convert to Double type!

And you can use method setRound(); to double and float types for setting round your number after decimal separator. For example:

//... from(0d). to(100d). setRound(2) //... 

You will have result - 100.00

setPrefix(); and setPostfix(); These methods will add to text counter usual String parameters. For example, if you want to show:"Result: 175$". You need to add setPrefix("Result: "); and setPostfix("$"); to your builder.

Method setDuration(); does setting duration of animation.

Method setFPS(); does setting fps of animation. If you do not use this method, the text counter will use default 60 FPS.

Method setMode(); does setting mode of animation. You can use one of next modes:

LINEAR_MODE LINEAR_ACCELERATION_MODE LINEAR_DECELERATION_MODE DECELERATION_MODE DECELERATION_LINEAR_MODE DECELERATION_ACCELERATION_MODE ACCELERATION_MODE ACCELERATION_LINEAR_MODE ACCELERATION_DECELERATION_MODE LINEAR_TO_ALPHA_MODE LINEAR_FROM_ALPHA_MODE DECELERATION_TO_ALPHA_MODE DECELERATION_FROM_ALPHA_MODE ACCELERATION_TO_ALPHA_MODE ACCELERATION_FROM_ALPHA_MODE CUSTOM_MODE 

I belive that you can understand the meaning of ths methods from their names.

You can make to text counter automatically change fps dynamic. Use setFromFps(); and setToFps(); methods for.

Also you can use set Fps Dynamic with method setFpsDynamic(); ', but be careful you need to put int array in this method.

It's absolutely same with alpha channel. You can use setFromAlpha(); and setToAlpha(); methods for. And setAlphaDynamic(); with float array.

The main method of this library is setCustomAnimation(). You need to use it with ModeConstructor.class. With this method you can create your own animation!

For example:

AnimationBuilder modeBuilder = AnimationBuilder.newBuilder()

  .addPart(1000, 60)

  .addPart(1000, 60, 100)

  .addPart(1000, 100, AlphaBuilder.newInstance().fromAlpha(1f).toAlpha(0f))

  .addPart(1000, 100, 60, AlphaBuilder.newInstance().fromAlpha(0f).toAlpha(1f))

  .build();

TextCounter animator = TextCounter.newBuilder()

  .setTextView(textView)

  .setCustomAnimation(modeBuilder)

  .from(0d)

  .to(100d)

  .build()

  .start();

What happened here? The first method addPart(); has the first parameter duration and the second parameter fps. The second: duration, fromFps, toFps. The third: duration, fps, and AlphaBuilder, which will create alpha dynamic change. Fourth: duration, fromFps, toFps, and AlphaBuilder, which will create alpha dynamic change.

You can create everthing you want with method setCustomAnimation(); .

License

  Copyright (C) 2017 BullyBoo
 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. 

Resources

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes