Questions tagged [android-diffutils]

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

180 questions
3
votes
1 answer

Object with same memory reference LiveData with Room DB and DiffUtil

I am trying to integrate the list with Room DB and Diff Utils, Issue Facing: When an item(s) is updated, LiveData got triggered but existing items in the adapter are the same as newItems. eg. OldList = [0 : "zero", 1: "one"] NewList = [0: "0",…
3
votes
0 answers

How to add search filter to RecyclerView using with DiffUtil

I have a recyclerview in my app in which I am using DiffUtil to load all the items, but now I want to add a search filter to that recyclerview how can I implement a search filter in RecyclerView which are adding items to the adapter using…
3
votes
0 answers

RecyclerView's DiffUtil scrolls the list when all visible items are getting replaced

I am using a RecyclerView with ListAdapter in which I display 2 types of items: content & placeholder. In this example the initial list consists of 10 content items and 10 placeholder items, which I then replace with another 10 content items (=…
Day
  • 844
  • 1
  • 9
  • 21
3
votes
2 answers

ListAdapter Diff does not dispatch updates on same list instance, but neither on different list from LiveData

it is a known issue that ListAdapter (actually the AsyncListDiffer from its implementation) does not update the list if the new list only has modified items but has the same instance. The updates do not work on new instance list either if you use…
3
votes
2 answers

java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid view holder adapter when using DiffUtil

Below is an adapter class for loading all book items in recycler view. Used DiffUtils so that the whole list doesn't get notified. class BooksAdapter(var mContext: Context) : RecyclerView.Adapter() { var books:…
3
votes
1 answer

DiffUtil.ItemCallback sometimes loses oldItem and causes areContentsTheSame() to incorrectly return true

I'm having an issue with the DiffUtil.ItemCallback library where the old state of a list item somehow ends up being lost and causes oldTask to have the same values as newTask. This is happening when I check/uncheck a checkbox in my ListAdapter and…
3
votes
2 answers

OnBindViewHolder on update autoScroll to top

After the adapter submitList to the DiffUtil, onBindViewHolder is called and for some reason it always scroll the list to the top. I tried every single one of the answers in SO regarding autoscroll on updating list in the recyclerview but can't…
3
votes
1 answer

Is there a need to suspend DiffUtilCallBack using coroutines when it is used to search or filter a list?

fun updateItems( newItems: List?, itemSame: (T, T) -> Boolean, contentSame: (T, T) -> Boolean ) { val diffResult = DiffUtil.calculateDiff(DiffCalc(this.items, newItems!!, itemSame, contentSame)) …
3
votes
1 answer

Android How to apply multiple filters with androidx.recyclerview.widget.DiffUtil

I am trying to create implement multiple filters for searching data in Recyclerview. For instance, in a shopping list, I can put filter like computers falling under the following criteria. Brand = apple , ScreenSize = 10 to 13 inch , HardDisk Size =…
3
votes
0 answers

Problem with nested RecyclerView + ItemDecorator + DiffUtil

I have a problem with refreshing nested recyclerview with DiffResult. I have a parents list and each parent has children list. When I want to refresh whole list then I calculate DiffResult of parents list and DiffResult of children for each parent.…
3
votes
0 answers

DiffUtil issues : old and new list are the same

Context : MainActivity launches, create a list of ItemObject, and call ListFragment. When the user clicks on button (which is in MainActivity), it modify the list, then call the listFragment to update it. Issues found : In the update function on…
Mathieu
  • 1,435
  • 3
  • 16
  • 35
2
votes
2 answers

RecyclerView inside WindowManager does not update

I try to create a notification overlay inside my application that can show notifications about certain application wise important events. I decided to use a RecyclerView which will be drown directly on WindowManager. This works fine for showing…
2
votes
0 answers

Viewpager2 with fragment and diffutil problem

I have a problem with viewpager2. Problem is There is a viewpager2 with Fragment, FragmentStateAdapter, DiffUtil If page is selected, update fragment list dynamically. (remove, add) Here is a example. A, B(current), C -> swipe to C -> A, B,…
2
votes
1 answer

Kotlin android development diffutil itemCallback type error

Im trying to implement diffutil in my adapter and im getting the following error: One type argument expected for class Result This is the code where i get the error: private val diffCallback = object: DiffUtil.ItemCallback()…
Dragos Ciupe
  • 109
  • 1
  • 7
2
votes
1 answer

ListAdapter with DiffUtil and LiveData overwriting items not appending

I implemented a ListAdapter with DiffUtil and faced an issue when appending a new list. It overwrites instead of appending to old one. To solve issue i created a new project and populate it with some test data. Here is my code: MainActivity private…
1 2
3
11 12