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.

DiffObservableList doesn't work well with the items that extend BaseObservable

See original GitHub issue

The case is the following:

  • my DiffObservableList contains item view models that extend BaseObservable so that the items can be updated without updating the list (which is much heavier than finding an appropriate item in the DiffObservableList and updating a text on it)
  • everything works fine, assuming that I’ll not call the DiffObservableList.update method with unmodified items. The diffUtil will not find any changes but the DiffObservableList will update the internal list. The new items are not bound to the view so calling notifyPropertyChanged doesn’t have any effect.

I think the solution is to get rid of list update for items that did not change.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
evantcommented, Aug 27, 2018

So I’m not really convinced that mixing mutable and immutable changes like this is a good idea. Either you should go down the mutable route and use ObservableArrayList and change things to match your data. Or you go the immutable route and submit a new list each time.

0reactions
thunderdoggecommented, Jul 7, 2018

Recently faced the same issue. My workaround is to get hash code from list with new items and compare it with hash code from old item’s list. If hash codes are not equal, DiffObservableList should be updated.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Work with observable data objects | Android Developers
There are three different types of observable classes: objects, fields, and collections. ... the Data Binding Library provides the BaseObservable class, ...
Read more >
Why JavaFX TableView#setItems takes ObservableList<T ...
Just to sum up the comments: The reason why TableView<T> method setItems doesn't take ObservableList<? extends T> as argument, ...
Read more >
ObservableList (JavaFX 8) - Oracle Help Center
A convenient method for var-arg adding of elements. void, addListener(ListChangeListener<? super E> listener). Add a listener to this observable list.
Read more >
Handling single items using MVVM and Android Architecture ...
The model folder stores all my pojos which extends from databindings BaseObservable . Those setters are bindable and notify for changes.
Read more >
Advanced Data Binding in Android: Observables
Learn how to use the Data Binding Library to bind UI elements in your XML layouts to data sources ... The UI doesn't...
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