All Downloads are FREE. Search and download functionalities are using the official Maven repository.

main.com.sceyt.chatuikit.shared.utils.MyDiffUtil.kt Maven / Gradle / Ivy

package com.sceyt.chatuikit.shared.utils

import androidx.recyclerview.widget.DiffUtil

class MyDiffUtil(private var oldList: List, private var newList: List) : DiffUtil.Callback() {

    override fun getOldListSize(): Int {
        return oldList.size
    }

    override fun getNewListSize(): Int {
        return newList.size
    }

    override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {
        val oldMessage = oldList[oldItemPosition]
        val newMessage = newList[newItemPosition]
        return (oldMessage == newMessage)
    }

    override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {
        val oldMessage = oldList[oldItemPosition]
        val newMessage = newList[newItemPosition]
        return oldMessage?.equals(newMessage) ?: false
    }

    override fun getChangePayload(oldItemPosition: Int, newItemPosition: Int): Any {
        return Any()
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy