All Projects → Appolica → Flubber

Appolica / Flubber

Licence: apache-2.0
Flubber is an elegant solution for making animations in Android. The library is developed and maintained by Appolica.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Flubber

Bookshop
📖 基于 SSM 框架的二手书交易系统
Stars: ✭ 223 (-12.2%)
Mutual labels:  spring
Java Microservice
A full microservice project using Spring and many others tools
Stars: ✭ 235 (-7.48%)
Mutual labels:  spring
Ax Boot Framework
Full Stack Java Web Application Framework with Java & HTML5
Stars: ✭ 244 (-3.94%)
Mutual labels:  spring
Mastering Junit5
A comprehensive collection of test examples created with JUnit 5
Stars: ✭ 223 (-12.2%)
Mutual labels:  spring
Axanimationchain
AXAnimationChain is a chain animation library, can be used to easily create CAAnimation based chain animation. There are two kinds of combination chain, one is called combination, the other is called link, created by the two ways above, the animation can be carried out at the same time, can also according to the time order, you can use the code to create a rich and complex animation.
Stars: ✭ 234 (-7.87%)
Mutual labels:  spring
Spring Cloud Kubernetes
Kubernetes integration with Spring Cloud Discovery Client, Configuration, etc...
Stars: ✭ 2,894 (+1039.37%)
Mutual labels:  spring
Stormpath Sdk Java
Official Java SDK for the Stormpath User Management REST API
Stars: ✭ 221 (-12.99%)
Mutual labels:  spring
Bus
Bus 是一个基础框架、服务套件,它基于Java8编写,参考、借鉴了大量已有框架、组件的设计,可以作为后端服务的开发基础中间件。代码简洁,架构清晰,非常适合学习使用。
Stars: ✭ 253 (-0.39%)
Mutual labels:  spring
Yieldfarming
🧑‍🌾 It ain't much, but it's an honest work
Stars: ✭ 235 (-7.48%)
Mutual labels:  curve
Istio By Example Java
A collection of examples of using Istio with Java applications.
Stars: ✭ 242 (-4.72%)
Mutual labels:  spring
Program Blog
Practice, thinking and reading
Stars: ✭ 228 (-10.24%)
Mutual labels:  spring
Spring Boot Testing Strategies
Sample project demonstrating different Test Strategies that can be followed when using Spring Boot.
Stars: ✭ 233 (-8.27%)
Mutual labels:  spring
My Review
主要存放平时理论学习,比如java jdk源码分析、并发理论;面试、数据库、Linux、中间件、分布式、网络协议等方向
Stars: ✭ 237 (-6.69%)
Mutual labels:  spring
Managementsystem
ssm框架学习,很好的demo,普通页面跳转演变成ajax无刷新技术
Stars: ✭ 224 (-11.81%)
Mutual labels:  spring
Wms
一个基于Spring MVC、Spring、MyBatis、Shiro框架的仓库管理系统Demo。A warehouse management system implement with Spring MVC, Spring Framework,MyBstis,Shiro and MySQL
Stars: ✭ 248 (-2.36%)
Mutual labels:  spring
Uportal
Enterprise open source portal built by and for the higher education community.
Stars: ✭ 221 (-12.99%)
Mutual labels:  spring
Mongodb Plugin
MongoDB Plugin for Java
Stars: ✭ 236 (-7.09%)
Mutual labels:  spring
Sureness
A simple and efficient open-source security framework that focus on protection of restful api.
Stars: ✭ 254 (+0%)
Mutual labels:  spring
Awesome Spring Cloud
Spring Cloud 优质资源一网打尽
Stars: ✭ 249 (-1.97%)
Mutual labels:  spring
Shop
SSM 框架搭建的网上游戏商城(仿Steam)
Stars: ✭ 238 (-6.3%)
Mutual labels:  spring

Flubber

FlubberLogo

Flubber is an elegant solution for making animations in Android. The library is inspired by the Spring library for iOS. It supports all of the animations, curves and properties that are present in Spring. The library provides an interpolator called Spring which is similar to the iOS CASpringAnimation.

The library is developed and maintained by Appolica.

morphzoominzoomout

wobblewobblefadeinfallshake

Download Download

Gradle

compile 'com.appolica:flubber:$LATEST_LIB_VERSION'

Maven

<dependency>
  <groupId>com.appolica</groupId>
  <artifactId>flubber</artifactId>
  <version>$LATEST_LIB_VERSION</version>
  <type>pom</type>
</dependency>

Example

  1. Add the library to your build file. If you're using gradle it would look like this:
dependencies {
	compile 'com.appolica:flubber:$LATEST_LIB_VERSION'
}
  1. Add a view which you want to be animated:
    <TextView
        android:id="@+id/text"
        android:layout_centerInParent="true"
        android:text="Hello World!"
        android:gravity="center"/>

  1. Get the view
View view = findViewById(R.id.text);
  1. Apply the flubber animation where you want it to happen(in this example, when the view is clicked):
view.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
	Flubber.with()
		.animation(Flubber.AnimationPreset.SLIDE_UP) // Slide up animation
		.repeatCount(1)                              // Repeat once
		.duration(1000)                              // Last for 1000 milliseconds(1 second)
		.createFor(view)                             // Apply it to the view
		.start();                                    // Start it now
    }
});

API

class Flubber

This is the main class you will use to create your animations.

public static AnimationBody.Builder with()

Used to get a new AnimationBody.Builder instance. With it you can create an AnimationBody which holds all the data for an animation. Example:

Flubber.with()
	   .animation(Flubber.AnimationPreset.MORPH)
	   .interpolator(Flubber.Curve.BZR_EASE_IN)
	   .duration(100)
	   .autoStart(true)
	   .createFor(viewToBeAnimated);

