-
Notifications
You must be signed in to change notification settings - Fork 314
Open
Description
In my project i have a chatbot recyclerView with some models represent each message. I want to continuously update an item's text and when i do i see the flickering effect. So i want to use the DiffUtils with the Payload list in onBindViewHolder. So what i did is the a created my DiffUtil.ItemCallback object and pass it to the AsyncListDifferDelegationAdapter as follow:
object : AsyncListDifferDelegationAdapter<RowUiItem>(
MESSAGE_DIFF_UTIL_CALLBACK,
receiverMessageAdapterDelegate(),
receiverNameAdapterDelegate(),
...other delegates...
) {}
}```
val MESSAGE_DIFF_UTIL_CALLBACK = object : DiffUtil.ItemCallback<RowUiItem>() {
//override methods and logic here
override fun getChangePayload(
oldItem: RowUiItem,
newItem: RowUiItem
): Any? =
if (oldItem is ServerMessageUiItem && newItem is ServerMessageUiItem) {
if (oldItem.message.size != newItem.message.size) Bundle().apply {
putString("key", "message_text")
}
else super.getChangePayload(oldItem, newItem)
}
else super.getChangePayload(oldItem, newItem)
}
Each delegate has the following form
```fun receiverMessageAdapterDelegate() =
adapterDelegateViewBinding<ReceiverMessageUiItem, RowUiItem, ItemReceiverMessageBinding>(
{ layoutInflater, parent ->
ItemReceiverMessageBinding.inflate(layoutInflater, parent, false)
}
) {
bind { it: List<Any>
....set up views here
// I want to take the Bundle payload here
}
Since i want to update the View using the payload from the "getChangePayload" inside the bind block, i want to ask how i can have those payload inside the bind block. Using the debugging mode i see that the DiffUtil never gets called
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels