If you are using ListAdapter, what will you do whe...
# android
t
If you are using ListAdapter, what will you do when you want to change a property of model and notify file UI change? For example: when tapping an item change it ’s background Mine way: I’m will submit new list to adapter but not enough, it change the model in current list but UI not change yet, so I need to make model extend from
BaseObservable
and call
notifyChange
function
😶 1
j
If you mean ListAdapter for RecyclerView and if you are using DiffUtil.ItemCallback, then check your comparison functions. If the callback’s methods can detect data change correctly, submitting new list will just update the UI.
t
I did it but it not working, in
areContentsTheSame
function, I have compared every model properties
j
Is your model’s properties primitives or data classes? or try submitting new list by calling list.toList() or list.toMutableList()
t
My model properties is primitive and when I submit new list I do this
submitList(ArrayList(newList))
o
@Thanh Vu if you show us your code I can maybe help