This will create an animation from the preset animation MORPH with an interpolator from the preset interpolator BZR_EASE_IN. It will have a duration of 100 milliseconds and it will start automatically. The view which will be animated is viewToBeAnimated. More about the properties of the AnimationBody.

enum AnimationPreset

An enum containing all of the preset animations. Available options are:

  • SLIDE_LEFT
  • SLIDE_RIGHT
  • SLIDE_DOWN
  • SLIDE_UP
  • SQUEEZE_LEFT
  • SQUEEZE_RIGHT
  • SQUEEZE_DOWN
  • SQUEEZE_UP
  • FADE_IN
  • FADE_OUT
  • FADE_OUT_IN
  • FADE_IN_LEFT
  • FADE_IN_RIGHT
  • FADE_IN_DOWN
  • FADE_IN_UP
  • ZOOM_IN
  • ZOOM_OUT
  • FALL
  • SHAKE
  • POP
  • FLIP_X
  • FLIP_Y
  • MORPH
  • SQUEEZE
  • FLASH
  • WOBBLE
  • SWING
  • ALPHA
  • ROTATION
  • TRANSLATION_X
  • TRANSLATION_Y
  • SCALE_X
  • SCALE_Y

enum Curve

An enum containing all of the preset curves. Available options are:

  • BZR_EASE_IN
  • BZR_EASE_OUT
  • BZR_EASE_IN_OUT
  • BZR_LINEAR
  • BZR_SPRING
  • BZR_EASE_IN_SINE
  • BZR_EASE_OUT_SINE
  • BZR_EASE_IN_OUT_SINE
  • BZR_EASE_IN_QUAD
  • BZR_EASE_OUT_QUAD
  • BZR_EASE_IN_OUT_QUAD
  • BZR_EASE_IN_CUBIC
  • BZR_EASE_OUT_CUBIC
  • BZR_EASE_IN_OUT_CUBIC
  • BZR_EASE_IN_QUART
  • BZR_EASE_OUT_QUART
  • BZR_EASE_IN_OUT_QUART
  • BZR_EASE_IN_QUINT
  • BZR_EASE_OUT_QUINT
  • BZR_EASE_IN_OUT_QUINT
  • BZR_EASE_IN_EXPO
  • BZR_EASE_OUT_EXPO
  • BZR_EASE_IN_OUT_EXPO
  • BZR_EASE_IN_CIRC
  • BZR_EASE_OUT_CIRC
  • BZR_EASE_IN_OUT_CIRC
  • BZR_EASE_IN_BACK
  • BZR_EASE_OUT_BACK
  • BZR_EASE_IN_OUT_BACK
  • SPRING
  • LINEAR

class AnimationBody

This class contains all of the properties of a given animation. All of them are accessible from the AnimationProvider.

  • autoStart - Determines if the animation will start before returning it from createFor().
  • force - The force of the animation. Used by most of the presets to determine how much to express the animation (rotate the view more, wobble harder, etc...).
  • damping - Used only by the spring interpolator to determine the stiffness of the spring.
  • velocity - Used only be the spring interpolator to determine the initial velocity of the spring.
  • startX/Y - Used only by the translation animation presets to determine where the translation starts.
  • endX/Y - Used only by the translation animation presets to determine where the translation ends.
  • startScaleX/Y - Used only by the scaling animation presets to determine the initial scale.
  • endScaleX/Y - Used only by the scaling animation presets to determine the finishing scale.
  • repeatCount - Used by the BaseProvider class to set how many times the animation is repeated.
  • repeatMode - Used by the BaseProvider class to set how the animation is repeated(restart or reverse).
  • delay - Sets the delay of the animation.
  • duration - Sets the duration of the animation.
  • animation - Sets the AnimationProvider for the animation.
  • iterpolatorProvider - Sets the InterpolatorProvider for the animation.
  • animatorListener - Sets an animator listener for the animation

public Animator createFor(View view)

Uses all of the properties to create an animation for the given view. If the autoStart property is enabled the animation will be started from this method otherwise the animation must be started after it is returned.

interface AnimationProvider

public Animator createAnimationFor(final AnimationBody animationBody, View view)

Must create an Animator instance for the given view from the animationBody. If you want you can use this interface to create new animations but it is recomended to use the BaseProvider class because it implements animation repetition and applies the interpolator. Example:

    public Animator createAnimationFor(AnimationBody animationBody, View view) {

        final ObjectAnimator alphaAnimation = ObjectAnimator.ofFloat(view, View.ALPHA, 0f, 1f);

        return alphaAnimation;
    }

abstract class BaseProvider

public abstract Animator getAnimationFor(AnimationBody animationBody, View view)

Should create the animation for the given view from the animationBody the same as createAnimationFor() but it is not necessary to set the animation's repeating and interpolation info because it is handled by the BaseProvider class.

interface InterpolatorProvider

public Interpolator createInterpolatorFor(final AnimationBody animationBody)

Should provide an anumation interpolator based on the given animationBody. Example:

public Interpolator createInterpolatorFor(AnimationBody animationBody) {
    final float force = animationBody.getForce();
    return PathInterpolatorCompat.create(0.5f, 1.1f + force / 3, 1f, 1f);
}

class SimpleAnimatorListener

This is a helper class you can use if you don't want to override all of the AnimatorListener methods. It provides four methods with callbacks for the for events in an AnimatorListener.

static Animator.AnimatorListener forStart(final OnAnimationStartListener startListener);
static Animator.AnimatorListener forEnd(final OnAnimationEndListener endListener);
static Animator.AnimatorListener forCancel(final OnAnimationCancelListener cancelListener);
static Animator.AnimatorListener forRepeat(final OnAnimationRepeatListener repeatListener);

License

The library is under the Apache license. Check the LICENSE file for more info.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].