Search in sources :

Example 91 with LinearInterpolator

use of android.view.animation.LinearInterpolator in project wire-android by wireapp.

the class SendingAnimationView method initAnimations.

private void initAnimations() {
    circleStartAnimator = ObjectAnimator.ofFloat(0, pendingAngleStop);
    circleStartAnimator.addUpdateListener(this);
    circleStartAnimator.setDuration((long) (animationDuration * (CIRCLE_FILL_ANIMATION_PART / 4f * 3)));
    circleStartAnimator.setInterpolator(new LinearInterpolator());
    circleStartAnimator.addListener(new Animator.AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animation) {
            SendingAnimationView.super.setVisibility(VISIBLE);
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (nextAnimation != null) {
                nextAnimation.start();
            }
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }
    });
    circleEndAnimator = ObjectAnimator.ofFloat(DEFAULT_PENDING_ANGLE_STOP, 360);
    circleEndAnimator.addUpdateListener(this);
    circleEndAnimator.setDuration((long) (animationDuration * (CIRCLE_FILL_ANIMATION_PART / 4f)));
    circleEndAnimator.setInterpolator(new LinearInterpolator());
    circleEndAnimator.addListener(new Animator.AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animation) {
            SendingAnimationView.super.setVisibility(VISIBLE);
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            scalingAnimator.start();
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }
    });
    scalingAnimator = ObjectAnimator.ofFloat(1, 0);
    scalingAnimator.addUpdateListener(this);
    scalingAnimator.setDuration((long) (animationDuration * (1f - CIRCLE_FILL_ANIMATION_PART)));
    scalingAnimator.setInterpolator(new LinearInterpolator());
    scalingAnimator.addListener(new Animator.AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animation) {
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            resetValues();
            SendingAnimationView.super.setVisibility(GONE);
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            resetValues();
            SendingAnimationView.super.setVisibility(GONE);
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }
    });
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) LinearInterpolator(android.view.animation.LinearInterpolator)

Example 92 with LinearInterpolator

use of android.view.animation.LinearInterpolator in project wire-android by wireapp.

the class GlyphProgressView method startEndlessProgress.

public void startEndlessProgress() {
    if (endlessValueAnimator != null && endlessValueAnimator.isRunning()) {
        return;
    }
    endlessValueAnimator = ValueAnimator.ofInt(0, 360);
    endlessValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            startAngle = (int) animation.getAnimatedValue();
            invalidate();
        }
    });
    progress = ENDLESS_PROGRESS_VALUE;
    endlessValueAnimator.setDuration(1500);
    endlessValueAnimator.setInterpolator(new LinearInterpolator());
    endlessValueAnimator.setRepeatCount(ValueAnimator.INFINITE);
    endlessValueAnimator.start();
}
Also used : LinearInterpolator(android.view.animation.LinearInterpolator) ValueAnimator(android.animation.ValueAnimator)

Example 93 with LinearInterpolator

use of android.view.animation.LinearInterpolator in project android_frameworks_base by crdroidandroid.

the class StackView method handlePointerUp.

