recyclerview-animators icon indicating copy to clipboard operation
recyclerview-animators copied to clipboard

Display animation when first time loads

Open roshan8 opened this issue 9 years ago • 6 comments

I'm using adapters with recyclerviews.

Animations are displayed only when we scroll through the contents of the recyclerView.

But When the first time fragment loads, How to show animations on items ?

roshan8 avatar May 08 '15 16:05 roshan8

Hi

OK, i will fix.

wasabeef avatar May 09 '15 16:05 wasabeef

+1 thanks for this library @wasabeef

im really stuck trying to implement FlipInTopXAnimator, FlipInBottomXAnimator

for the items of the recylerview when the activity/fragment loads

vnh1991 avatar Nov 16 '15 11:11 vnh1991

any update on this issue ?!

muhammad-naderi avatar Jan 09 '16 06:01 muhammad-naderi

The cause of first load animation fail is due to the view is not exist when onBindViewHolder is called. My work around is to insert the short time view.animate() function. animate() will be called when the view is rendered on screen. As the duration property is private variable. I override the setter to get the value for animations.

I would like to see if i can show some different animations on first visible items but it's difficult to calculate know the position information inside the adapter. `

public class FirstTimeSlideInRightAnimationAdapter extends SlideInRightAnimationAdapter {
    private int mDuration = 300;
    private Interpolator mInterpolator = new LinearInterpolator();

    public void setDuration(int mDuration) {
        super.setDuration(mDuration);
        this.mDuration = mDuration;
    }

    public void setInterpolator(Interpolator mInterpolator) {
        super.setInterpolator(mInterpolator);
        this.mInterpolator = mInterpolator;
    }

    public FirstTimeSlideInRightAnimationAdapter(RecyclerView.Adapter adapter) {
        super(adapter);
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        RecyclerView.ViewHolder viewHolder = super.onCreateViewHolder(parent, viewType);
        viewHolder.itemView.animate()
                .setDuration(1)
                .setListener(new Animator.AnimatorListener() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        Animator[] animators = getAnimators(viewHolder.itemView);
                        for (Animator animator : animators) {
                            animator.setDuration(mDuration).start();
                            animation.setInterpolator(mInterpolator);
                        }
                    }
// other empty override function
                }).start();
        return viewHolder;
    }
}

`

springwong avatar Jan 29 '16 19:01 springwong

You must see #14 maybe there are a way for the solution

agueroveraalvaro avatar Aug 24 '17 20:08 agueroveraalvaro

@wasabeef I am having this problem too, any way to fix it?

The problem is with SlideInBottomAnimationAdapter.

With the Alpha animation I am not getting this problem...

JavierSegoviaCordoba avatar Jan 10 '19 14:01 JavierSegoviaCordoba