package com.rehome.bhdxj.adapter


import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.rehome.bhdxj.base.BaseViewBindingAdapter
import com.rehome.bhdxj.bean.QxgdAddressBean
import com.rehome.bhdxj.databinding.AdapterQxgdSearchAddressBinding


class QxgdSearchAddressAdapter(var context: Context,
                               var data: MutableList<QxgdAddressBean.DataBean>, var btnClickListener: QxgdAddressAdapterBtnClickListener) : BaseViewBindingAdapter<AdapterQxgdSearchAddressBinding>(context) {

                         //QxgdAddressBean

    override fun getCount(): Int {
        return data.count()
    }

    override fun getItem(position: Int): Any {
        return data[position]
    }

    override fun getItemId(position: Int): Long {
        return position.toLong()
    }

    override fun getBinding(
        inflater: LayoutInflater,
        parent: ViewGroup?
    ) = AdapterQxgdSearchAddressBinding.inflate(inflater, parent, false)
    override fun handleData(position: Int, binding: AdapterQxgdSearchAddressBinding) {
        val item: QxgdAddressBean.DataBean = data[position]
        binding.tvMc.text = item.description

        binding.tvWzbm.text = item.wzbm
        binding.tvSbbm.text = item.sbbm
        binding.btnMjApply.setOnClickListener {
            btnClickListener.onClick(position)
        }
    }
}