private void handlePointerUp(MotionEvent ev) {
    int pointerIndex = ev.findPointerIndex(mActivePointerId);
    float newY = ev.getY(pointerIndex);
    int deltaY = (int) (newY - mInitialY);
    mLastInteractionTime = System.currentTimeMillis();
    if (mVelocityTracker != null) {
        mVelocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
        mYVelocity = (int) mVelocityTracker.getYVelocity(mActivePointerId);
    }
    if (mVelocityTracker != null) {
        mVelocityTracker.recycle();
        mVelocityTracker = null;
    }
    if (deltaY > mSwipeThreshold && mSwipeGestureType == GESTURE_SLIDE_DOWN && mStackSlider.mMode == StackSlider.NORMAL_MODE) {
        // We reset the gesture variable, because otherwise we will ignore showPrevious() /
        // showNext();
        mSwipeGestureType = GESTURE_NONE;
        // Swipe threshold exceeded, swipe down
        if (mStackMode == ITEMS_SLIDE_UP) {
            showPrevious();
        } else {
            showNext();
        }
        mHighlight.bringToFront();
    } else if (deltaY < -mSwipeThreshold && mSwipeGestureType == GESTURE_SLIDE_UP && mStackSlider.mMode == StackSlider.NORMAL_MODE) {
        // We reset the gesture variable, because otherwise we will ignore showPrevious() /
        // showNext();
        mSwipeGestureType = GESTURE_NONE;
        // Swipe threshold exceeded, swipe up
        if (mStackMode == ITEMS_SLIDE_UP) {
            showNext();
        } else {
            showPrevious();
        }
        mHighlight.bringToFront();
    } else if (mSwipeGestureType == GESTURE_SLIDE_UP) {
        // Didn't swipe up far enough, snap back down
        int duration;
        float finalYProgress = (mStackMode == ITEMS_SLIDE_DOWN) ? 1 : 0;
        if (mStackMode == ITEMS_SLIDE_UP || mStackSlider.mMode != StackSlider.NORMAL_MODE) {
            duration = Math.round(mStackSlider.getDurationForNeutralPosition());
        } else {
            duration = Math.round(mStackSlider.getDurationForOffscreenPosition());
        }
        StackSlider animationSlider = new StackSlider(mStackSlider);
        PropertyValuesHolder snapBackY = PropertyValuesHolder.ofFloat("YProgress", finalYProgress);
        PropertyValuesHolder snapBackX = PropertyValuesHolder.ofFloat("XProgress", 0.0f);
        ObjectAnimator pa = ObjectAnimator.ofPropertyValuesHolder(animationSlider, snapBackX, snapBackY);
        pa.setDuration(duration);
        pa.setInterpolator(new LinearInterpolator());
        pa.start();
    } else if (mSwipeGestureType == GESTURE_SLIDE_DOWN) {
        // Didn't swipe down far enough, snap back up
        float finalYProgress = (mStackMode == ITEMS_SLIDE_DOWN) ? 0 : 1;
        int duration;
        if (mStackMode == ITEMS_SLIDE_DOWN || mStackSlider.mMode != StackSlider.NORMAL_MODE) {
            duration = Math.round(mStackSlider.getDurationForNeutralPosition());
        } else {
            duration = Math.round(mStackSlider.getDurationForOffscreenPosition());
        }
        StackSlider animationSlider = new StackSlider(mStackSlider);
        PropertyValuesHolder snapBackY = PropertyValuesHolder.ofFloat("YProgress", finalYProgress);
        PropertyValuesHolder snapBackX = PropertyValuesHolder.ofFloat("XProgress", 0.0f);
        ObjectAnimator pa = ObjectAnimator.ofPropertyValuesHolder(animationSlider, snapBackX, snapBackY);
        pa.setDuration(duration);
        pa.start();
    }
    mActivePointerId = INVALID_POINTER;
    mSwipeGestureType = GESTURE_NONE;
}
Also used : LinearInterpolator(android.view.animation.LinearInterpolator) ObjectAnimator(android.animation.ObjectAnimator) PropertyValuesHolder(android.animation.PropertyValuesHolder) Paint(android.graphics.Paint)

Example 94 with LinearInterpolator

use of android.view.animation.LinearInterpolator in project android_frameworks_base by crdroidandroid.

the class StackView method transformViewForTransition.

/**
     * Animate the views between different relative indexes within the {@link AdapterViewAnimator}
     */
