Open App-rentice opened 8 years ago
@iMingHua
i will try fix it.
@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
.
@craya1982
:shipit:
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.
@sander-m
Please show me the source code :smiley_cat:
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.
https://github.com/iMingHua/ErrorNotifyItemChanged
here is my simple version
+1
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.
Hi, how does it look with this issue?
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.
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);
}
This still does not work
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);
}
}
});
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().