Questions tagged [android-diffutils]

Questions related to Android DiffUtil utility class for calculating difference between two lists

180 questions
1
vote
0 answers

Android DiffUtil without moving items

I am trying to update a RecyclerView based on a size (Int) passed to the adapter. I would like the adapter to add or remove items without moving any items as it appears to be now. I am sharing the code for DiffUtil below: fun…
Klariskao
  • 133
  • 1
  • 8
1
vote
0 answers

DiffUtil.Callback() not working as the same as notifyDataSetChanged()

I have a message list that contains messages. And I used a regular RecyclerView.Adapter instead of ListAdapter. ChatFragment chatViewModel.msgListDisplayLiveData.observe(viewLifecycleOwner, { chatAdapter.setChat(it) }) Here is the function to…
Teo
  • 876
  • 9
  • 22
1
vote
0 answers

Java android keep fragment running in the background

I use this code for change fragment; smoothBottomBar.setOnItemSelectedListener(i -> { switch (i) { case 0: fragment = new homeFragment(); break; …
1
vote
0 answers

Why does submitList method of Diffutil AsyncListDiffer not refresh my recyclerview?

I am implementing recyclerview inside recyclerview as shown in below image and using diffutil asynclistdiffer to manage the changes in list elements. List of event cards Adding code of fragment and adapters below. CustomizeEventFragment code: class…
1
vote
0 answers

Shouldn't DiffUtil compare with hashCode?

I am developing the Workout log app now. Two items (routine and routine detail) are expressed using one recycler view and adapter. If i click the Add Routine button, a routine item is added, and the routine basically has one routine detail…
ybybyb
  • 1,385
  • 1
  • 12
  • 33
1
vote
0 answers

Why is the drag animation being repeated in RecyclerView?

I am using the ItemTouchHelper class to support drag and drop in my RecyclerView. While I am dragging an item around it visually updates (swaps rows) as expected. Once I drop the item, another **visual** drag occurs. For example (see diagram below)…
1
vote
1 answer

How to search a diffutil filter out results from existing list

I'm using DiffUtil in my RecyclerView to displays a list from a database using the Room component. I would like to add a search function in the Appbar, that will filter out the existing items in the list as the user is typing. My app currently has a…
Shawn
  • 1,222
  • 1
  • 18
  • 41
1
vote
1 answer

RecyclerView row flashes/blinks when item inserted

Any time I insert an item into my Room database, my recycler view flashes the row containing the newly inserted view holder (the rest of the list does not flash). I am using LiveData to keep my list automatically updated by calling submitList(list)…
1
vote
6 answers

RecyclerView list item view not updating (using DiffUtil.ItemCallback)

SOLVED RV - recycler view I have an RV inside an alertdialog. Adapter for the RV extends ListAdapter with DiffUtil.ItemCallback. List for the adapter is being updated every 500ms using countdowntimer (checking whether the list item is downloaded or…
1
vote
1 answer

RecyclerView, with DiffUtil and LiveData

I've been stuck on this for a couple of days and could really use some help and understanding on how to setup RecylerView(RV) with DiffUtil, seems whatever I try I can't get the RV to update. I'll run through what I have and hopefully, someone can…
Shawn
  • 1,222
  • 1
  • 18
  • 41
1
vote
2 answers

LiveData with a list

I'm want to observe a MutableList so when items get added or removed from the MutableList the DiffUtil will update the RecycerView. I think the best approach to update the list is to use LiveData but I'm not able to add or remove items from the…
Shawn
  • 1,222
  • 1
  • 18
  • 41
1
vote
1 answer

nested recyclerview using paging adapter (paging 3) show wrong image after scrolling

How to solve the child adapter image that changes and show wrong images after scrolling? this is my code Parent Data Class data class Review( val author: String, val date: String, val rating: Float, val comment: String, val images:…
1
vote
2 answers

RecyclerView sets all the items when single data changed in database

I am using LiveData to fetch 30 items from the database like this: @Query("SELECT * FROM table ORDER BY id DESC LIMIT 30") fun getLast30(): LiveData> Every recycler view item has a like button and I have an interface in the…
1
vote
1 answer

Using RecyclerView with DiffUtil for multiple data types

I know how to implement DiffUtil if the adapter receive single data type objects. But in my case I have an adapter which get two data types from a fragment. So how can I use DiffUtil with multiple data types? Here is my adapter code: class…
1
vote
1 answer

DiffUtil espresso Test

[Testing] How can we write a test case for DiffUtil? val oldList = listOf("a", "b", 0) val newList = listOf("a", "c", 0, 1) How can we write a particular test case that our onBindViewHolder has not been called for the items in the new list which…