package com.lukouguoji.gjc.holder

import android.view.View
import android.widget.TextView
import com.lukouguoji.gjc.R
import com.lukouguoji.gjc.activity.GjcQueryDetailsActivity
import com.lukouguoji.gjc.activity.GjcQueryEditActivity
import com.lukouguoji.gjc.databinding.ItemGjcQueryBinding
import com.lukouguoji.module_base.base.BaseViewHolder
import com.lukouguoji.module_base.bean.GjcMaWb

/**
 * 国际出港查询列表ViewHolder
 */
class GjcQueryViewHolder(view: View) :
    BaseViewHolder<GjcMaWb, ItemGjcQueryBinding>(view) {

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

        // 立即更新UI（避免闪烁）
        binding.executePendingBindings()

        // 整行点击事件 - 跳转详情页
        binding.ll.setOnClickListener {
            GjcQueryDetailsActivity.start(it.context, bean.maWbId)
        }

        // 修改按钮点击事件
        binding.root.findViewById<TextView>(R.id.btnEdit)?.setOnClickListener {
            GjcQueryEditActivity.start(it.context, bean)
        }
    }
}
