Search in sources :

Example 51 with LinearInterpolator

use of android.view.animation.LinearInterpolator in project Depth-LIB-Android- by danielzeller.

the class PathBitmapMesh method startWaveAnim.

private void startWaveAnim(Bitmap bitmap, float waves, int animDuration) {
    pathOffset = ValueAnimator.ofFloat(0, ((bitmap.getWidth() / waves) * 2f) / bitmap.getWidth()).setDuration(animDuration);
    pathOffset.setRepeatCount(ValueAnimator.INFINITE);
    pathOffset.setRepeatMode(ValueAnimator.RESTART);
    pathOffset.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            pathOffsetPercent = (float) animation.getAnimatedValue();
        }
    });
    pathOffset.setInterpolator(new LinearInterpolator());
    pathOffset.start();
}
Also used : LinearInterpolator(android.view.animation.LinearInterpolator) ValueAnimator(android.animation.ValueAnimator)

Example 52 with LinearInterpolator

use of android.view.animation.LinearInterpolator in project XobotOS by xamarin.

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 53 with LinearInterpolator

use of android.view.animation.LinearInterpolator in project TastyToast by yadav-rahul.

the class DefaultToastView 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();
            postInvalidate();
        }
    });
    if (!valueAnimator.isRunning()) {
        valueAnimator.start();
    }
    return valueAnimator;
}
Also used : LinearInterpolator(android.view.animation.LinearInterpolator) ValueAnimator(android.animation.ValueAnimator)

Example 54 with LinearInterpolator

use of android.view.animation.LinearInterpolator in project TastyToast by yadav-rahul.

the class ErrorToastView 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.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            mAnimatedValue = (float) valueAnimator.getAnimatedValue();
            if (mAnimatedValue < 0.5) {
                isSad = false;
                isJustVisible = false;
                endAngle = 240 * (mAnimatedValue);
                isJustVisible = true;
            } else if (mAnimatedValue > 0.55 && mAnimatedValue < 0.7) {
                endAngle = 120;
                isSad = false;
                isJustVisible = true;
            } else {
                endAngle = 120;
                isSad = true;
                isJustVisible = false;
            }
            postInvalidate();
        }
    });
    if (!valueAnimator.isRunning()) {
        valueAnimator.start();
    }
    return valueAnimator;
}
Also used : LinearInterpolator(android.view.animation.LinearInterpolator) ValueAnimator(android.animation.ValueAnimator)

Example 55 with LinearInterpolator

use of android.view.animation.LinearInterpolator in project TastyToast by yadav-rahul.

the class SuccessToastView 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.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            mAnimatedValue = (float) valueAnimator.getAnimatedValue();
            if (mAnimatedValue < 0.5) {
                isSmileLeft = false;
                isSmileRight = false;
                endAngle = -360 * (mAnimatedValue);
            } else if (mAnimatedValue > 0.55 && mAnimatedValue < 0.7) {
                endAngle = -180;
                isSmileLeft = true;
                isSmileRight = false;
            } else {
                endAngle = -180;
                isSmileLeft = true;
                isSmileRight = true;
            }
            postInvalidate();
        }
    });
    if (!valueAnimator.isRunning()) {
        valueAnimator.start();
    }
    return valueAnimator;
}
Also used : LinearInterpolator(android.view.animation.LinearInterpolator) 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