package com.lukouguoji.gnj.adapt

import android.app.Activity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.EditText
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.lukouguoji.gnj.R
import com.lukouguoji.gnj.model.GnjWareHouseInfo

/**
 * 出港查询详情
 */
class GnjWareHouseInfoListAdapter(val activity: Activity, val collectList: MutableList<GnjWareHouseInfo>) :
    RecyclerView.Adapter<GnjWareHouseInfoListAdapter.ViewHolder>() {

    inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
        val title: TextView = view.findViewById(R.id.title)
        val content: EditText = view.findViewById(R.id.content)
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        val view = LayoutInflater.from(parent.context).inflate(R.layout.gnj_ware_house_info_item, parent, false)
        val viewHolder = ViewHolder(view)

        /* viewHolder.itemView.setOnClickListener {

             var adapterPosition = viewHolder.adapterPosition
             var gncFuBang = collectList[adapterPosition]

             ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_GOUT_FU_BANG_ACTIVITY).withString("userIdParam", gncFuBang.useId.toString())
                 .navigation(activity, Constant.RequestCode.gnc_shouyun_list_refresh)

         }
 */
        return viewHolder
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        val collect = collectList[position]
        holder.title.text = collect.title
        holder.content.setText(collect.content)
    }

    override fun getItemCount() = collectList.size

    fun append(gnjWareHouseInfo: GnjWareHouseInfo) {
        collectList.add(gnjWareHouseInfo)
        notifyDataSetChanged()
    }
}