Search in sources :

Example 1 with FastOutSlowInInterpolator

use of androidx.interpolator.view.animation.FastOutSlowInInterpolator in project TextSurface by elevenetc.

the class Rotate3D method start.

@Override
public void start(@Nullable final IEndListener listener) {
    PropertyValuesHolder valHolder = null;
    int fromDegree;
    int toDegree;
    text.setAlpha(255);
    if (show) {
        fromDegree = 90;
        toDegree = 0;
    } else {
        fromDegree = 0;
        toDegree = -90;
    }
    if ((pivot & Pivot.BOTTOM) == Pivot.BOTTOM) {
        valHolder = PropertyValuesHolder.ofFloat("rotationX", fromDegree, toDegree);
        cameraTransXPre = -text.getWidth() / 2;
        cameraTransXPost = text.getWidth() / 2;
        cameraTransYPre = -text.getFontDescent();
        cameraTransYPost = 0;
    } else if ((pivot & Pivot.TOP) == Pivot.TOP) {
        valHolder = PropertyValuesHolder.ofFloat("rotationX", -fromDegree, toDegree);
        cameraTransXPre = -text.getWidth() / 2;
        cameraTransXPost = text.getWidth() / 2;
        cameraTransYPre = text.getHeight() - text.getFontDescent();
        cameraTransYPost = -text.getHeight();
    }
    if ((pivot & Pivot.LEFT) == Pivot.LEFT) {
        valHolder = PropertyValuesHolder.ofFloat("rotationY", fromDegree, toDegree);
        cameraTransXPre = 0;
        cameraTransXPost = 0;
        cameraTransYPre = text.getHeight() / 2 - text.getFontDescent();
        cameraTransYPost = text.getHeight() / 2 - text.getHeight();
    } else if ((pivot & Pivot.RIGHT) == Pivot.RIGHT) {
        valHolder = PropertyValuesHolder.ofFloat("rotationY", -fromDegree, toDegree);
        cameraTransXPre = -text.getWidth();
        cameraTransXPost = text.getWidth();
        cameraTransYPre = text.getHeight() / 2 - text.getFontDescent();
        cameraTransYPost = text.getHeight() / 2 - text.getHeight();
    }
    if ((pivot & Pivot.CENTER) == Pivot.CENTER) {
        valHolder = PropertyValuesHolder.ofFloat(axis == Axis.Y ? "rotationY" : "rotationX", fromDegree, toDegree);
        cameraTransXPre = -text.getWidth() / 2;
        cameraTransXPost = text.getWidth() / 2;
        cameraTransYPre = text.getHeight() / 2 - text.getFontDescent();
        cameraTransYPost = text.getHeight() / 2 - text.getHeight();
    }
    if (valHolder != null) {
        animator = ObjectAnimator.ofPropertyValuesHolder(this, valHolder);
        animator.setInterpolator(new FastOutSlowInInterpolator());
        Utils.addEndListener(this, animator, new IEndListener() {

            @Override
            public void onAnimationEnd(ISurfaceAnimation animation) {
                text.removeEffect(Rotate3D.this);
                if (!show)
                    text.setAlpha(0);
                if (listener != null)
                    listener.onAnimationEnd(Rotate3D.this);
            }
        });
        animator.setDuration(duration);
        animator.addUpdateListener(this);
        animator.start();
    } else {
        throw new RuntimeException(getClass().getSuperclass() + " was not configured properly. Pivot:" + pivot);
    }
}
Also used : ISurfaceAnimation(su.levenetc.android.textsurface.interfaces.ISurfaceAnimation) FastOutSlowInInterpolator(androidx.interpolator.view.animation.FastOutSlowInInterpolator) PropertyValuesHolder(android.animation.PropertyValuesHolder) IEndListener(su.levenetc.android.textsurface.interfaces.IEndListener) Paint(android.graphics.Paint)

Example 2 with FastOutSlowInInterpolator

use of androidx.interpolator.view.animation.FastOutSlowInInterpolator in project TextSurface by elevenetc.

the class ScaleSurface method start.