void transformViewForTransition(int fromIndex, int toIndex, final View view, boolean animate) {
    if (!animate) {
        ((StackFrame) view).cancelSliderAnimator();
        view.setRotationX(0f);
        LayoutParams lp = (LayoutParams) view.getLayoutParams();
        lp.setVerticalOffset(0);
        lp.setHorizontalOffset(0);
    }
    if (fromIndex == -1 && toIndex == getNumActiveViews() - 1) {
        transformViewAtIndex(toIndex, view, false);
        view.setVisibility(VISIBLE);
        view.setAlpha(1.0f);
    } else if (fromIndex == 0 && toIndex == 1) {
        // Slide item in
        ((StackFrame) view).cancelSliderAnimator();
        view.setVisibility(VISIBLE);
        int duration = Math.round(mStackSlider.getDurationForNeutralPosition(mYVelocity));
        StackSlider animationSlider = new StackSlider(mStackSlider);
        animationSlider.setView(view);
        if (animate) {
            PropertyValuesHolder slideInY = PropertyValuesHolder.ofFloat("YProgress", 0.0f);
            PropertyValuesHolder slideInX = PropertyValuesHolder.ofFloat("XProgress", 0.0f);
            ObjectAnimator slideIn = ObjectAnimator.ofPropertyValuesHolder(animationSlider, slideInX, slideInY);
            slideIn.setDuration(duration);
            slideIn.setInterpolator(new LinearInterpolator());
            ((StackFrame) view).setSliderAnimator(slideIn);
            slideIn.start();
        } else {
            animationSlider.setYProgress(0f);
            animationSlider.setXProgress(0f);
        }
    } else if (fromIndex == 1 && toIndex == 0) {
        // Slide item out
        ((StackFrame) view).cancelSliderAnimator();
        int duration = Math.round(mStackSlider.getDurationForOffscreenPosition(mYVelocity));
        StackSlider animationSlider = new StackSlider(mStackSlider);
        animationSlider.setView(view);
        if (animate) {
            PropertyValuesHolder slideOutY = PropertyValuesHolder.ofFloat("YProgress", 1.0f);
            PropertyValuesHolder slideOutX = PropertyValuesHolder.ofFloat("XProgress", 0.0f);
            ObjectAnimator slideOut = ObjectAnimator.ofPropertyValuesHolder(animationSlider, slideOutX, slideOutY);
            slideOut.setDuration(duration);
            slideOut.setInterpolator(new LinearInterpolator());
            ((StackFrame) view).setSliderAnimator(slideOut);
            slideOut.start();
        } else {
            animationSlider.setYProgress(1.0f);
            animationSlider.setXProgress(0f);
        }
    } else if (toIndex == 0) {
        // Make sure this view that is "waiting in the wings" is invisible
        view.setAlpha(0.0f);
        view.setVisibility(INVISIBLE);
    } else if ((fromIndex == 0 || fromIndex == 1) && toIndex > 1) {
        view.setVisibility(VISIBLE);
        view.setAlpha(1.0f);
        view.setRotationX(0f);
        LayoutParams lp = (LayoutParams) view.getLayoutParams();
        lp.setVerticalOffset(0);
        lp.setHorizontalOffset(0);
    } else if (fromIndex == -1) {
        view.setAlpha(1.0f);
        view.setVisibility(VISIBLE);
    } else if (toIndex == -1) {
        if (animate) {
            postDelayed(new Runnable() {

                public void run() {
                    view.setAlpha(0);
                }
            }, STACK_RELAYOUT_DURATION);
        } else {
            view.setAlpha(0f);
        }
    }
    // Implement the faked perspective
    if (toIndex != -1) {
        transformViewAtIndex(toIndex, view, animate);
    }
}
Also used : LinearInterpolator(android.view.animation.LinearInterpolator) ObjectAnimator(android.animation.ObjectAnimator) PropertyValuesHolder(android.animation.PropertyValuesHolder) Paint(android.graphics.Paint)

Example 95 with LinearInterpolator

use of android.view.animation.LinearInterpolator in project smartmodule by carozhu.

the class LVCircularSmile method startViewAnim.

private ValueAnimator startViewAnim(float startF, final float endF, long time) {
    valueAnimator = ValueAnimator.ofFloat(startF, endF);
    valueAnimator.setDuration(time);
    valueAnimator.setInterpolator(new LinearInterpolator());
    //无限循环
    valueAnimator.setRepeatCount(ValueAnimator.INFINITE);
    valueAnimator.setRepeatMode(ValueAnimator.RESTART);
    valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            mAnimatedValue = (float) valueAnimator.getAnimatedValue();
            if (mAnimatedValue < 0.5) {
                isSmile = false;
                startAngle = 720 * mAnimatedValue;
            } else {
                startAngle = 720;
                isSmile = true;
            }
            invalidate();
        }
    });
    valueAnimator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
        }

        @Override
        public void onAnimationStart(Animator animation) {
            super.onAnimationStart(animation);
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
            super.onAnimationRepeat(animation);
        }
    });
    if (!valueAnimator.isRunning()) {
        valueAnimator.start();
    }
    return valueAnimator;
}
Also used : Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) LinearInterpolator(android.view.animation.LinearInterpolator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ValueAnimator(android.animation.ValueAnimator)

Aggregations

LinearInterpolator (android.view.animation.LinearInterpolator)217 ValueAnimator (android.animation.ValueAnimator)65 Animator (android.animation.Animator)42 ObjectAnimator (android.animation.ObjectAnimator)39 Paint (android.graphics.Paint)30 ArrayList (java.util.ArrayList)28 AlphaAnimation (android.view.animation.AlphaAnimation)27 RotateAnimation (android.view.animation.RotateAnimation)24 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)22 PropertyValuesHolder (android.animation.PropertyValuesHolder)18 Animatable (android.graphics.drawable.Animatable)17 View (android.view.View)17 Animation (android.view.animation.Animation)17 Transformation (android.view.animation.Transformation)17 AnimatorSet (android.animation.AnimatorSet)14 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)14 TranslateAnimation (android.view.animation.TranslateAnimation)12 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)11 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)9 AnimationListener (android.view.animation.Animation.AnimationListener)8