Search in sources :

Example 46 with DecelerateInterpolator

use of android.view.animation.DecelerateInterpolator in project PhotoNoter by yydcdut.

the class FeedbackActivity method startSendingAnimation.

private void startSendingAnimation(final RevealView.RevealAnimationListener listener) {
    final int width = mFab.getLeft();
    final int height = mFab.getTop();
    ValueAnimator valueAnimator = new ValueAnimator();
    valueAnimator.setDuration(Const.DURATION / 2);
    valueAnimator.setObjectValues(new PointF(0, 0));
    valueAnimator.setInterpolator(new DecelerateInterpolator());
    valueAnimator.setEvaluator(new TypeEvaluator<PointF>() {

        @Override
        public PointF evaluate(float fraction, PointF startValue, PointF endValue) {
            PointF point = new PointF();
            point.x = (width) * (1 - fraction / 2);
            point.y = (height) - 0.85f * (height) * (fraction / 2) * (fraction / 2);
            return point;
        }
    });
    valueAnimator.start();
    valueAnimator.addUpdateListener((animation) -> {
        PointF point = (PointF) animation.getAnimatedValue();
        mFab.setX(point.x);
        mFab.setY(point.y);
    });
    valueAnimator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            mRevealView.reveal((int) mFab.getX() + mFab.getWidth() / 2, (int) mFab.getY() + mFab.getHeight() / 2, getThemeColor(), Const.RADIUS, Const.DURATION, listener);
        }
    });
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ValueAnimator(com.nineoldandroids.animation.ValueAnimator) Animator(com.nineoldandroids.animation.Animator) AnimatorListenerAdapter(com.nineoldandroids.animation.AnimatorListenerAdapter) PointF(android.graphics.PointF) ValueAnimator(com.nineoldandroids.animation.ValueAnimator)

Example 47 with DecelerateInterpolator

use of android.view.animation.DecelerateInterpolator in project PhotoNoter by yydcdut.

the class DetailActivity method initAnimationView.

@Override
public void initAnimationView() {
    new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            AnimatorSet animatorSet = new AnimatorSet();
            animatorSet.playTogether(ObjectAnimator.ofFloat(mCardView, "translationY", 0, mTranslateHeight));
            animatorSet.addListener(new AnimatorListenerAdapter() {

                @Override
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);
                    mOverlayView.setVisibility(View.GONE);
                    mIsIgnoreClick = true;
                }

                @Override
                public void onAnimationStart(Animator animation) {
                    super.onAnimationStart(animation);
                    mIsIgnoreClick = true;
                }
            });
            animatorSet.setDuration(400);
            animatorSet.setInterpolator(new DecelerateInterpolator());
            animatorSet.start();
            mAnimationHandler.postDelayed(mDownDelayRunnable, 350);
        }
    }, 500);
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) Animator(com.nineoldandroids.animation.Animator) AnimatorListenerAdapter(com.nineoldandroids.animation.AnimatorListenerAdapter) Handler(android.os.Handler) AnimatorSet(com.nineoldandroids.animation.AnimatorSet)

Example 48 with DecelerateInterpolator

use of android.view.animation.DecelerateInterpolator in project WordPress-Android by wordpress-mobile.

the class AniUtils method animateBar.

private static void animateBar(View view, boolean show, boolean isTopBar, Duration duration) {
    int newVisibility = (show ? View.VISIBLE : View.GONE);
    if (view == null || view.getVisibility() == newVisibility) {
        return;
    }
    float fromY;
    float toY;
    if (isTopBar) {
        fromY = (show ? -1f : 0f);
        toY = (show ? 0f : -1f);
    } else {
        fromY = (show ? 1f : 0f);
        toY = (show ? 0f : 1f);
    }
    Animation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, fromY, Animation.RELATIVE_TO_SELF, toY);
    long durationMillis = duration.toMillis(view.getContext());
    animation.setDuration(durationMillis);
    if (show) {
        animation.setInterpolator(new DecelerateInterpolator());
    } else {
        animation.setInterpolator(new AccelerateInterpolator());
    }
    view.clearAnimation();
    view.startAnimation(animation);
    view.setVisibility(newVisibility);
}
Also used : AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) TranslateAnimation(android.view.animation.TranslateAnimation) Animation(android.view.animation.Animation) TranslateAnimation(android.view.animation.TranslateAnimation)

