question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

LiveData and Adapters

See original GitHub issue

What is the best way to handle adapter updates with data arriving only through LiveData?

With everything in Activity, you could call all methods, such as adapter.notifyItemAdded(), but with LiveData you can only submit one type of item, generally whole list to display. That way you can only call adapter.notifyDataSetChanged() which documentation states it should be used as last resort.

So is there any better way to do it, or do we just need to call adapter.notifyDataSetChanged() from now on?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:22 (2 by maintainers)

github_iconTop GitHub Comments

29reactions
makk909commented, Jan 31, 2018

I don’t think any of the solutions mentioned above has related to the Original Question, I want this issue to be reopened as currently I find no way to update a single item in RecyclerView Adapter using LiveData inside ViewModel, we have to set entire list everytime which I don’t think a better solution or technique.

28reactions
justjannecommented, Sep 7, 2017

I’d like to know this as well – I’m working with large (tenthousands of items) datasets, and need to handle their LiveData<List<…>> changing frequently. Just diffing them is a major waste of time. A LiveDataCollection type that can handle collections, and changes within them, would be a major improvement.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to set LiveData from Adapter? - Stack Overflow
I set up an onClickListener in the ViewHolder class inside the RecyclerView.Adapter of the Library Fragment. So, when an item is clicked, the ......
Read more >
Recycler View With MVVM Livedata - Medium
Live data is nothing just an observer pattern using ViewModel, ... Recycler View With MVVM Livedata ... Create Recyclerview Adapter xml
Read more >
LiveAdapter, Android: RecyclerView Adapter for LiveData
Not even a ViewHolder! Based on Android Data Binding; Written in Kotlin; Supports LiveData; No need to write the adapter; No need to...
Read more >
Flexible RecyclerView Adapter with MVVM and Data Binding
A RecyclerView Adapter that can handle multiple item types without ... value of our LiveData object which will be bound to the XML...
Read more >
Why does recyclerview adapter often changes from livedata ...
Coding example for the question Why does recyclerview adapter often changes from livedata observer even though no changes are there?-kotlin.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found