Skip to content
This repository has been archived by the owner on Feb 8, 2022. It is now read-only.

Added evaluator. #61

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,21 @@ Path animations ( Inspiration from http://blog.csdn.net/tianjian4592/article/det
```


Animations with custom evalutors - such as those available in [AnimationEasingFunctions](https://github.com/daimajia/AnimationEasingFunctions) for more advanced [easing interpolators](https://easings.net/)
```java
ViewAnimator.animate(view)
.translationY(0f, translateY) // up
.startDelay(1000)
.duration(150)
.interpolator(DecelerateInterpolator())
.thenAnimate(view)
.translationY(translateY, 0f) // down with a 'boing' effect
.evaluator(ElasticEaseOut(500))
.duration(500)
.onStop { startAnimation() } // restart the animation, by creating it again
.start()
```

# Download

<a href='https://ko-fi.com/A160LCC' target='_blank'><img height='36' style='border:0px;height:36px;' src='https://az743702.vo.msecnd.net/cdn/kofi1.png?v=0' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.animation.Animator;
import android.animation.ArgbEvaluator;
import android.animation.ObjectAnimator;
import android.animation.TypeEvaluator;
import android.animation.ValueAnimator;
import android.graphics.Path;
import android.graphics.PathMeasure;
Expand Down Expand Up @@ -247,6 +248,11 @@ public AnimationBuilder interpolator(Interpolator interpolator) {
return this;
}

public AnimationBuilder evaluator(TypeEvaluator evaluator) {
viewAnimator.evaluator(evaluator);
return this;
}

public AnimationBuilder singleInterpolator(Interpolator interpolator) {
singleInterpolator = interpolator;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.TypeEvaluator;
import android.animation.ValueAnimator;
import android.view.View;
import android.view.ViewTreeObserver;
Expand Down Expand Up @@ -30,6 +31,7 @@ public class ViewAnimator {
private long duration = DEFAULT_DURATION;
private long startDelay = 0;
private Interpolator interpolator = null;
private TypeEvaluator evaluator = null;

private int repeatCount = 0;
private int repeatMode = RESTART;
Expand Down Expand Up @@ -67,6 +69,7 @@ protected AnimatorSet createAnimatorSet() {
ValueAnimator valueAnimator = (ValueAnimator) animator;
valueAnimator.setRepeatCount(repeatCount);
valueAnimator.setRepeatMode(repeatMode);
valueAnimator.setEvaluator(evaluator);
}
}

Expand Down Expand Up @@ -203,4 +206,9 @@ public ViewAnimator interpolator(Interpolator interpolator) {
return this;
}

public ViewAnimator evaluator(TypeEvaluator evaluator) {
this.evaluator = evaluator;
return this;
}

}