Search in sources :

Example 1 with BaseItemAnimator

use of com.dk.animation.effect.BaseItemAnimator in project RecyclerViewAnimator by dkmeteor.

the class StandUpIn method startAnimation.

@Override
public void startAnimation(final ViewHolder holder, long duration, final BaseItemAnimator animator) {
    System.out.println("startAnimation");
    float x = (holder.itemView.getWidth() - holder.itemView.getPaddingLeft() - holder.itemView.getPaddingRight()) / 2 + holder.itemView.getPaddingLeft();
    float y = holder.itemView.getHeight() - holder.itemView.getPaddingBottom();
    AnimatorSet set = new AnimatorSet();
    set.playTogether(ObjectAnimator.ofFloat(holder.itemView, "pivotX", x, x, x, x, x), ObjectAnimator.ofFloat(holder.itemView, "pivotY", y, y, y, y, y), ObjectAnimator.ofFloat(holder.itemView, "rotationX", 90, 55, -30, 15, -15, 0));
    set.addListener(new AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animation) {
        // TODO Auto-generated method stub
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        // TODO Auto-generated method stub
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            animator.dispatchAddFinished(holder);
            animator.mAddAnimations.remove(holder);
            animator.dispatchFinishedWhenDone();
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        // TODO Auto-generated method stub
        }
    });
    set.setStartDelay(mDelay * mDelayCount);
    set.setDuration(animator.getAddDuration());
    set.start();
    animator.mAddAnimations.add(holder);
}
Also used : AnimatorListener(android.animation.Animator.AnimatorListener) BaseItemAnimator(com.dk.animation.effect.BaseItemAnimator) ObjectAnimator(android.animation.ObjectAnimator) SegmentAnimator(com.dk.animation.effect.SegmentAnimator) Animator(android.animation.Animator) AnimatorSet(android.animation.AnimatorSet)

Example 2 with BaseItemAnimator

use of com.dk.animation.effect.BaseItemAnimator in project RecyclerViewAnimator by dkmeteor.

the class DropOut method startAnimation.

@Override
public void startAnimation(final ViewHolder holder, long duration, final BaseItemAnimator animator) {
    ViewCompat.animate(holder.itemView).cancel();
    AnimatorSet set = new AnimatorSet();
    int abs = Math.random() > 0.5 ? -1 : 1;
    ObjectAnimator objectAnimatorAnimatorR = ObjectAnimator.ofFloat(holder.itemView, "rotation", abs * 30, abs * 90);
    ObjectAnimator objectAnimatorAnimatorT = ObjectAnimator.ofFloat(holder.itemView, "translationY", 0, ViewUtils.getScreenHeight());
    set.addListener(new AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animation) {
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            animator.dispatchAddFinished(holder);
            animator.mAddAnimations.remove(holder);
            animator.dispatchFinishedWhenDone();
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        }
    });
    set.playTogether(objectAnimatorAnimatorR, objectAnimatorAnimatorT);
    set.setStartDelay(mDelay * mDelayCount);
    set.setDuration(animator.getAddDuration());
    set.start();
    animator.mAddAnimations.add(holder);
}
Also used : AnimatorListener(android.animation.Animator.AnimatorListener) BaseItemAnimator(com.dk.animation.effect.BaseItemAnimator) ObjectAnimator(android.animation.ObjectAnimator) SegmentAnimator(com.dk.animation.effect.SegmentAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorSet(android.animation.AnimatorSet)

Example 3 with BaseItemAnimator

use of com.dk.animation.effect.BaseItemAnimator in project RecyclerViewAnimator by dkmeteor.

the class FlipHorizonIn method startAnimation.

@Override
public void startAnimation(final ViewHolder holder, long duration, final BaseItemAnimator animator) {
    ViewCompat.animate(holder.itemView).cancel();
    AnimatorSet set = new AnimatorSet();
    set.playTogether(ObjectAnimator.ofFloat(holder.itemView, "rotationY", 90, -15, 15, 0), ObjectAnimator.ofFloat(holder.itemView, "alpha", 0.25f, 0.5f, 0.75f, 1));
    set.addListener(new AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animation) {
        // TODO Auto-generated method stub
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        // TODO Auto-generated method stub
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            animator.dispatchAddFinished(holder);
            animator.mAddAnimations.remove(holder);
            animator.dispatchFinishedWhenDone();
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        // TODO Auto-generated method stub
        }
    });
    set.setStartDelay(mDelay * mDelayCount);
    set.setDuration(animator.getAddDuration());
    set.start();
    animator.mAddAnimations.add(holder);
}
Also used : AnimatorListener(android.animation.Animator.AnimatorListener) BaseItemAnimator(com.dk.animation.effect.BaseItemAnimator) ObjectAnimator(android.animation.ObjectAnimator) SegmentAnimator(com.dk.animation.effect.SegmentAnimator) Animator(android.animation.Animator) AnimatorSet(android.animation.AnimatorSet)

