package com.hongyegroup.cpt_main.adapter

import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.guadou.cs_cptservices.binding.BaseDataBindingAdapter
import com.guadou.lib_baselib.ext.checkEmpty
import com.hongyegroup.cpt_main.BR
import com.hongyegroup.cpt_main.R
import com.hongyegroup.cpt_main.bean.NotificationBean

/**
 * 通知列表适配器
 */
class NotificationAdapter(data: MutableList<NotificationBean>) :
    BaseDataBindingAdapter<NotificationBean>(R.layout.item_notification, BR.item, data) {

    override fun convert(holder: BaseViewHolder, item: NotificationBean, payloads: List<Any>) {

        if (!payloads.checkEmpty() && payloads[0] == "read") {

            holder.setImageResource(R.id.iv_is_read, if (item.isRead) R.drawable.notify_isread_gray else R.drawable.notify_isread_red)

        } else {
            //如果默认没有payload或者不为我指定的payload,那么走原来的方法
            super.convert(holder, item, payloads)
        }


    }

}