Loading repository data…
Loading repository data…
Appolica / repository
Flubber is an elegant solution for making animations in Android. The library is developed and maintained by Appolica.
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
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.
implementation 'com.appolica:flubber:1.0.1'
<dependency>
<groupId>com.appolica</groupId>
<artifactId>flubber</artifactId>
<version>1.0.1</version>
<type>aar</type>
</dependency>
dependencies {
` implementation 'com.appolica:flubber:1.0.1'`
}
<TextView
android:id="@+id/text"
android:layout_centerInParent="true"
android:text="Hello World!"
android:gravity="center"/>
View view = findViewById(R.id.text);
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
}
});
class FlubberThis 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 AnimationPresetAn enum containing all of the preset animations. Available options are:
SLIDE_LEFTSLIDE_RIGHTSLIDE_DOWNSLIDE_UPSQUEEZE_LEFTSQUEEZE_RIGHTSQUEEZE_DOWNSQUEEZE_UPFADE_INFADE_OUTFADE_OUT_INFADE_IN_LEFTFADE_IN_RIGHTFADE_IN_DOWNFADE_IN_UPZOOM_INZOOM_OUTFALLSHAKEPOPFLIP_XFLIP_YMORPHSQUEEZEFLASHWOBBLESWINGALPHAROTATIONTRANSLATION_XTRANSLATION_YSCALE_XSCALE_Yenum CurveAn enum containing all of the preset curves. Available options are:
BZR_EASE_INBZR_EASE_OUTBZR_EASE_IN_OUTBZR_LINEARBZR_SPRINGBZR_EASE_IN_SINEBZR_EASE_OUT_SINEBZR_EASE_IN_OUT_SINEBZR_EASE_IN_QUADBZR_EASE_OUT_QUADBZR_EASE_IN_OUT_QUADBZR_EASE_IN_CUBICBZR_EASE_OUT_CUBICBZR_EASE_IN_OUT_CUBICBZR_EASE_IN_QUARTBZR_EASE_OUT_QUARTBZR_EASE_IN_OUT_QUARTBZR_EASE_IN_QUINTBZR_EASE_OUT_QUINTBZR_EASE_IN_OUT_QUINTBZR_EASE_IN_EXPOBZR_EASE_OUT_EXPOBZR_EASE_IN_OUT_EXPOBZR_EASE_IN_CIRCBZR_EASE_OUT_CIRCBZR_EASE_IN_OUT_CIRCBZR_EASE_IN_BACKBZR_EASE_OUT_BACKBZR_EASE_IN_OUT_BACKSPRINGLINEARclass AnimationBodyThis 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 animationpublic 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 AnimationProviderpublic 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 BaseProviderpublic 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 InterpolatorProviderpublic 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 SimpleAnimatorListenerThis 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);
The library is under the Apache license. Check the LICENSE file for more info.