Search in sources :

Example 26 with OvershootInterpolator

use of android.view.animation.OvershootInterpolator in project AndroidSweetSheet by zzz40500.

the class MenuRVAdapter method animation.

private void animation(MenuVH menuVH) {
    ViewHelper.setAlpha(menuVH.itemView, 0);
    ViewHelper.setTranslationY(menuVH.itemView, 300);
    ObjectAnimator translationY = ObjectAnimator.ofFloat(menuVH.itemView, "translationY", 500, 0);
    translationY.setDuration(300);
    translationY.setInterpolator(new OvershootInterpolator(1.6f));
    ObjectAnimator alphaIn = ObjectAnimator.ofFloat(menuVH.itemView, "alpha", 0, 1);
    alphaIn.setDuration(100);
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(translationY, alphaIn);
    animatorSet.setStartDelay(30 * menuVH.getAdapterPosition());
    animatorSet.start();
}
Also used : OvershootInterpolator(android.view.animation.OvershootInterpolator) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) AnimatorSet(com.nineoldandroids.animation.AnimatorSet)

Example 27 with OvershootInterpolator

use of android.view.animation.OvershootInterpolator in project 500px-android-blur by 500px.

the class MainActivity method shift.

public void shift(View view) {
    if (!mShifted) {
        for (ImageView imageView : mImageViews) {
            ObjectAnimator tx = ObjectAnimator.ofFloat(imageView, View.TRANSLATION_X, (mRandom.nextFloat() - 0.5f) * 500);
            tx.addUpdateListener(listener);
            ObjectAnimator ty = ObjectAnimator.ofFloat(imageView, View.TRANSLATION_Y, (mRandom.nextFloat() - 0.5f) * 500);
            ty.addUpdateListener(listener);
            AnimatorSet set = new AnimatorSet();
            set.playTogether(tx, ty);
            set.setDuration(3000);
            set.setInterpolator(new OvershootInterpolator());
            set.addListener(new AnimationEndListener(imageView));
            set.start();
        }
        mShifted = true;
    } else {
        for (ImageView imageView : mImageViews) {
            ObjectAnimator tx = ObjectAnimator.ofFloat(imageView, View.TRANSLATION_X, 0);
            tx.addUpdateListener(listener);
            ObjectAnimator ty = ObjectAnimator.ofFloat(imageView, View.TRANSLATION_Y, 0);
            ty.addUpdateListener(listener);
            AnimatorSet set = new AnimatorSet();
            set.playTogether(tx, ty);
            set.setDuration(3000);
            set.setInterpolator(new OvershootInterpolator());
            set.addListener(new AnimationEndListener(imageView));
            set.start();
        }
        mShifted = false;
    }
}
Also used : OvershootInterpolator(android.view.animation.OvershootInterpolator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorSet(android.animation.AnimatorSet) ImageView(android.widget.ImageView)

Example 28 with OvershootInterpolator

use of android.view.animation.OvershootInterpolator 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 29 with OvershootInterpolator

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

the class FloatingActionsMenu method createAddButton.

private void createAddButton(Context context) {
    mAddButton = new AddFloatingActionButton(context) {

        @Override
        void updateBackground() {
            mPlusColor = mAddButtonPlusColor;
            mColorNormal = mAddButtonColorNormal;
            mColorPressed = mAddButtonColorPressed;
            super.updateBackground();
        }

        @Override
        Drawable getIconDrawable() {
            final RotatingDrawable rotatingDrawable = new RotatingDrawable(super.getIconDrawable());
            mRotatingDrawable = rotatingDrawable;
            final OvershootInterpolator interpolator = new OvershootInterpolator();
            final ObjectAnimator collapseAnimator = ObjectAnimator.ofFloat(rotatingDrawable, "rotation", EXPANDED_PLUS_ROTATION, COLLAPSED_PLUS_ROTATION);
            final ObjectAnimator expandAnimator = ObjectAnimator.ofFloat(rotatingDrawable, "rotation", COLLAPSED_PLUS_ROTATION, EXPANDED_PLUS_ROTATION);
            collapseAnimator.setInterpolator(interpolator);
            expandAnimator.setInterpolator(interpolator);
            mExpandAnimation.play(expandAnimator);
            mCollapseAnimation.play(collapseAnimator);
            return rotatingDrawable;
        }
    };
    mAddButton.setId(R.id.fab_expand_menu_button);
    mAddButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            toggle();
        }
    });
    addView(mAddButton, super.generateDefaultLayoutParams());
}
Also used : OvershootInterpolator(android.view.animation.OvershootInterpolator) ObjectAnimator(android.animation.ObjectAnimator) LayerDrawable(android.graphics.drawable.LayerDrawable) Drawable(android.graphics.drawable.Drawable) View(android.view.View)

Example 30 with OvershootInterpolator

use of android.view.animation.OvershootInterpolator 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)

Aggregations

OvershootInterpolator (android.view.animation.OvershootInterpolator)78 ObjectAnimator (android.animation.ObjectAnimator)30 Animator (android.animation.Animator)21 AnimatorSet (android.animation.AnimatorSet)15 View (android.view.View)15 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)14 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)12 Handler (android.os.Handler)11 ValueAnimator (android.animation.ValueAnimator)10 LinearInterpolator (android.view.animation.LinearInterpolator)10 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)8 TextView (android.widget.TextView)7 Drawable (android.graphics.drawable.Drawable)6 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)6 PropertyValuesHolder (android.animation.PropertyValuesHolder)5 Rect (android.graphics.Rect)5 LayerDrawable (android.graphics.drawable.LayerDrawable)5 Interpolator (android.view.animation.Interpolator)5 Point (android.graphics.Point)4 Animation (android.view.animation.Animation)4