Search in sources :

Example 66 with AccelerateInterpolator

use of android.view.animation.AccelerateInterpolator in project UltimateAndroid by cymcsg.

the class FilckerAnimationListView method animatePreLayout.

/**
	 * Animate items that are deleted entirely and items that move out of
	 * bounds.
	 */
private void animatePreLayout(final float durationUnit, final Animator.AnimatorListener listener) {
    final AnimatorSet animatorSet = new AnimatorSet();
    final int firstVisiblePosition = getFirstVisiblePosition();
    final int childCount = getChildCount();
    for (final Iterator<Entry<Long, Float>> iter = yMap.entrySet().iterator(); iter.hasNext(); ) {
        final Entry<Long, Float> entry = iter.next();
        final long id = entry.getKey();
        final int oldPos = positionMap.get(id);
        final View child = getChildAt(oldPos - firstVisiblePosition);
        final int newPos = getPositionForId(id);
        // fade out items that disappear
        if (newPos == -1) {
            final ObjectAnimator anim = animateAlpha(child, false);
            animatorSet.play(anim);
            iter.remove();
            positionMap.remove(id);
            continue;
        }
        // translate items that move out of bounds
        if (newPos < firstVisiblePosition || newPos > firstVisiblePosition + childCount) {
            final float offset;
            if (newPos < firstVisiblePosition) {
                offset = -getHeight();
            } else {
                offset = getHeight();
            }
            final AnimatorProxy proxy = AnimatorProxy.wrap(child);
            final ObjectAnimator anim = ObjectAnimator.ofFloat(proxy, "translationY", 0f, offset);
            final int finalDuration = getDuration(0, getHeight() / 2, durationUnit);
            anim.setInterpolator(new AccelerateInterpolator());
            anim.setDuration((long) (finalDuration * animationDurationFactor));
            animatorSet.addListener(new AnimatorListenerAdapter() {

                @Override
                public void onAnimationEnd(final Animator animation) {
                    child.post(new Runnable() {

                        @Override
                        public void run() {
                            proxy.setTranslationY(0f);
                        }
                    });
                }
            });
            animatorSet.play(anim);
            iter.remove();
            positionMap.remove(id);
            continue;
        }
    }
    if (!animatorSet.getChildAnimations().isEmpty()) {
        animatorSet.addListener(listener);
        animatorSet.start();
    } else {
        listener.onAnimationEnd(animatorSet);
    }
}
Also used : AccelerateInterpolator(android.view.animation.AccelerateInterpolator) ObjectAnimator(com.marshalchen.common.uimodule.nineoldandroids.animation.ObjectAnimator) AnimatorSet(com.marshalchen.common.uimodule.nineoldandroids.animation.AnimatorSet) View(android.view.View) ListView(android.widget.ListView) Entry(java.util.Map.Entry) Animator(com.marshalchen.common.uimodule.nineoldandroids.animation.Animator) ObjectAnimator(com.marshalchen.common.uimodule.nineoldandroids.animation.ObjectAnimator) AnimatorListenerAdapter(com.marshalchen.common.uimodule.nineoldandroids.animation.AnimatorListenerAdapter) AnimatorProxy(com.marshalchen.common.uimodule.nineoldandroids.view.animation.AnimatorProxy)

Example 67 with AccelerateInterpolator

use of android.view.animation.AccelerateInterpolator in project Swipecards by Diolor.

the class FlingCardListener method onSelected.

public void onSelected(final boolean isLeft, float exitY, long duration) {
    isAnimationRunning = true;
    float exitX;
    if (isLeft) {
        exitX = -objectW - getRotationWidthOffset();
    } else {
        exitX = parentWidth + getRotationWidthOffset();
    }
    this.frame.animate().setDuration(duration).setInterpolator(new AccelerateInterpolator()).x(exitX).y(exitY).setListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            if (isLeft) {
                mFlingListener.onCardExited();
                mFlingListener.leftExit(dataObject);
            } else {
                mFlingListener.onCardExited();
                mFlingListener.rightExit(dataObject);
            }
            isAnimationRunning = false;
        }
    }).rotation(getExitRotation(isLeft));
}
Also used : Animator(android.animation.Animator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter)

