Search in sources :

Example 76 with AccelerateInterpolator

use of android.view.animation.AccelerateInterpolator in project UltimateAndroid by cymcsg.

the class SlideInAnimationHandler method animateMenuClosing.

@Override
public void animateMenuClosing(Point center) {
    super.animateMenuOpening(center);
    setAnimating(true);
    Animator lastAnimation = null;
    for (int i = 0; i < menu.getSubActionItems().size(); i++) {
        //            PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat(View.TRANSLATION_X, - (menu.getSubActionItems().get(i).x - center.x + menu.getSubActionItems().get(i).width / 2));
        PropertyValuesHolder pvhY = PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, DIST_Y);
        //            PropertyValuesHolder pvhsX = PropertyValuesHolder.ofFloat(View.SCALE_X, 0);
        //            PropertyValuesHolder pvhsY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 0);
        PropertyValuesHolder pvhA = PropertyValuesHolder.ofFloat(View.ALPHA, 0);
        final ObjectAnimator animation = ObjectAnimator.ofPropertyValuesHolder(menu.getSubActionItems().get(i).view, pvhY, pvhA);
        animation.setDuration(DURATION);
        animation.setInterpolator(new AccelerateInterpolator());
        animation.addListener(new SubActionItemAnimationListener(menu.getSubActionItems().get(i), ActionType.CLOSING));
        if (i == 0) {
            lastAnimation = animation;
        }
        if (i <= menu.getSubActionItems().size() / 2) {
            animation.setStartDelay(i * LAG_BETWEEN_ITEMS);
        } else {
            animation.setStartDelay((menu.getSubActionItems().size() - i) * LAG_BETWEEN_ITEMS);
        }
        animation.start();
    }
    if (lastAnimation != null) {
        lastAnimation.addListener(new LastAnimationListener());
    }
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) ObjectAnimator(android.animation.ObjectAnimator) PropertyValuesHolder(android.animation.PropertyValuesHolder) Point(android.graphics.Point)

Example 77 with AccelerateInterpolator

use of android.view.animation.AccelerateInterpolator in project UltimateAndroid by cymcsg.

the class ArcLayout method bindChildAnimation.

private void bindChildAnimation(final View child, final int index, final long duration) {
    final boolean expanded = mExpanded;
    final int centerX = getWidth() / 2;
    final int centerY = getHeight() / 2;
    final int radius = expanded ? 0 : mRadius;
    final int childCount = getChildCount();
    final float perDegrees = (mToDegrees - mFromDegrees) / (childCount - 1);
    Rect frame = computeChildFrame(centerX, centerY, radius, mFromDegrees + index * perDegrees, mChildSize);
    final int toXDelta = frame.left - child.getLeft();
    final int toYDelta = frame.top - child.getTop();
    Interpolator interpolator = mExpanded ? new AccelerateInterpolator() : new OvershootInterpolator(1.5f);
    final long startOffset = computeStartOffset(childCount, mExpanded, index, 0.1f, duration, interpolator);
    Animation animation = mExpanded ? createShrinkAnimation(0, toXDelta, 0, toYDelta, startOffset, duration, interpolator) : createExpandAnimation(0, toXDelta, 0, toYDelta, startOffset, duration, interpolator);
    final boolean isLast = getTransformedIndex(expanded, childCount, index) == childCount - 1;
    animation.setAnimationListener(new AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            if (isLast) {
                postDelayed(new Runnable() {

                    @Override
                    public void run() {
                        onAllAnimationsEnd();
                    }
                }, 0);
            }
        }
    });
    child.setAnimation(animation);
}
Also used : Rect(android.graphics.Rect) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) OvershootInterpolator(android.view.animation.OvershootInterpolator) RotateAnimation(android.view.animation.RotateAnimation) Animation(android.view.animation.Animation) Interpolator(android.view.animation.Interpolator) LinearInterpolator(android.view.animation.LinearInterpolator) OvershootInterpolator(android.view.animation.OvershootInterpolator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) AnimationListener(android.view.animation.Animation.AnimationListener)

Example 78 with AccelerateInterpolator

use of android.view.animation.AccelerateInterpolator in project UltimateAndroid by cymcsg.

the class RayLayout method bindChildAnimation.

private void bindChildAnimation(final View child, final int index, final long duration) {
    final boolean expanded = mExpanded;
    final int childCount = getChildCount();
    Rect frame = computeChildFrame(!expanded, mLeftHolderWidth, index, mChildGap, mChildSize);
    final int toXDelta = frame.left - child.getLeft();
    final int toYDelta = frame.top - child.getTop();
    Interpolator interpolator = mExpanded ? new AccelerateInterpolator() : new OvershootInterpolator(1.5f);
    final long startOffset = computeStartOffset(childCount, mExpanded, index, 0.1f, duration, interpolator);
    Animation animation = mExpanded ? createShrinkAnimation(0, toXDelta, 0, toYDelta, startOffset, duration, interpolator) : createExpandAnimation(0, toXDelta, 0, toYDelta, startOffset, duration, interpolator);
    final boolean isLast = getTransformedIndex(expanded, childCount, index) == childCount - 1;
    animation.setAnimationListener(new AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            if (isLast) {
                postDelayed(new Runnable() {

                    @Override
                    public void run() {
                        onAllAnimationsEnd();
                    }
                }, 0);
            }
        }
    });
    child.setAnimation(animation);
}
Also used : Rect(android.graphics.Rect) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) OvershootInterpolator(android.view.animation.OvershootInterpolator) RotateAnimation(android.view.animation.RotateAnimation) Animation(android.view.animation.Animation) Interpolator(android.view.animation.Interpolator) LinearInterpolator(android.view.animation.LinearInterpolator) OvershootInterpolator(android.view.animation.OvershootInterpolator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) AnimationListener(android.view.animation.Animation.AnimationListener)