@Override
public void start(@Nullable IEndListener listener) {
    float pivotX;
    float pivotY;
    if (fit == -1) {
        pivotX = textPivot.getPosition().getRelativeX(pivot, textPivot, true);
        pivotY = textPivot.getPosition().getRelativeY(pivot, textPivot, true);
    } else {
        int surfaceWidth = textSurface.getWidth();
        float textWidth = textPivot.getWidth();
        toScale = surfaceWidth / textWidth;
        pivotX = textPivot.getPosition().getRelativeX(Pivot.CENTER, textPivot, true);
        pivotY = textPivot.getPosition().getRelativeY(Pivot.CENTER, textPivot, true);
    }
    PropertyValuesHolder scaleHolder = PropertyValuesHolder.ofFloat("scale", camera.getScale(), toScale);
    PropertyValuesHolder pivotXHolder = PropertyValuesHolder.ofFloat("scalePivotX", camera.getScalePivotX(), pivotX);
    PropertyValuesHolder pivotYHolder = PropertyValuesHolder.ofFloat("scalePivotY", camera.getScalePivotY(), pivotY);
    animator = ObjectAnimator.ofPropertyValuesHolder(camera, scaleHolder, pivotXHolder, pivotYHolder);
    animator.setInterpolator(new FastOutSlowInInterpolator());
    animator.setDuration(duration);
    animator.addUpdateListener(this);
    Utils.addEndListener(this, animator, listener);
    animator.start();
}
Also used : FastOutSlowInInterpolator(androidx.interpolator.view.animation.FastOutSlowInInterpolator) PropertyValuesHolder(android.animation.PropertyValuesHolder)

Example 3 with FastOutSlowInInterpolator

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

the class TransparentDoubleClickToolbar method animateToTransparent.

public void animateToTransparent(boolean transparent) {
    if (mTransparent == transparent) {
        return;
    }
    mTransparent = transparent;
    if (mAnimator != null) {
        mAnimator.cancel();
        mAnimator = null;
    }
    mAnimator = ValueAnimator.ofInt(mAlpha, mTransparent ? 0 : 255).setDuration(mAnimationDuration);
    mAnimator.setInterpolator(new FastOutSlowInInterpolator());
    mAnimator.addUpdateListener(animation -> {
        int alpha = (int) animation.getAnimatedValue();
        setToolbarAlpha(alpha);
    });
    mAnimator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationCancel(Animator animation) {
            mAnimator = null;
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            mAnimator = null;
        }
    });
    mAnimator.start();
}
Also used : Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) FastOutSlowInInterpolator(androidx.interpolator.view.animation.FastOutSlowInInterpolator)

Example 4 with FastOutSlowInInterpolator

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

the class FriendlyFloatingActionButton method show.

public void show() {
    if (mShowing) {
        return;
    }
    mShowing = true;
    cancelAnimator();
    mAnimator = ObjectAnimator.ofFloat(this, TRANSLATION_Y, getTranslationY(), 0).setDuration(mAnimationDuration);
    mAnimator.setInterpolator(new FastOutSlowInInterpolator());
    mAnimator.start();
}
Also used : FastOutSlowInInterpolator(androidx.interpolator.view.animation.FastOutSlowInInterpolator)

Example 5 with FastOutSlowInInterpolator

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

the class FlexibleSpaceLayout method animateHeaderViewScroll.

public void animateHeaderViewScroll(boolean toCollapsed) {
    ObjectAnimator animator = ObjectAnimator.ofInt(this, SCROLL, mScroll, toCollapsed ? mHeaderView.getScrollExtent() : 0);
    animator.setDuration(mMediumAnimationTime);
    animator.setInterpolator(new FastOutSlowInInterpolator());
    animator.start();
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) FastOutSlowInInterpolator(androidx.interpolator.view.animation.FastOutSlowInInterpolator)

Aggregations

FastOutSlowInInterpolator (androidx.interpolator.view.animation.FastOutSlowInInterpolator)33 ValueAnimator (android.animation.ValueAnimator)8 Animation (android.view.animation.Animation)6 Animator (android.animation.Animator)5 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)4 PropertyValuesHolder (android.animation.PropertyValuesHolder)4 View (android.view.View)4 ViewGroup (android.view.ViewGroup)3 IEndListener (su.levenetc.android.textsurface.interfaces.IEndListener)3 ISurfaceAnimation (su.levenetc.android.textsurface.interfaces.ISurfaceAnimation)3 ObjectAnimator (android.animation.ObjectAnimator)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 AnimatorSet (android.animation.AnimatorSet)1 SuppressLint (android.annotation.SuppressLint)1