You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
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:
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
The text was updated successfully, but these errors were encountered: