Search in sources :

Example 1 with FastOutLinearInInterpolator

use of androidx.interpolator.view.animation.FastOutLinearInInterpolator in project Carbon by ZieIony.

the class AnimUtils method getSlideOutAnimator.

public static ValueAnimator getSlideOutAnimator(int gravity) {
    ViewAnimator animator = new ViewAnimator();
    animator.setInterpolator(new FastOutLinearInInterpolator());
    animator.setOnSetupValuesListener(() -> {
        View view = animator.getTarget();
        int height = view.getMeasuredHeight();
        ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
        boolean top = (gravity & Gravity.BOTTOM) == Gravity.BOTTOM;
        if (layoutParams != null && layoutParams instanceof ViewGroup.MarginLayoutParams)
            height += top ? ((ViewGroup.MarginLayoutParams) layoutParams).bottomMargin : ((ViewGroup.MarginLayoutParams) layoutParams).topMargin;
        animator.setFloatValues(view.getTranslationY(), top ? height : -height);
        long duration = (long) (SHORT_ANIMATION_DURATION * (1 - Math.abs(view.getTranslationY() / height)));
        animator.setDuration(duration);
    });
    animator.addUpdateListener(valueAnimator -> {
        View view = animator.getTarget();
        view.setTranslationY((Float) valueAnimator.getAnimatedValue());
    });
    return animator;
}
Also used : ViewGroup(android.view.ViewGroup) FastOutLinearInInterpolator(androidx.interpolator.view.animation.FastOutLinearInInterpolator) ImageView(android.widget.ImageView) ProgressView(carbon.widget.ProgressView) ShadowView(carbon.view.ShadowView) View(android.view.View)

Example 2 with FastOutLinearInInterpolator

use of androidx.interpolator.view.animation.FastOutLinearInInterpolator in project Carbon by ZieIony.

the class AnimUtils method getFlyOutAnimator.

public static ValueAnimator getFlyOutAnimator() {
    ViewAnimator animator = new ViewAnimator();
    animator.setInterpolator(new FastOutLinearInInterpolator());
    animator.setOnSetupValuesListener(() -> {
        View view = animator.getTarget();
        float start = view.getAlpha();
        animator.setFloatValues(start, 0);
        animator.setDuration((long) (SHORT_ANIMATION_DURATION * start));
    });
    animator.addUpdateListener(valueAnimator -> {
        View view = animator.getTarget();
        view.setAlpha((Float) valueAnimator.getAnimatedValue());
        view.setTranslationY(Math.min(view.getHeight() / 2, view.getResources().getDimension(R.dimen.carbon_1dip) * 50.0f) * (1 - (Float) valueAnimator.getAnimatedValue()));
    });
    return animator;
}
Also used : FastOutLinearInInterpolator(androidx.interpolator.view.animation.FastOutLinearInInterpolator) ImageView(android.widget.ImageView) ProgressView(carbon.widget.ProgressView) ShadowView(carbon.view.ShadowView) View(android.view.View)

Example 3 with FastOutLinearInInterpolator

use of androidx.interpolator.view.animation.FastOutLinearInInterpolator in project Douya by DreaminginCodeZH.

the class ViewUtils method fadeOut.

public static void fadeOut(@NonNull View view, int duration, boolean gone, @Nullable Runnable nextRunnable) {
    if (view.getVisibility() != View.VISIBLE || view.getAlpha() == 0) {
        // Cancel any starting animation.
        view.animate().alpha(0).setDuration(0).start();
        view.setVisibility(gone ? View.GONE : View.INVISIBLE);
        if (nextRunnable != null) {
            nextRunnable.run();
        }
        return;
    }
    view.animate().alpha(0).setDuration(duration).setInterpolator(new FastOutLinearInInterpolator()).setListener(new AnimatorListenerAdapter() {

        private boolean mCanceled = false;

        @Override
        public void onAnimationCancel(@NonNull Animator animator) {
            mCanceled = true;
        }

        @Override
        public void onAnimationEnd(@NonNull Animator animator) {
            if (!mCanceled) {
                view.setVisibility(gone ? View.GONE : View.INVISIBLE);
                if (nextRunnable != null) {
                    nextRunnable.run();
                }
            }
        }
    }).start();
}
Also used : Animator(android.animation.Animator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) NonNull(androidx.annotation.NonNull) FastOutLinearInInterpolator(androidx.interpolator.view.animation.FastOutLinearInInterpolator)

Example 4 with FastOutLinearInInterpolator

use of androidx.interpolator.view.animation.FastOutLinearInInterpolator in project Douya by DreaminginCodeZH.

the class ProfileLayout method animateExit.

private void animateExit() {
    int offset = getOffset();
    int height = getHeight();
    if (offset >= height) {
        mListener.onExitAnimationEnd();
        return;
    }
    ObjectAnimator animator = ObjectAnimator.ofInt(this, OFFSET, offset, height);
    animator.setDuration(mShortAnimationTime);
    animator.setInterpolator(new FastOutLinearInInterpolator());
    animator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            if (mListener != null) {
                mListener.onExitAnimationEnd();
            }
        }
    });
    animator.start();
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) FastOutLinearInInterpolator(androidx.interpolator.view.animation.FastOutLinearInInterpolator)

Example 5 with FastOutLinearInInterpolator

use of androidx.interpolator.view.animation.FastOutLinearInInterpolator in project Douya by DreaminginCodeZH.

the class FriendlyFloatingActionButton method hide.

public void hide() {
    if (!mShowing) {
        return;
    }
    mShowing = false;
    cancelAnimator();
    mAnimator = ObjectAnimator.ofFloat(this, TRANSLATION_Y, getTranslationY(), getHideTranslationY()).setDuration(mAnimationDuration);
    mAnimator.setInterpolator(new FastOutLinearInInterpolator());
    mAnimator.start();
}
Also used : FastOutLinearInInterpolator(androidx.interpolator.view.animation.FastOutLinearInInterpolator)

Aggregations

FastOutLinearInInterpolator (androidx.interpolator.view.animation.FastOutLinearInInterpolator)8 View (android.view.View)3 ProgressView (carbon.widget.ProgressView)3 Animator (android.animation.Animator)2 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)2 ViewGroup (android.view.ViewGroup)2 ImageView (android.widget.ImageView)2 ShadowView (carbon.view.ShadowView)2 AnimatorSet (android.animation.AnimatorSet)1 ObjectAnimator (android.animation.ObjectAnimator)1 TextView (android.widget.TextView)1 NonNull (androidx.annotation.NonNull)1 Nullable (androidx.annotation.Nullable)1 LinearOutSlowInInterpolator (androidx.interpolator.view.animation.LinearOutSlowInInterpolator)1 Fade (androidx.transition.Fade)1 TransitionSet (androidx.transition.TransitionSet)1 Scale (com.transitionseverywhere.extra.Scale)1