Android Flux

Release Download License

demo

Usage

➫ GRADLE

Add this to your app build.gradle:

dependencies {
    compile 'net.brach.android:flux:1.1.0'
}
➫ JAVA

No need to initialized. Use the Flux.Builder to pre-calculate the animation. Then call the 'start()' function to run the animation.

final Flux flux = new Flux.Builder(this)
        .from(viewFrom)
        .to(viewTo)
        .number(400)
        .assets(bitmaps, 15, 65)
        .duration(1000, 1500)
        .build();

viewFrom.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        flux.start();
        v.setOnClickListener(null);
    }
});

You can also run the animation directly (be careful, it may take time) using the 'run()' function.

new Flux.Builder(this)
        .from(view)
        .to(to)
        .number(400)
        .assets(bitmaps, 15, 65)
        .duration(1000, 1500)
        .run();

Classes

Flux.Builder

To create a Flux animation, you should used the Flux.Builder class.

Methods

These methods can be chained:

  • number(int count): (required)
    The number of particles you want to animate.
  • from(View from): (required)
    The view where the particles will start.
  • to(View to): (required)
    The view where the particles will arrive.
  • duration(int min, int max): (required)
    The interval of durations in milliseconds.
  • circle(float radiusMin, float radiusMax): (required if assets isn't called)
    The interval of circle radius in pixels.
  • assets(List assets, int sizeMin, int sizeMax): (required if circle isn't called)
    The list of assets and the interval of sizes in pixels.
  • addInterpolators(TimeInterpolator... interpolators):
    Add multiple interpolators. An interpolator will be chosen randomly in this list to be associate to a particle.
  • removeInterpolators(TimeInterpolator... interpolators):
    Remove multiple interpolators. If the list is empty, the default interpolators will be added.
  • clearInterpolators():
    Remove all interpolators. If the list is empty, the default interpolators will be added.

These methods build or run the animation:

  • run():
    Immediately execute the animation when it will be created.
  • build():
    Returns a Flux which is the pre-calculation of the animation.

Flux

The Flux class is the animation.

Methods

The Flux class behaves like an android.animation.Animator. You can add or remove listeners, you can start, cancel, end, pause or resume the animation and retrieve some information about it.

An additional method, called remove() is added to delete all views created by the animation.

Contribution

Feel free to create pull requests / issues

Licence

This project is licensed under the WTFPL (Do What The Fuck You Want To Public License, Version 2)

WTFPL

Copyright © 2017 brachior brachior@gmail.com

This work is free. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See the COPYING file for more details.