PLEASE HELPP (StackOverflow does not have the answ...
# android
s
PLEASE HELPP (StackOverflow does not have the answer) So i have a list(recycler view) of items which is loaded from a local db using room and pagination. Also i have used livedata for pagination. Now whenever i click an item, I want to highlight the text in it and save it to the database. But since this causes a change in the table, room triggers the livedata callback and the list is refreshed. So the problem is whenever i click “highlight text”, the list is refreshed and recycler view animation is fired leading to a bad ux. I want to avoid the room callback whenever i update the isHighlighted flag in the db. Also i want to keep using the pagination which uses live data observer, so i cannot remove the observer after the list is loaded.
stackoverflow 5
k
I don’t know implementation details. But using DiffUtils to calculate change-set between list updates should help you. Check https://developer.android.com/reference/android/arch/paging/AsyncPagedListDiffer
t
You can disable the default animation
a
Create a new Room Entity containing itemId and isHighlighted: Boolean or text: String to store the values if item is highlighted. Then to retrieve values, use JOIN query in the DAO interface.
s
@Antonio Yes that is exactly what I thought, but was an overkill to just highlight an item.. so I asked for help here. But I think that's the only decent way go about this.
👍 1