package kr.co.vividnext.sodalive.live.room.profile

import androidx.recyclerview.widget.DiffUtil
import kr.co.vividnext.sodalive.live.room.info.LiveRoomMember

class LiveRoomMemberResponseDiffUtilCallback(
    private val oldData: List<Any>,
    private val newData: List<Any>
) : DiffUtil.Callback() {
    override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {
        val oldItem = oldData[oldItemPosition]
        val newItem = newData[newItemPosition]

        return if (oldItem is LiveRoomMember && newItem is LiveRoomMember) {
            oldItem.id == newItem.id
        } else {
            false
        }
    }

    override fun getOldListSize(): Int = oldData.size

    override fun getNewListSize(): Int = newData.size

    override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean =
        oldData[oldItemPosition] == newData[newItemPosition]
}