Example 79 with AccelerateInterpolator

use of android.view.animation.AccelerateInterpolator in project UltimateAndroid by cymcsg.

the class CardContainer method onTouchEvent.

@Override
public boolean onTouchEvent(MotionEvent event) {
    if (mTopCard == null) {
        return false;
    }
    if (mGestureDetector.onTouchEvent(event)) {
        return true;
    }
    Log.d("Touch Event", MotionEvent.actionToString(event.getActionMasked()) + " ");
    final int pointerIndex;
    final float x, y;
    final float dx, dy;
    switch(event.getActionMasked()) {
        case MotionEvent.ACTION_DOWN:
            mTopCard.getHitRect(childRect);
            pointerIndex = event.getActionIndex();
            x = event.getX(pointerIndex);
            y = event.getY(pointerIndex);
            if (!childRect.contains((int) x, (int) y)) {
                return false;
            }
            mLastTouchX = x;
            mLastTouchY = y;
            mActivePointerId = event.getPointerId(pointerIndex);
            float[] points = new float[] { x - mTopCard.getLeft(), y - mTopCard.getTop() };
            mTopCard.getMatrix().invert(mMatrix);
            mMatrix.mapPoints(points);
            mTopCard.setPivotX(points[0]);
            mTopCard.setPivotY(points[1]);
            break;
        case MotionEvent.ACTION_MOVE:
            pointerIndex = event.findPointerIndex(mActivePointerId);
            x = event.getX(pointerIndex);
            y = event.getY(pointerIndex);
            dx = x - mLastTouchX;
            dy = y - mLastTouchY;
            if (Math.abs(dx) > mTouchSlop || Math.abs(dy) > mTouchSlop) {
                mDragging = true;
            }
            if (!mDragging) {
                return true;
            }
            mTopCard.setTranslationX(mTopCard.getTranslationX() + dx);
            mTopCard.setTranslationY(mTopCard.getTranslationY() + dy);
            mTopCard.setRotation(40 * mTopCard.getTranslationX() / (getWidth() / 2.f));
            mLastTouchX = x;
            mLastTouchY = y;
            break;
        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_CANCEL:
            if (!mDragging) {
                return true;
            }
            mDragging = false;
            mActivePointerId = INVALID_POINTER_ID;
            ValueAnimator animator = ObjectAnimator.ofPropertyValuesHolder(mTopCard, PropertyValuesHolder.ofFloat("translationX", 0), PropertyValuesHolder.ofFloat("translationY", 0), PropertyValuesHolder.ofFloat("rotation", (float) Math.toDegrees(mRandom.nextGaussian() * DISORDERED_MAX_ROTATION_RADIANS)), PropertyValuesHolder.ofFloat("pivotX", mTopCard.getWidth() / 2.f), PropertyValuesHolder.ofFloat("pivotY", mTopCard.getHeight() / 2.f)).setDuration(250);
            animator.setInterpolator(new AccelerateInterpolator());
            animator.start();
            break;
        case MotionEvent.ACTION_POINTER_UP:
            pointerIndex = event.getActionIndex();
            final int pointerId = event.getPointerId(pointerIndex);
            if (pointerId == mActivePointerId) {
                final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
                mLastTouchX = event.getX(newPointerIndex);
                mLastTouchY = event.getY(newPointerIndex);
                mActivePointerId = event.getPointerId(newPointerIndex);
            }
            break;
    }
    return true;
}
Also used : AccelerateInterpolator(android.view.animation.AccelerateInterpolator)

Example 80 with AccelerateInterpolator

use of android.view.animation.AccelerateInterpolator in project UltimateAndroid by cymcsg.

the class SpanVariableGridView method translateChild.

protected final void translateChild(View v, Point prev, Point now) {
    TranslateAnimation translate = new TranslateAnimation(Animation.ABSOLUTE, -now.x + prev.x, Animation.ABSOLUTE, 0, Animation.ABSOLUTE, -now.y + prev.y, Animation.ABSOLUTE, 0);
    translate.setInterpolator(new AccelerateInterpolator(4f));
    translate.setDuration(350);
    translate.setFillEnabled(false);
    translate.setFillAfter(false);
    v.clearAnimation();
    v.startAnimation(translate);
}
Also used : AccelerateInterpolator(android.view.animation.AccelerateInterpolator) TranslateAnimation(android.view.animation.TranslateAnimation)

Aggregations

AccelerateInterpolator (android.view.animation.AccelerateInterpolator)186 Animator (android.animation.Animator)62 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)54 View (android.view.View)52 ObjectAnimator (android.animation.ObjectAnimator)41 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)40 ImageView (android.widget.ImageView)26 AnimatorSet (android.animation.AnimatorSet)24 TextView (android.widget.TextView)23 Animation (android.view.animation.Animation)21 ValueAnimator (android.animation.ValueAnimator)17 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)14 LinearInterpolator (android.view.animation.LinearInterpolator)14 TranslateAnimation (android.view.animation.TranslateAnimation)14 OvershootInterpolator (android.view.animation.OvershootInterpolator)13 Point (android.graphics.Point)12 Paint (android.graphics.Paint)10 Interpolator (android.view.animation.Interpolator)9 AlphaAnimation (android.view.animation.AlphaAnimation)8 AnticipateOvershootInterpolator (android.view.animation.AnticipateOvershootInterpolator)8