package net.pokeranalytics.android.ui.view

import androidx.annotation.Nullable
import androidx.recyclerview.widget.DiffUtil

class RowRepresentableDiffCallback(var newRows: List<RowRepresentable>, var oldRows: List<RowRepresentable>) :
	DiffUtil.Callback() {

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

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

	override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {
		return oldRows[oldItemPosition].viewType == newRows[newItemPosition].viewType
	}

	override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {
		// Force to update all the rows that were already there
		return false
	}

	@Nullable
	override fun getChangePayload(oldItemPosition: Int, newItemPosition: Int): Any? {
		//you can return particular field for changed item.
		return super.getChangePayload(oldItemPosition, newItemPosition)
	}
}