Example 49 with DecelerateInterpolator

use of android.view.animation.DecelerateInterpolator in project WordPress-Android by wordpress-mobile.

the class AniUtils method showFab.

/*
     * in/out animation for floating action button
     */
public static void showFab(final View view, final boolean show) {
    if (view == null)
        return;
    Context context = view.getContext();
    int fabHeight = context.getResources().getDimensionPixelSize(android.support.design.R.dimen.design_fab_size_normal);
    int fabMargin = context.getResources().getDimensionPixelSize(R.dimen.fab_margin);
    int max = (fabHeight + fabMargin) * 2;
    float fromY = (show ? max : 0f);
    float toY = (show ? 0f : max);
    ObjectAnimator anim = ObjectAnimator.ofFloat(view, View.TRANSLATION_Y, fromY, toY);
    if (show) {
        anim.setInterpolator(new DecelerateInterpolator());
    } else {
        anim.setInterpolator(new AccelerateInterpolator());
    }
    anim.setDuration(show ? Duration.LONG.toMillis(context) : Duration.SHORT.toMillis(context));
    anim.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationStart(Animator animation) {
            super.onAnimationStart(animation);
            if (view.getVisibility() != View.VISIBLE) {
                view.setVisibility(View.VISIBLE);
            }
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            if (!show) {
                view.setVisibility(View.GONE);
            }
        }
    });
    anim.start();
}
Also used : Context(android.content.Context) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter)

Example 50 with DecelerateInterpolator

use of android.view.animation.DecelerateInterpolator in project JamsMusicPlayer by psaravan.

the class QueueDrawerFragment method animatePauseToPlay.

/**
     * Animates the pause button to a play button.
     */
private void animatePauseToPlay() {
    //Check to make sure the current icon is the pause icon.
    if (mPlayPauseButton.getId() != R.drawable.pause_light)
        return;
    //Scale out the pause button.
    final ScaleAnimation scaleOut = new ScaleAnimation(1.0f, 0.0f, 1.0f, 0.0f, mPlayPauseButton.getWidth() / 2, mPlayPauseButton.getHeight() / 2);
    scaleOut.setDuration(150);
    scaleOut.setInterpolator(new AccelerateInterpolator());
    //Scale in the play button.
    final ScaleAnimation scaleIn = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f, mPlayPauseButton.getWidth() / 2, mPlayPauseButton.getHeight() / 2);
    scaleIn.setDuration(150);
    scaleIn.setInterpolator(new DecelerateInterpolator());
    scaleOut.setAnimationListener(new Animation.AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            mPlayPauseButton.setImageResource(R.drawable.play_light);
            mPlayPauseButton.setPadding(0, 0, -5, 0);
            mPlayPauseButton.startAnimation(scaleIn);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });
    scaleIn.setAnimationListener(new Animation.AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            mPlayPauseButton.setScaleX(1.0f);
            mPlayPauseButton.setScaleY(1.0f);
            mPlayPauseButton.setId(R.drawable.play_light);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });
    mPlayPauseButton.startAnimation(scaleOut);
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) ScaleAnimation(android.view.animation.ScaleAnimation) Animation(android.view.animation.Animation) ScaleAnimation(android.view.animation.ScaleAnimation)

Aggregations

DecelerateInterpolator (android.view.animation.DecelerateInterpolator)312 ObjectAnimator (android.animation.ObjectAnimator)80 Animator (android.animation.Animator)66 ValueAnimator (android.animation.ValueAnimator)59 View (android.view.View)58 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)55 AnimatorSet (android.animation.AnimatorSet)52 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)36 ImageView (android.widget.ImageView)32 AlphaAnimation (android.view.animation.AlphaAnimation)30 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)29 Animation (android.view.animation.Animation)21 TextView (android.widget.TextView)20 Point (android.graphics.Point)18 ValueAnimator (com.nineoldandroids.animation.ValueAnimator)18 Paint (android.graphics.Paint)14 LinearInterpolator (android.view.animation.LinearInterpolator)14 ScaleAnimation (android.view.animation.ScaleAnimation)14 AnimatorSet (com.actionbarsherlock.internal.nineoldandroids.animation.AnimatorSet)14 ObjectAnimator (com.actionbarsherlock.internal.nineoldandroids.animation.ObjectAnimator)14