Example usage for android.animation TimeInterpolator TimeInterpolator

List of usage examples for android.animation TimeInterpolator TimeInterpolator

Introduction

In this page you can find the example usage for android.animation TimeInterpolator TimeInterpolator.

Prototype

TimeInterpolator

Source Link

Usage

From source file:io.github.data4all.activity.CameraActivity.java

/**
 * This method is the callback for the success-animation of the gallery
 * saving action.//from w ww  .j  a v  a  2  s. c  o m
 * 
 * @author tbrose
 */
protected void onGallerySuccess() {
    mCallbackView.animate().alpha(1).setDuration(VIBRATION_DURATION).setInterpolator(new TimeInterpolator() {
        private TimeInterpolator ti = new AccelerateDecelerateInterpolator();

        @Override
        public float getInterpolation(float input) {
            return 2f * (0.5f - Math.abs(-ti.getInterpolation(input) + 0.5f));
        }
    }).withStartAction(new Runnable() {
        @Override
        public void run() {
            mCallbackView.setVisibility(View.VISIBLE);
            Log.i(TAG, "starting success animation");
            mCamera.startPreview();
        }
    }).withEndAction(new Runnable() {
        @Override
        public void run() {
            mCallbackView.setVisibility(View.INVISIBLE);
            mCallbackView.setAlpha(0);
            btnCapture.setEnabled(true);
            Log.i(TAG, "ending success animation");
        }
    }).start();
}

From source file:cc.flydev.launcher.Page.java

public void onFlingToDelete(PointF vel) {
    final long startTime = AnimationUtils.currentAnimationTimeMillis();

    // NOTE: Because it takes time for the first frame of animation to actually be
    // called and we expect the animation to be a continuation of the fling, we have
    // to account for the time that has elapsed since the fling finished.  And since
    // we don't have a startDelay, we will always get call to update when we call
    // start() (which we want to ignore).
    final TimeInterpolator tInterpolator = new TimeInterpolator() {
        private int mCount = -1;
        private long mStartTime;
        private float mOffset;
        /* Anonymous inner class ctor */ {
            mStartTime = startTime;/*from w ww  .jav a 2s.c  o m*/
        }

        @Override
        public float getInterpolation(float t) {
            if (mCount < 0) {
                mCount++;
            } else if (mCount == 0) {
                mOffset = Math.min(0.5f, (float) (AnimationUtils.currentAnimationTimeMillis() - mStartTime)
                        / FLING_TO_DELETE_FADE_OUT_DURATION);
                mCount++;
            }
            return Math.min(1f, mOffset + t);
        }
    };

    final Rect from = new Rect();
    final View dragView = mDragView;
    from.left = (int) dragView.getTranslationX();
    from.top = (int) dragView.getTranslationY();
    AnimatorUpdateListener updateCb = new FlingAlongVectorAnimatorUpdateListener(dragView, vel, from, startTime,
            FLING_TO_DELETE_FRICTION);

    final Runnable onAnimationEndRunnable = createPostDeleteAnimationRunnable(dragView);

    // Create and start the animation
    ValueAnimator mDropAnim = new ValueAnimator();
    mDropAnim.setInterpolator(tInterpolator);
    mDropAnim.setDuration(FLING_TO_DELETE_FADE_OUT_DURATION);
    mDropAnim.setFloatValues(0f, 1f);
    mDropAnim.addUpdateListener(updateCb);
    mDropAnim.addListener(new AnimatorListenerAdapter() {
        public void onAnimationEnd(Animator animation) {
            onAnimationEndRunnable.run();
        }
    });
    mDropAnim.start();
    mDeferringForDelete = true;
}

From source file:saftyos.android.launcher3.Page.java

