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.common.ConstantEvent
import com.lukouguoji.module_base.impl.FlowBus
import com.lukouguoji.module_base.bean.MsgReceivePool

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, itemView)

        // 选择框点击 - 切换选择状态（拦截，不触发卡片点击）
        binding.ivCheck.setOnClickListener {
            bean.checked.set(!bean.checked.get())
            FlowBus.with<String>(ConstantEvent.EVENT_CHECK_CHANGED).tryEmit("check_changed")
            binding.executePendingBindings()
        }
    }
}
