Search in sources :

Example 31 with FastOutSlowInInterpolator

use of androidx.interpolator.view.animation.FastOutSlowInInterpolator in project Slide by ccrama.

the class CommentAdapterHelper method hideChildrenObject.

public static void hideChildrenObject(final View v) {
    ValueAnimator animator = ValueAnimator.ofFloat(1f, 0);
    animator.setDuration(250);
    animator.setInterpolator(new FastOutSlowInInterpolator());
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float value = (Float) animation.getAnimatedValue();
            v.setAlpha(value);
            v.setScaleX(value);
            v.setScaleY(value);
        }
    });
    animator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator arg0) {
            v.setVisibility(View.GONE);
        }

        @Override
        public void onAnimationCancel(Animator arg0) {
            v.setVisibility(View.GONE);
        }
    });
    animator.start();
}
Also used : Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) FastOutSlowInInterpolator(androidx.interpolator.view.animation.FastOutSlowInInterpolator) ValueAnimator(android.animation.ValueAnimator)

Example 32 with FastOutSlowInInterpolator

use of androidx.interpolator.view.animation.FastOutSlowInInterpolator in project Slide by ccrama.

the class AnimatorUtil method slideAnimator.

public static ValueAnimator slideAnimator(final int start, final int end, final View view) {
    final ValueAnimator animator = ValueAnimator.ofInt(start, end);
    animator.setInterpolator(new FastOutSlowInInterpolator());
    animator.addUpdateListener(valueAnimator -> {
        // Update height
        final int value = (Integer) valueAnimator.getAnimatedValue();
        final ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
        layoutParams.height = value;
        view.setLayoutParams(layoutParams);
    });
    return animator;
}
Also used : ViewGroup(android.view.ViewGroup) FastOutSlowInInterpolator(androidx.interpolator.view.animation.FastOutSlowInInterpolator) ValueAnimator(android.animation.ValueAnimator)

Example 33 with FastOutSlowInInterpolator

use of androidx.interpolator.view.animation.FastOutSlowInInterpolator in project Slide by ccrama.

the class AnimatorUtil method flipAnimator.

public static ValueAnimator flipAnimator(final boolean isFlipped, final View view) {
    final ValueAnimator animator = ValueAnimator.ofFloat(isFlipped ? -1f : 1f, isFlipped ? 1f : -1f);
    animator.setInterpolator(new FastOutSlowInInterpolator());
    // Update height
    animator.addUpdateListener(valueAnimator -> view.setScaleY((Float) valueAnimator.getAnimatedValue()));
    return animator;
}
Also used : FastOutSlowInInterpolator(androidx.interpolator.view.animation.FastOutSlowInInterpolator) ValueAnimator(android.animation.ValueAnimator)

Example 34 with FastOutSlowInInterpolator

use of androidx.interpolator.view.animation.FastOutSlowInInterpolator in project Slide by ccrama.

the class AnimatorUtil method setFlashAnimation.

public static void setFlashAnimation(final View vBig, final View from, final int color) {
    // get the center for the clipping circle
    final View v = vBig.findViewById(R.id.vote);
    v.post(() -> {
        v.setBackgroundColor(color);
        v.setVisibility(View.VISIBLE);
        v.setAlpha(1f);
        final int cx = (from.getLeft() + from.getRight()) / 2;
        final int cy = vBig.getHeight() - from.getHeight() / 2;
        // from.getRight() - ( from.getWidth()/ 2);
        // get the final radius for the clipping circle
        final int dx = Math.max(cx, vBig.getWidth() - cx);
        final int dy = Math.max(cy, vBig.getHeight() - cy);
        final float finalRadius = (float) Math.hypot(dx, dy);
        try {
            final Animator animator = ViewAnimationUtils.createCircularReveal(v, cx, cy, 0, finalRadius);
            animator.setInterpolator(new FastOutSlowInInterpolator());
            animator.setDuration(250);
            animator.start();
            v.postDelayed(() -> {
                final ObjectAnimator animator2 = ObjectAnimator.ofFloat(v, View.ALPHA, 1f, 0f);
                animator2.setInterpolator(new AccelerateDecelerateInterpolator());
                animator2.setDuration(450);
                animator2.addListener(new AnimatorListenerAdapter() {

                    @Override
                    public void onAnimationEnd(Animator animation) {
                        v.setVisibility(View.GONE);
                    }
                });
                animator2.start();
            }, 450);
        } catch (Exception e) {
            v.setVisibility(View.GONE);
        }
    });
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) FastOutSlowInInterpolator(androidx.interpolator.view.animation.FastOutSlowInInterpolator) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) View(android.view.View)

Aggregations

FastOutSlowInInterpolator (androidx.interpolator.view.animation.FastOutSlowInInterpolator)34 ValueAnimator (android.animation.ValueAnimator)8 Animator (android.animation.Animator)6 Animation (android.view.animation.Animation)6 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)4 PropertyValuesHolder (android.animation.PropertyValuesHolder)4 View (android.view.View)4 ObjectAnimator (android.animation.ObjectAnimator)3 ViewGroup (android.view.ViewGroup)3 IEndListener (su.levenetc.android.textsurface.interfaces.IEndListener)3 ISurfaceAnimation (su.levenetc.android.textsurface.interfaces.ISurfaceAnimation)3 AnimatorSet (android.animation.AnimatorSet)2 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)2 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)2 AlphaAnimation (android.view.animation.AlphaAnimation)2 AnticipateInterpolator (android.view.animation.AnticipateInterpolator)2 ScaleAnimation (android.view.animation.ScaleAnimation)2 Nullable (androidx.annotation.Nullable)2 Manifest (android.Manifest)1 TimeInterpolator (android.animation.TimeInterpolator)1