public void onFlingToDelete(PointF vel) {
    final long startTime = AnimationUtils.currentAnimationTimeMillis();

    // NOTE: Because it takes time for the first frame of animation to actually be
    // called and we expect the animation to be a continuation of the fling, we have
    // to account for the time that has elapsed since the fling finished.  And since
    // we don't have a startDelay, we will always get call to update when we call
    // start() (which we want to ignore).
    final TimeInterpolator tInterpolator = new TimeInterpolator() {
        private int mCount = -1;
        private long mStartTime;
        private float mOffset;

        /* Anonymous inner class ctor */ {
            mStartTime = startTime;//from w  w  w .j av a 2s . c  o  m
        }

        @Override
        public float getInterpolation(float t) {
            if (mCount < 0) {
                mCount++;
            } else if (mCount == 0) {
                mOffset = Math.min(0.5f, (float) (AnimationUtils.currentAnimationTimeMillis() - mStartTime)
                        / FLING_TO_DELETE_FADE_OUT_DURATION);
                mCount++;
            }
            return Math.min(1f, mOffset + t);
        }
    };

    final Rect from = new Rect();
    final View dragView = mDragView;
    from.left = (int) dragView.getTranslationX();
    from.top = (int) dragView.getTranslationY();
    AnimatorUpdateListener updateCb = new FlingAlongVectorAnimatorUpdateListener(dragView, vel, from, startTime,
            FLING_TO_DELETE_FRICTION);

    final Runnable onAnimationEndRunnable = createPostDeleteAnimationRunnable(dragView);

    // Create and start the animation
    ValueAnimator mDropAnim = new ValueAnimator();
    mDropAnim.setInterpolator(tInterpolator);
    mDropAnim.setDuration(FLING_TO_DELETE_FADE_OUT_DURATION);
    mDropAnim.setFloatValues(0f, 1f);
    mDropAnim.addUpdateListener(updateCb);
    mDropAnim.addListener(new AnimatorListenerAdapter() {
        public void onAnimationEnd(Animator animation) {
            onAnimationEndRunnable.run();
        }
    });
    mDropAnim.start();
    mDeferringForDelete = true;
}

From source file:com.n2hsu.launcher.Page.java

public void onFlingToDelete(PointF vel) {
    final long startTime = AnimationUtils.currentAnimationTimeMillis();

    // NOTE: Because it takes time for the first frame of animation to
    // actually be
    // called and we expect the animation to be a continuation of the fling,
    // we have//w  w w  . java2s  . c o m
    // to account for the time that has elapsed since the fling finished.
    // And since
    // we don't have a startDelay, we will always get call to update when we
    // call
    // start() (which we want to ignore).
    final TimeInterpolator tInterpolator = new TimeInterpolator() {
        private int mCount = -1;
        private long mStartTime;
        private float mOffset;
        /* Anonymous inner class ctor */ {
            mStartTime = startTime;
        }

        @Override
        public float getInterpolation(float t) {
            if (mCount < 0) {
                mCount++;
            } else if (mCount == 0) {
                mOffset = Math.min(0.5f, (float) (AnimationUtils.currentAnimationTimeMillis() - mStartTime)
                        / FLING_TO_DELETE_FADE_OUT_DURATION);
                mCount++;
            }
            return Math.min(1f, mOffset + t);
        }
    };

    final Rect from = new Rect();
    final View dragView = mDragView;
    from.left = (int) dragView.getTranslationX();
    from.top = (int) dragView.getTranslationY();
    AnimatorUpdateListener updateCb = new FlingAlongVectorAnimatorUpdateListener(dragView, vel, from, startTime,
            FLING_TO_DELETE_FRICTION);

    final Runnable onAnimationEndRunnable = createPostDeleteAnimationRunnable(dragView);

    // Create and start the animation
    ValueAnimator mDropAnim = new ValueAnimator();
    mDropAnim.setInterpolator(tInterpolator);
    mDropAnim.setDuration(FLING_TO_DELETE_FADE_OUT_DURATION);
    mDropAnim.setFloatValues(0f, 1f);
    mDropAnim.addUpdateListener(updateCb);
    mDropAnim.addListener(new AnimatorListenerAdapter() {
        public void onAnimationEnd(Animator animation) {
            onAnimationEndRunnable.run();
        }
    });
    mDropAnim.start();
    mDeferringForDelete = true;
}