package com.lukouguoji.gjj.holder

import android.view.View
import com.lukouguoji.gjj.databinding.ItemIntImpMsgParseBinding
import com.lukouguoji.module_base.base.BaseViewHolder
import com.lukouguoji.module_base.bean.MsgReceivePool

/**
 * 国际进港电报解析列表项ViewHolder
 */
class IntImpMsgParseViewHolder(view: View) :
    BaseViewHolder<MsgReceivePool, ItemIntImpMsgParseBinding>(view) {

    override fun onBind(item: Any?, position: Int) {
        val bean = getItemBean(item) ?: return
        binding.bean = bean
        binding.position = position
        binding.executePendingBindings()

        // 添加卡片点击事件 - 查看详情
        notifyItemClick(position, binding.cardView)

        // 添加选择图标点击事件 - 切换选择状态
        binding.ivCheck.setOnClickListener {
            // 反转checked状态
            bean.checked.set(!bean.checked.get())

            // 立即更新UI
            binding.executePendingBindings()
        }
    }
}
