Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问MultiType与AsyncListDiffer如何结合使用 #333

Open
liukepeng opened this issue Jun 2, 2022 · 1 comment
Open

请问MultiType与AsyncListDiffer如何结合使用 #333

liukepeng opened this issue Jun 2, 2022 · 1 comment

Comments

@liukepeng
Copy link

如题

@XM-XiaoMa
Copy link

如下

class ConvAdapter : MultiTypeAdapter() {
private val asyncListDiffer: AsyncListDiffer = AsyncListDiffer(this,
object : DiffUtil.ItemCallback() {
override fun areItemsTheSame(oldItem: Any, newItem: Any): Boolean {
if (oldItem is ConvBean && newItem is ConvBean)
return oldItem.peerUser.uid == newItem.peerUser.uid
return false
}

        override fun areContentsTheSame(oldItem: Any, newItem: Any): Boolean {
            return if (oldItem is ConvBean && newItem is ConvBean) oldItem == newItem
            else if (oldItem::class == newItem::class) true
            else false
        }
    })

fun submitList(list: List<Any>) {
    items = list
    asyncListDiffer.submitList(list)
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants