Search in sources :

Example 21 with FastOutSlowInInterpolator

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

the class NavigationHeaderLayout method beginAvatarTransition.

private void beginAvatarTransition(ImageView moveAvatarOneImage, ImageView moveAvatarTwoImage, ImageView moveAvatarThreeImage) {
    ImageView appearAvatarImage = moveAvatarOneImage;
    ImageView disappearAvatarImage = moveAvatarThreeImage != null ? moveAvatarThreeImage : moveAvatarTwoImage;
    ImageView fadeOutDisappearAvatarImage = disappearAvatarImage == mAvatarImage ? mFadeOutAvatarImage : disappearAvatarImage == mRecentOneAvatarImage ? mFadeOutRecentOneAvatarImage : mFadeOutRecentTwoAvatarImage;
    TransitionSet transitionSet = new TransitionSet();
    int duration = ViewUtils.getLongAnimTime(getContext());
    // Will be set on already added and newly added transitions.
    transitionSet.setDuration(duration);
    // NOTE: TransitionSet.setInterpolator() won't have any effect on platform versions.
    // https://code.google.com/p/android/issues/detail?id=195495
    transitionSet.setInterpolator(new FastOutSlowInInterpolator());
    Fade fadeOutAvatar = new Fade(Fade.OUT);
    setAvatarImageFrom(fadeOutDisappearAvatarImage, disappearAvatarImage);
    fadeOutDisappearAvatarImage.setVisibility(VISIBLE);
    fadeOutAvatar.addTarget(fadeOutDisappearAvatarImage);
    transitionSet.addTransition(fadeOutAvatar);
    // Make it finish before new avatar arrives.
    fadeOutAvatar.setDuration(duration / 2);
    Fade fadeInAvatar = new Fade(Fade.IN);
    appearAvatarImage.setVisibility(INVISIBLE);
    fadeInAvatar.addTarget(appearAvatarImage);
    transitionSet.addTransition(fadeInAvatar);
    ChangeTransform changeAppearAvatarTransform = new ChangeTransform();
    appearAvatarImage.setScaleX(0.8f);
    appearAvatarImage.setScaleY(0.8f);
    changeAppearAvatarTransform.addTarget(appearAvatarImage);
    transitionSet.addTransition(changeAppearAvatarTransform);
    addChangeMoveToAvatarTransformToTransitionSet(moveAvatarOneImage, moveAvatarTwoImage, transitionSet);
    if (moveAvatarThreeImage != null) {
        addChangeMoveToAvatarTransformToTransitionSet(moveAvatarTwoImage, moveAvatarThreeImage, transitionSet);
    }
    CrossfadeText crossfadeText = new CrossfadeText();
    crossfadeText.addTarget(mNameText);
    crossfadeText.addTarget(mDescriptionText);
    transitionSet.addTransition(crossfadeText);
    transitionSet.addListener(new Transition.TransitionListenerAdapter() {

        @Override
        public void onTransitionEnd(Transition transition) {
            mAccountTransitionRunning = false;
            mInfoLayout.setEnabled(true);
            if (mListener != null) {
                mListener.onAccountTransitionEnd();
            }
        }
    });
    mInfoLayout.setEnabled(false);
    TransitionManager.beginDelayedTransition(this, transitionSet);
    mAccountTransitionRunning = true;
    if (mListener != null) {
        mListener.onAccountTransitionStart();
    }
    fadeOutDisappearAvatarImage.setVisibility(INVISIBLE);
    appearAvatarImage.setVisibility(VISIBLE);
    appearAvatarImage.setScaleX(1);
    appearAvatarImage.setScaleY(1);
    resetMoveToAvatarTransform(moveAvatarTwoImage);
    if (moveAvatarThreeImage != null) {
        resetMoveToAvatarTransform(moveAvatarThreeImage);
    }
}
Also used : CrossfadeText(me.zhanghai.android.douya.ui.CrossfadeText) ChangeTransform(com.transitionseverywhere.ChangeTransform) TransitionSet(com.transitionseverywhere.TransitionSet) FastOutSlowInInterpolator(androidx.interpolator.view.animation.FastOutSlowInInterpolator) Transition(com.transitionseverywhere.Transition) ImageView(android.widget.ImageView) Fade(com.transitionseverywhere.Fade)

Example 22 with FastOutSlowInInterpolator

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

the class ShapeReveal method start.

@Override
public void start(@Nullable final IEndListener listener) {
    text.setAlpha(255);
    animator = revealShape.getAnimator();
    animator.setInterpolator(new FastOutSlowInInterpolator());
    Utils.addEndListener(this, animator, new IEndListener() {

        @Override
        public void onAnimationEnd(ISurfaceAnimation animation) {
            text.removeEffect(ShapeReveal.this);
            if (hideOnEnd)
                text.setAlpha(0);
            if (listener != null)
                listener.onAnimationEnd(ShapeReveal.this);
        }
    });
    animator.setDuration(duration);
    animator.start();
}
Also used : ISurfaceAnimation(su.levenetc.android.textsurface.interfaces.ISurfaceAnimation) FastOutSlowInInterpolator(androidx.interpolator.view.animation.FastOutSlowInInterpolator) IEndListener(su.levenetc.android.textsurface.interfaces.IEndListener)

Example 23 with FastOutSlowInInterpolator

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

the class Slide method start.

