wasabeef / recyclerview-animators

An Android Animation library which easily add itemanimator to RecyclerView items.
Apache License 2.0
11.49k stars 1.98k forks source link

Animation issue after calling notifyitemchanged #50

Open App-rentice opened 8 years ago

App-rentice commented 8 years ago

Hello, I have compiled the latest recyclerview-animators:2.0.0 and the latest recyclerview-v7:23.1.0.

After calling notifyItemChanged(position) and after that notifyItemRemoved(position) (the position is the same), the remove-animation freezes. (sometimes the item re-appears after the remove-animation over an other item at the same position it was "removed") I use the simple SlideInLeftAnimator.

Without the animator everything works fine or without calling notifyItemChanged().

wasabeef commented 8 years ago

@iMingHua

i will try fix it.

wasabeef commented 8 years ago

@iMingHua @sander-m

They don’t, which is why notifyDataSetChanged should be your last resort. When notifyDataSetChanged is called on the adapter, RecyclerView does not know where items moved so it cannot properly fake getViewForPosition calls. It simply runs animations as a LayoutTransition would do.

So, you should use notifyItemRemoved, the notifyItemInserted.

wasabeef commented 8 years ago

@craya1982

:shipit:

sander-m commented 8 years ago

I'm not sure if I fully understand you, but I'm not calling notifyDatasetChanged(). I'm calling notifyItemChanged(int position) which should apply the animateChange animation, but this doesn't work since v2.0.0.

wasabeef commented 8 years ago

@sander-m

Please show me the source code :smiley_cat:

sander-m commented 8 years ago

I'm using the SlideInLeftAnimator on my RecyclerView (mOptionList):

RecyclerView.ItemAnimator animator = new SlideInLeftAnimator();
mOptionList.setItemAnimator(animator);

This is my code within the adapter:

public void insertOption(int position, Option o) {
    mData.options.add(position, o);
    notifyItemInserted(position);
}

public void removeOption(int position) {
    mData.options.remove(position);
    notifyItemRemoved(position);
}

public void setOption(int position, Option o) {
    mData.options.set(position, o); //update actual data
    notifyItemChanged(position); // notify the adapter, should display fade change animation?
}

public void moveOption(int fromPosition, int toPosition) {
    Option o = mData.options.remove(fromPosition);
    mData.options.add(toPosition, o);
    notifyItemMoved(fromPosition, toPosition);
}

The problem is with notifyItemChanged(position). Previously (e.g. in 1.3.0), a fade animation is shown. With 2.0.0. the content changes but there is no fade animation. I have just reverted back to 1.3.0 and the fade works again.

App-rentice commented 8 years ago

https://github.com/iMingHua/ErrorNotifyItemChanged

here is my simple version

ygnessin commented 8 years ago

+1

dostalleos commented 8 years ago

I have same issue with FadeInAnimation(). I'm calling notifyItemChanged() and then notifyItemRemoved () after 2sec on the same position. If the item is fully visible everything is ok. Buit if only part of the item is visible, then it makes remove animation correctly and then removed item popup and freez there.

dostalleos commented 8 years ago

Hi, how does it look with this issue?

brkckr commented 8 years ago

Hi, i have the same issue which is spinner's part remains on the screen when i call the notifyItemChanged(position). After scrolling, it disappears.

Also, is that possible way to call notifyItemChanged without an animation? 10x a lot.

luizotavionunes commented 7 years ago

Hello, i got same problem here when using notifyItemRemoved and notifyItemChanged. Like App-Rentice said, sometimes the item re-appears after the remove-animation over an other item at the same position it was removed, but if you scroll recycler view everything gets normal.

private void remove(int pos) {
    if(pos<0)
        return;
    //productList.removeViewAt(pos);
    m_markets.remove(pos);
    notifyItemRemoved(pos);
}
mladenrakonjac commented 7 years ago

This still does not work

3zcs commented 6 years ago

Not work with me also

recyclerView.setItemAnimator(new SlideInRightAnimator());
recyclerView.getItemAnimator().setRemoveDuration(2000);
button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                for (int i = myList.size()-1 ; i >= 0 ; i--){
                    myList.remove(i);
                    adapter.notifyItemRemoved(i);
                }
            }
        });