Android Open Source - RecyclerViewLib From Top Item Animator






From Project

Back to project page RecyclerViewLib.

License

The source code is released under:

Apache License

If you think the Android project RecyclerViewLib listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.twotoasters.anim;
//www  . j  a va  2  s.c  o  m
import android.graphics.Point;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewPropertyAnimatorCompat;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.OvershootInterpolator;

import com.twotoasters.android.support.v7.widget.RecyclerView.ViewHolder;
import com.twotoasters.utils.DisplayUtils;

public class FromTopItemAnimator extends PendingItemAnimator {

    public FromTopItemAnimator() {
        setMoveDuration(200);
        setRemoveDuration(500);
        setAddDuration(300);
    }

    @Override
    protected boolean prepHolderForAnimateRemove(ViewHolder holder) {
        return true;
    }

    @Override
    protected ViewPropertyAnimatorCompat animateRemoveImpl(ViewHolder holder) {
        Point screen = DisplayUtils.getScreenDimensions(holder.itemView.getContext());
        int top = holder.itemView.getTop();
        return ViewCompat.animate(holder.itemView)
                .rotation(80)
                .translationY(screen.y - top)
                .setInterpolator(new AccelerateInterpolator());
    }

    @Override
    protected void onRemoveCanceled(ViewHolder holder) {
        ViewCompat.setTranslationY(holder.itemView, 0);
    }

    @Override
    protected boolean prepHolderForAnimateAdd(ViewHolder holder) {
        int bottom = holder.itemView.getBottom();
        ViewCompat.setTranslationY(holder.itemView, - bottom);
        return true;
    }

    @Override
    protected ViewPropertyAnimatorCompat animateAddImpl(ViewHolder holder) {
        return ViewCompat.animate(holder.itemView)
                .translationY(0)
                .setInterpolator(new OvershootInterpolator());
    }

    @Override
    protected void onAddCanceled(ViewHolder holder) {
        ViewCompat.setTranslationY(holder.itemView, 0);
    }
}




Java Source Code List

com.twotoasters.android.support.v7.widget.CardViewDelegate.java
com.twotoasters.android.support.v7.widget.CardViewEclairMr1.java
com.twotoasters.android.support.v7.widget.CardViewImpl.java
com.twotoasters.android.support.v7.widget.CardViewJellybeanMr1.java
com.twotoasters.android.support.v7.widget.CardView.java
com.twotoasters.android.support.v7.widget.DefaultItemAnimator.java
com.twotoasters.android.support.v7.widget.LinearLayoutManager.java
com.twotoasters.android.support.v7.widget.LinearSmoothScroller.java
com.twotoasters.android.support.v7.widget.PositionMap.java
com.twotoasters.android.support.v7.widget.RecyclerView.java
com.twotoasters.android.support.v7.widget.RoundRectDrawableWithShadow.java
com.twotoasters.anim.FlipDownItemAnimator.java
com.twotoasters.anim.FromTopItemAnimator.java
com.twotoasters.anim.GarageDoorItemAnimator.java
com.twotoasters.anim.PendingItemAnimator.java
com.twotoasters.anim.SlideItemAnimator.java
com.twotoasters.layoutmanager.BaseLayoutManager.java
com.twotoasters.layoutmanager.GridLayoutManager.java
com.twotoasters.recycled.ApplicationTest.java
com.twotoasters.recycled.Item.java
com.twotoasters.recycled.NameAdapter.java
com.twotoasters.recycled.NameViewHolder.java
com.twotoasters.recycled.RecycleActivity.java
com.twotoasters.recycled.factory.ItemAnimationFactory.java
com.twotoasters.recycled.factory.NameFactory.java
com.twotoasters.utils.DisplayUtils.java