Questions related to Android DiffUtil utility class for calculating difference between two lists
Questions tagged [android-diffutils]
121 questions
12
votes
8 answers
ListAdapter not refreshing RecyclerView if I submit the same list with different item order
I am using a RecyclerView with ListAdapter (which uses AsyncListDiffer to calculate and animate changes when list is replaced).
The problem is that if I submit() some list, then re-order that list, and submit() again, nothing happens.
How do I force…
![](../../users/profiles/1181261.webp)
Primož Kralj
- 5,534
- 14
- 65
- 125
10
votes
5 answers
DiffUtil ItemCallback areContentsTheSame() always returns true after updating an item on the ListAdapter
While using a ListAdapter I noticed that after updating an item the DiffUtil.ItemCallback areContentsTheSame() method was always returning true. Debugging the code I realized that the old and the new item were exactly the same (the old state…
![](../../users/profiles/6460150.webp)
fmiralles
- 135
- 1
- 7
10
votes
4 answers
What's wrong with my DiffUtil implementation?
Update: One of the problems is solved: Now updateList is resolved, the problem was that I defined mAdapter as RecyclerView.Adapter instead of MyAdapter. But now even though I am getting data, nothing shows up on the list, it's…
![](../../users/profiles/10705966.webp)
Stackpile
- 181
- 1
- 9
8
votes
0 answers
DiffUtil.Callback not working as expected
I am using DiffUtil.ItemCallback along with ListAdapter to update RecyclerView.
It's working pretty well but there is something that bothering me with it's behaviour.
According to the documentation, the areContentsTheSame method should be called…
![](../../users/profiles/2237148.webp)
Moti Bartov
- 2,642
- 22
- 31
6
votes
3 answers
RecyclerView scroll to top with AsyncListDiffer not working
I am using RecyclerView with AsyncListDiffer (calculates and animates differences between old and new items, all on background thread).
I have a button to sort the list. After I sort it and re-set it to RecyclerView using mDiffer.submitList(items);…
![](../../users/profiles/1181261.webp)
Primož Kralj
- 5,534
- 14
- 65
- 125
5
votes
3 answers
How to update list in RecyclerView with DiffUtils?
How do you use DiffCallback to load a newList in RecyclerView when DiffUtil ItemCallback is being used.
I would like to give the user the option to return different size lists from the database when the user selects a different size I want the…
![](../../users/profiles/3943340.webp)
Shawn
- 798
- 9
- 28
5
votes
1 answer
How to fix incorrect position I get when dispatching an update to ListUpdateCallback using DiffUtil
I have an Android application where the user can modify multiple String items using EditText at the same time, so I need to figure out what have changed in order to notify the server about the changes (create new item, update existing item or delete…
![](../../users/profiles/6457272.webp)
O-BL
- 304
- 3
- 10
4
votes
0 answers
DiffUtil areContentsTheSame() always returns true, after the contents are updated of the List in RecycleViewAdapter
This is my RecyclerView Adapter Class. Clicking an item from the list UI should change of the particular item like background black to white. After clicking an item I am changing the status of the item 0 to 1 from the UI class, based on that status…
![](../../users/profiles/14466223.webp)
Anil Adhikary
- 41
- 3
4
votes
1 answer
AsyncListDiffer is not updating the recyclerview
I have a RecyclerView with an adapter that uses AssyncListDiffer. The problem I have is that the recyclerview is not updated when changes happen in the LiveData. The observer is notified but the list doesn't update.
This is my adapter:
class…
![](../../users/profiles/4667931.webp)
Gabriel Kuka
- 164
- 1
- 11
4
votes
0 answers
RecyclerView / DiffUtils animation when dataset change without full refresh
I would like two things :
To not reload / refresh the adapter when i delete an item inside RecyclerView (no use of notifyDatasetChanged).
To do so i am using DiffUtils which works perfectly fine. But i also would like to keep the…
![](../../users/profiles/11665178.webp)
Tom3652
- 579
- 5
- 12
4
votes
1 answer
updating recycler view adapter with diff utils, isnt working correctly when adding an item
I'm using diff utils to update my recycler view (live data from view model returns a list), I have an item decoration that adds a large amount of padding to the last element in the list but as diff utils updates the recycler view properly by calling…
![](../../users/profiles/2745944.webp)
martinseal1987
- 747
- 2
- 25
- 52
3
votes
1 answer
RecyclerView not refreshed automatically with submitList() and LiveData
here is the situation:
I have a RecyclerView in a Fragment using DataBinding. Its adapter is a ListAdapter.
class MyFragment : Fragment() {
override fun onCreateView(...) {
val binding = // inflate layout with DataBindingUtil
…
![](../../users/profiles/9840279.webp)
neige-i
- 51
- 8
3
votes
1 answer
How to use DiffUtil with multiple View types
I have implemented a recyclerview with multiple view types , and i want to add DiffUtil . I managed to do so for one type but when i try to support multiple view types i can't
So my question is : does DiffUtil supports multiple view types and is…
![](../../users/profiles/11621632.webp)
AYMEN SOUMER
- 155
- 1
- 8
3
votes
1 answer
Coroutines, async DiffUtil and Inconsistency detected error
I'm having trouble putting up together Kotlin Flows and async DiffUtil.
I have this function in my RecyclerView.Adapter that computes on a computation thread a DiffUtil and dispatch updates to the RecyclerView on the Main thread :
suspend fun…
![](../../users/profiles/8096984.webp)
Charly Lafon
- 386
- 2
- 15
3
votes
1 answer
notifyItemMoved() not working when migrated to ListAdapter Android
We have this feature in our App where we can drag recycler view Items up and down.
Inside onMove() of ItemTouchHelper.Callback() we call
adapter.onItemMove(source.adapterPosition, target.adapterPosition)
and the adapter code goes like this
override…
![](../../users/profiles/3833705.webp)
shalini
- 347
- 3
- 17