Example 4 with BaseItemAnimator

use of com.dk.animation.effect.BaseItemAnimator in project RecyclerViewAnimator by dkmeteor.

the class HingeOut method startAnimation.

@Override
public void startAnimation(final ViewHolder holder, long duration, final BaseItemAnimator animator) {
    ViewCompat.animate(holder.itemView).cancel();
    AnimatorSet set = new AnimatorSet();
    View target = holder.itemView;
    int abs = Math.random() > 0.5 ? -1 : 1;
    float x, y;
    if (abs > 0) {
        x = target.getPaddingLeft();
        y = target.getPaddingTop();
    } else {
        x = target.getWidth();
        y = target.getPaddingTop();
    }
    set.setDuration(animator.getRemoveDuration());
    set.addListener(new AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animation) {
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            animator.dispatchAddFinished(holder);
            animator.mAddAnimations.remove(holder);
            animator.dispatchFinishedWhenDone();
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        }
    });
    set.playTogether(ObjectAnimator.ofFloat(target, "rotation", 0, abs * 80, abs * 60, abs * 80, abs * 60, abs * 60), ObjectAnimator.ofFloat(target, "translationY", 0, 0, 0, 0, 0, 700), ObjectAnimator.ofFloat(target, "alpha", 1, 1, 1, 1, 1, 0), ObjectAnimator.ofFloat(target, "pivotX", x, x, x, x, x, x), ObjectAnimator.ofFloat(target, "pivotY", y, y, y, y, y, y));
    set.setStartDelay(mDelay * mDelayCount);
    set.setDuration(animator.getAddDuration());
    set.start();
    animator.mAddAnimations.add(holder);
}
Also used : AnimatorListener(android.animation.Animator.AnimatorListener) BaseItemAnimator(com.dk.animation.effect.BaseItemAnimator) ObjectAnimator(android.animation.ObjectAnimator) SegmentAnimator(com.dk.animation.effect.SegmentAnimator) Animator(android.animation.Animator) AnimatorSet(android.animation.AnimatorSet) View(android.view.View)

Example 5 with BaseItemAnimator

use of com.dk.animation.effect.BaseItemAnimator in project RecyclerViewAnimator by dkmeteor.

the class FlipVertialIn method startAnimation.

@Override
public void startAnimation(final ViewHolder holder, long duration, final BaseItemAnimator animator) {
    ViewCompat.animate(holder.itemView).cancel();
    AnimatorSet set = new AnimatorSet();
    set.playTogether(ObjectAnimator.ofFloat(holder.itemView, "rotationX", 90, -15, 15, 0), ObjectAnimator.ofFloat(holder.itemView, "alpha", 0.25f, 0.5f, 0.75f, 1));
    set.addListener(new AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animation) {
        // TODO Auto-generated method stub
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        // TODO Auto-generated method stub
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            animator.dispatchAddFinished(holder);
            animator.mAddAnimations.remove(holder);
            animator.dispatchFinishedWhenDone();
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        // TODO Auto-generated method stub
        }
    });
    set.setStartDelay(mDelay * mDelayCount);
    set.setDuration(animator.getAddDuration());
    set.start();
    animator.mAddAnimations.add(holder);
}
Also used : AnimatorListener(android.animation.Animator.AnimatorListener) BaseItemAnimator(com.dk.animation.effect.BaseItemAnimator) ObjectAnimator(android.animation.ObjectAnimator) SegmentAnimator(com.dk.animation.effect.SegmentAnimator) Animator(android.animation.Animator) AnimatorSet(android.animation.AnimatorSet)

Aggregations

Animator (android.animation.Animator)6 AnimatorListener (android.animation.Animator.AnimatorListener)6 ObjectAnimator (android.animation.ObjectAnimator)6 BaseItemAnimator (com.dk.animation.effect.BaseItemAnimator)6 SegmentAnimator (com.dk.animation.effect.SegmentAnimator)6 AnimatorSet (android.animation.AnimatorSet)5 View (android.view.View)1