package com.zxbw.modulemain.adapter

import android.app.Activity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.RelativeLayout
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.zxbw.modulemain.R
import com.zxhl.cms.AppContext
import com.zxhl.cms.common.base.BaseRecyclerAdapter
import com.zxhl.cms.utils.OnRecycleItemClickListener
import com.zxhl.cms.widget.RecycleImageView


class ZeroBuyGoodsListAdapter : BaseRecyclerAdapter<Any, ZeroBuyGoodsListAdapter.ViewHolder> {
    private var mContext: Activity? = null
    private val listener: OnRecycleItemClickListener<Any>

    constructor(
        content: Activity?,
        listener: OnRecycleItemClickListener<Any>
    ) : super() {
        mContext = content
        this.listener = listener
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {

        holder.id_ll_zero_buy_goods_item_view?.setOnClickListener {
            listener.onItemClick(it, position, null)
        }
    }

    override fun getItemCount(): Int {
        return 3
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        return ViewHolder(
            LayoutInflater.from(AppContext.get())
                .inflate(R.layout.item_layout_zero_buy_goods_view, parent, false)
        )
    }

    class ViewHolder : RecyclerView.ViewHolder {
        var id_ll_zero_buy_goods_item_view: LinearLayout?
        var id_item_zero_buy_goods_img: RecycleImageView?
        var id_tv_zero_buy_goods_name: TextView?
        var id_tv_zero_buy_goods_price: TextView?
        var id_tv_zero_buy_goods_old_price: TextView?

        constructor(
            itemView: View
        ) : super(itemView) {
            id_ll_zero_buy_goods_item_view =
                itemView.findViewById<LinearLayout>(R.id.id_ll_zero_buy_goods_item_view)
            id_item_zero_buy_goods_img = itemView.findViewById<RecycleImageView>(R.id.id_item_zero_buy_goods_img)
            id_tv_zero_buy_goods_name = itemView.findViewById<TextView>(R.id.id_tv_zero_buy_goods_name)
            id_tv_zero_buy_goods_price = itemView.findViewById<TextView>(R.id.id_tv_zero_buy_goods_price)
            id_tv_zero_buy_goods_old_price = itemView.findViewById<TextView>(R.id.id_tv_zero_buy_goods_old_price)
        }
    }
}