Example 68 with AccelerateInterpolator

use of android.view.animation.AccelerateInterpolator in project Android-Bootstrap by Bearded-Hen.

the class BootstrapAlert method setupAnimations.

private void setupAnimations() {
    fadeInAnimation = new AlphaAnimation(0.0f, 1.0f);
    fadeInAnimation.setDuration(300);
    fadeInAnimation.setInterpolator(new AccelerateInterpolator());
    fadeInAnimation.setAnimationListener(this);
    fadeOutAnimation = new AlphaAnimation(1.0f, 0.0f);
    fadeOutAnimation.setDuration(300);
    fadeOutAnimation.setInterpolator(new AccelerateInterpolator());
    fadeOutAnimation.setAnimationListener(this);
}
Also used : AccelerateInterpolator(android.view.animation.AccelerateInterpolator) AlphaAnimation(android.view.animation.AlphaAnimation)

Example 69 with AccelerateInterpolator

use of android.view.animation.AccelerateInterpolator in project TransitionHelper by ImmortalZ.

the class ColorShowMethod method translate.

@Override
public void translate(InfoBean bean, RenderView parent, View child) {
    if (startColor != 0) {
        startColor = parent.getResources().getColor(startColor);
    } else {
        startColor = parent.getResources().getColor(R.color.showmethod_start_color);
    }
    if (endColor != 0) {
        endColor = parent.getResources().getColor(endColor);
    } else {
        endColor = parent.getResources().getColor(R.color.showmethod_end_color);
    }
    parent.setPaintColor(endColor);
    ObjectAnimator colorAnimator = ObjectAnimator.ofInt(parent, "backgroundColor", startColor, endColor);
    colorAnimator.setEvaluator(new ArgbEvaluator());
    set.playTogether(ObjectAnimator.ofFloat(child, "translationX", 0, -bean.translationX), ObjectAnimator.ofFloat(child, "translationY", 0, -bean.translationY), ObjectAnimator.ofFloat(child, "scaleX", 1 / bean.scalling), ObjectAnimator.ofFloat(child, "scaleY", 1 / bean.scalling), colorAnimator);
    set.setInterpolator(new AccelerateInterpolator());
    set.setDuration(duration).start();
}
Also used : AccelerateInterpolator(android.view.animation.AccelerateInterpolator) ObjectAnimator(android.animation.ObjectAnimator) ArgbEvaluator(android.animation.ArgbEvaluator)

Example 70 with AccelerateInterpolator

use of android.view.animation.AccelerateInterpolator in project TransitionHelper by ImmortalZ.

the class InflateShowMethod method translate.

@Override
public void translate(InfoBean bean, RenderView parent, View child) {
    set.playTogether(ObjectAnimator.ofFloat(child, "translationX", 0, -bean.translationX), ObjectAnimator.ofFloat(child, "translationY", 0, -bean.translationY), ObjectAnimator.ofFloat(child, "scaleX", 1, 1 / bean.scalling), ObjectAnimator.ofFloat(child, "scaleY", 1, 1 / bean.scalling));
    set.setInterpolator(new AccelerateInterpolator());
    set.setDuration(duration).start();
}
Also used : AccelerateInterpolator(android.view.animation.AccelerateInterpolator)

Aggregations

AccelerateInterpolator (android.view.animation.AccelerateInterpolator)186 Animator (android.animation.Animator)62 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)54 View (android.view.View)52 ObjectAnimator (android.animation.ObjectAnimator)41 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)40 ImageView (android.widget.ImageView)26 AnimatorSet (android.animation.AnimatorSet)24 TextView (android.widget.TextView)23 Animation (android.view.animation.Animation)21 ValueAnimator (android.animation.ValueAnimator)17 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)14 LinearInterpolator (android.view.animation.LinearInterpolator)14 TranslateAnimation (android.view.animation.TranslateAnimation)14 OvershootInterpolator (android.view.animation.OvershootInterpolator)13 Point (android.graphics.Point)12 Paint (android.graphics.Paint)10 Interpolator (android.view.animation.Interpolator)9 AlphaAnimation (android.view.animation.AlphaAnimation)8 AnticipateOvershootInterpolator (android.view.animation.AnticipateOvershootInterpolator)8