package com.abbidot.tracker.diff

import android.text.TextUtils
import com.abbidot.tracker.base.BaseDiffCallBack
import com.abbidot.tracker.bean.MenuTxtBean


/**
 *Created  by .yzq on 2022/3/29/029.
 * @link
 * @description:
 */
class PaymentMethodDiffCallBack(oldList: MutableList<MenuTxtBean>,
                                newList: MutableList<MenuTxtBean>) :
    BaseDiffCallBack<MenuTxtBean>(oldList, newList) {

    private var mOldList = oldList
    private val mNewList = newList

    override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {
        val old = mOldList[oldItemPosition]
        val new = mNewList[newItemPosition]
        if (TextUtils.isEmpty(old.menuName) && TextUtils.isEmpty(new.menuName)) {
            return old.imageId == new.imageId
        }
        return old.menuName == new.menuName
    }

    override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {
        return mOldList[oldItemPosition].isSwitch == mNewList[newItemPosition].isSwitch &&
                mOldList[oldItemPosition].menuValue == mNewList[newItemPosition].menuValue
    }
}