evant / binding-collection-adapter

Easy way to bind collections to listviews and recyclerviews with the new Android Data Binding framework
Apache License 2.0
1.92k stars 255 forks source link

ListView not updated if viewModel updated while view is detached from view-hierarchy #207

Closed arberg closed 2 years ago

arberg commented 4 years ago

Issue: First I create and attached a screen with a ListView in the hierarchy bound by ItemBinding and ObservableList, and I populate the list. Then I detach the screen from the view-parent, update the viewModel (due to receieved asyncronous signals), and finally I attach the screen again.

In use-case scenario: show a list, open an item on the list in another view, delete the item thus deleting it from underlying storage with listener firing back to list-view-model, and navigate user back to list.

To be honest, I'm not sure if this is not issue in this adapter, the underlying databindings or just not a feature of databindings. Though other all other databindings i've used do update if view is detached.

I'm using binding-collection-adapter 4.0.0 (android 29, and up2date on androidx libraries)

evant commented 4 years ago

Sounds like a bug. A sample project reproducing it would really help here.

arberg commented 4 years ago

Yeah I know it can be tough without a reproducing sample. I'll see if I can squeeze it in some time to build it

arberg commented 2 years ago

I'll close the issue, because i've noticed it seems to work now on my Android 11, API 30. I have remove items from my ObservableList while the view is removed from viewHierachy, it gets updated as it should when view is shown again. So my guess is that it was an android bug that has now been fixed. I'll close the issue.