Can the performance of PagedList and RecyclerView interaction be improved?
Asked Answered
N

0

6

In my Android app i'm showing data in a RecyclerView using Room and the Paging library.

My implementation is quite similar to the example in the AsyncPagedListDiffer docs.

The flow is the following:

  1. Data is changed in the database
  2. A corresponding Observer passes the changes to the Adapter:

    myLiveData.observe(viewLifecycleOwner, Observer {
        myAdapter.submitList(it)
    })
    
  3. The AsyncPagedListDiffer calculates the diff and updates the list accordingly

My problem is the performance hit of step 3.

Even if i insert just one single item to the top of the list, the differ have to check all of the items (which is quite inefficient, especially with larger datasets), whereas a simple notifyItemInserted(0) call would be sufficient.

Is there a way around this behavior?

For example, can i tell the differ that it doesn't have to check all of the items? Or any other solutions to this?

I'd really appreciate any advice.

Noncombatant answered 11/10, 2018 at 17:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.