@Override
public void start(@Nullable final IEndListener listener) {
    text.setAlpha(255);
    PropertyValuesHolder hHolder = null;
    PropertyValuesHolder vHolder = null;
    float fromX = 0;
    float toX = 0;
    float fromY = 0;
    float toY = 0;
    if ((side & Side.LEFT) == side) {
        if (toShow) {
            fromX = -text.getWidth();
        } else {
            toX = -text.getWidth();
        }
        hHolder = PropertyValuesHolder.ofFloat("xOffset", fromX, toX);
    } else if ((side & Side.RIGHT) == side) {
        if (toShow) {
            fromX = text.getWidth();
        } else {
            toX = text.getWidth();
        }
        hHolder = PropertyValuesHolder.ofFloat("xOffset", fromX, toX);
    }
    if ((side & Side.TOP) == side) {
        if (toShow) {
            fromY = -text.getHeight();
        } else {
            toY = -text.getHeight();
        }
        vHolder = PropertyValuesHolder.ofFloat("yOffset", fromY, toY);
    } else if ((side & Side.BOTTOM) == side) {
        if (toShow) {
            fromY = text.getHeight();
        } else {
            toY = text.getHeight();
        }
        vHolder = PropertyValuesHolder.ofFloat("yOffset", fromY, toY);
    }
    if (hHolder != null && vHolder != null) {
        animator = ObjectAnimator.ofPropertyValuesHolder(this, hHolder, vHolder);
    } else if (hHolder != null) {
        animator = ObjectAnimator.ofPropertyValuesHolder(this, hHolder);
    } else {
        animator = ObjectAnimator.ofPropertyValuesHolder(this, vHolder);
    }
    animator.setInterpolator(new FastOutSlowInInterpolator());
    Utils.addEndListener(this, animator, new IEndListener() {

        @Override
        public void onAnimationEnd(ISurfaceAnimation animation) {
            text.removeEffect(Slide.this);
            if (!toShow)
                text.setAlpha(0);
            if (listener != null)
                listener.onAnimationEnd(Slide.this);
        }
    });
    animator.setDuration(duration);
    animator.addUpdateListener(this);
    animator.start();
}
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)

Example 24 with FastOutSlowInInterpolator

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

the class TransSurface method start.

@Override
public void start(@Nullable final IEndListener listener) {
    float fromX = camera.getTransX();
    float fromY = camera.getTransY();
    float toX;
    float toY;
    if (textPivot == null) {
        toX = camera.getTransX() + dx;
        toY = camera.getTransY() + dy;
    } else {
        toX = textPivot.getPosition().getRelativeX(pivot, textPivot, true) * camera.getScale() * -1;
        toY = textPivot.getPosition().getRelativeY(pivot, textPivot, true) * camera.getScale() * -1;
    }
    debugTranslation(fromX, fromY, toX, toY);
    PropertyValuesHolder dxHolder = PropertyValuesHolder.ofFloat("transX", fromX, toX);
    PropertyValuesHolder dyHolder = PropertyValuesHolder.ofFloat("transY", fromY, toY);
    animator = ObjectAnimator.ofPropertyValuesHolder(camera, dxHolder, dyHolder);
    animator.setInterpolator(new FastOutSlowInInterpolator());
    Utils.addEndListener(this, animator, listener);
    animator.setDuration(duration);
    animator.addUpdateListener(this);
    animator.start();
}
Also used : FastOutSlowInInterpolator(androidx.interpolator.view.animation.FastOutSlowInInterpolator) PropertyValuesHolder(android.animation.PropertyValuesHolder)

Example 25 with FastOutSlowInInterpolator

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

the class PathAnimationActivity method onCreate.

@SuppressLint("ClickableViewAccessibility")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    initToolbar();
    ImageView imageView = findViewById(R.id.image);
    imageView.setImageDrawable(new DrawableImageGenerator(this).next());
    LinearLayout card = findViewById(R.id.card);
    View layout = findViewById(R.id.layout);
    layout.setOnTouchListener((v, event) -> {
        if (event.getAction() == MotionEvent.ACTION_UP) {
            NURBS nurbs = new NURBS();
            nurbs.addPoint(new PointF(card.getX() + card.getWidth() / 2, card.getY() + card.getHeight() / 2));
            nurbs.addPoint(new PointF(event.getX(), card.getY() + card.getHeight() / 2));
            nurbs.addPoint(new PointF(event.getX(), event.getY()));
            nurbs.init();
            ValueAnimator animator = ValueAnimator.ofFloat(0, 1);
            float srcWidth = card.getWidth();
            float srcHeight = card.getHeight();
            float destWidth = expanded ? getResources().getDimension(R.dimen.carbon_contentSpace) : layout.getWidth();
            float destHeight = destWidth * 9.0f / 16;
            animator.setDuration(500);
            animator.setInterpolator(new FastOutSlowInInterpolator());
            animator.addUpdateListener(animation -> {
                PointF point = nurbs.getPoint((Float) animation.getAnimatedValue());
                int w = (int) MathUtils.lerp(srcWidth, destWidth, (Float) animation.getAnimatedValue());
                int h = (int) MathUtils.lerp(srcHeight, destHeight, (Float) animation.getAnimatedValue());
                int x = (int) point.x - w / 2;
                int y = (int) point.y - h / 2;
                card.setBounds(x, y, w, h);
            });
            animator.start();
            expanded = !expanded;
        }
        return true;
    });
}
Also used : DrawableImageGenerator(tk.zielony.randomdata.common.DrawableImageGenerator) PointF(android.graphics.PointF) FastOutSlowInInterpolator(androidx.interpolator.view.animation.FastOutSlowInInterpolator) ImageView(carbon.widget.ImageView) ValueAnimator(android.animation.ValueAnimator) View(android.view.View) ImageView(carbon.widget.ImageView) LinearLayout(carbon.widget.LinearLayout) SuppressLint(android.annotation.SuppressLint) NURBS(carbon.internal.NURBS) SuppressLint(android.annotation.SuppressLint)

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