Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import android.animation.TimeInterpolator;
- import android.view.animation.LinearInterpolator;
- /**
- * Maps time into another interpolator so that the animation plays, and then reverses.
- * i.e. time maps like so:
- * [0..0.5, 0.5..1] maps to [0..1, 1..0]
- */
- public final class AutoReverseInterpolator implements TimeInterpolator {
- private final TimeInterpolator inner;
- /**
- * Decorator constructor, use if you don't want a linear interpolation.
- * @param inner
- */
- public AutoReverseInterpolator(TimeInterpolator inner) {
- this.inner = inner;
- }
- /**
- * Linear interpolation constructor.
- */
- public AutoReverseInterpolator() {
- this(new LinearInterpolator());
- }
- @Override
- public float getInterpolation(float input) {
- input *= 2;
- if (input > 1) {
- input = 2 - input;
- }
- return inner.getInterpolation(input);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement