Closed FitApps7 closed 2 years ago
Hi,
I think DiffUtil
is not what you need to fix this issue. In your case you should only update the one item that you interact with. This can be done by making the items itself Observable so their views react to changes. This is covered in the linked article under the Making an ItemViewModel observable
section.
If you still want to implement DiffUtil
in your app to make animations more smoother when something changes in a list I added sample code for that in my latest commit: 69ef882747c597d327561cea6d358d3cfa400317
The code is pretty simple I think, you just basically have to delegate the comparing functions to the ItemViewModel
classes. I plan to write a follow up article about it when I get the time.
Hi, I think
DiffUtil
is not what you need to fix this issue. In your case you should only update the one item that you interact with. This can be done by making the items itself Observable so their views react to changes. This is covered in the linked article under theMaking an ItemViewModel observable
section.If you still want to implement
DiffUtil
in your app to make animations more smoother when something changes in a list I added sample code for that in my latest commit: 69ef882747c597d327561cea6d358d3cfa400317The code is pretty simple I think, you just basically have to delegate the comparing functions to the
ItemViewModel
classes. I plan to write a follow up article about it when I get the time.
thanks, @kozmi55
I am using your approach in my project, I am using live data having two types of views, when I make changes in data, whole recyclerView invalidate to overcome this issue I want to implement DiffCallback, please guide me How I can?
https://user-images.githubusercontent.com/35890924/157379068-afd7e4ac-c8f8-4d31-9cbc-33963df46a6b.mp4