New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NotifyDataSetChanged caused recycleview to blink #232
Comments
Hi. Maybe, ((DefaultItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false); ref.) Or if you want to finish all other animations (move, add or delete) immediately, try the following code. recyclerView.getItemAnimator().endAnimations(); |
Thank you for your swift reply. I have found the reason. The fault is on my side where I always return different long id in getItemId(int position) in the adapter when I do refresh. |
Yes, that is the correct solution. Using not consisted ID value causes such unwanted item animations. |
Hi, I implemented the moveitem in draggable grid layout and this causes for bad animation. It is going back to the same position and after moving and then the data changes. How to solve this!! |
Did you override getItemId correctly? If you have duplicate ids, your app might crash or views will return back to the same position.
|
Yes, I have done that! I have implemented my own moveItem as he uses the AbstractDataProvider
The items are list of strings so in order to move I am using this method. Thanks!! |
By returning the position as id, I don't think it will work as you expected. Usually I return the unique attribute of the item at that position, for example,
In your case, if each string in strings is unique, you can try:
It is not a fool-proof solution, but it should work. |
Cool, struggling to find what went wrong. Thanks for your time man! This should be properly documented in the library that the unique attribute should be given. |
If you encounter blinking as I did, make sure the id you return is unique and does not change when you move view or at any point of time. If you use strings.get(position).hashCode() as I suggested, and any string in strings is changed, it might cause blinking. |
Fixes h6ah4i#129 See also: h6ah4i#232
…pter (#400) *IMPORTANT* A new callback method have been added to SwipeableItemAdapter. So please add this new onItemSwipeStarted() method to your adapter. Inside the method, you can call notify*() method to invalidate items. Before this change, the library always calls the notifyDataSetChanged() method internally. If you need the same behavior, put a method call of notifyDataSetChanged() in the onItemSwipeStarted(). Related issues/pull requests - Only notify adapter to change the item being swiped #395 - NotifyDataSetChanged caused recycleview to blink #232 - swipe not so smooth like examples #129
…pter (#400) *IMPORTANT* A new callback method have been added to SwipeableItemAdapter. So please add this new onItemSwipeStarted() method to your adapter. Inside the method, you can call notify*() method to invalidate items. Before this change, the library always calls the notifyDataSetChanged() method internally. If you need the same behavior, put a method call of notifyDataSetChanged() in the onItemSwipeStarted(). Related issues/pull requests - Only notify adapter to change the item being swiped #395 - NotifyDataSetChanged caused recycleview to blink #232 - swipe not so smooth like examples #129
When there are items in recycleview, and I pull to refresh to get updated items from server, pass them into adapter and call notifyDataSetChanged in the adapter. It caused the recycleview to blink. The adapter here is the original adapter, not the wrapped adapter. Am I updating wrong adapter or is there any addition all steps to avoid the blink?
The text was updated successfully, but these errors were encountered: