package com.zxbw.modulemain.adapter

import android.app.Activity
import android.content.Context
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.RelativeLayout
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.zxbw.modulemain.R
import com.zxhl.cms.AppContext
import com.zxhl.cms.common.base.BaseRecyclerAdapter
import com.zxhl.cms.net.model.box.AddressEntity
import com.zxhl.cms.net.model.box.LotteryEntity
import com.zxhl.cms.utils.OnRecycleItemClickListener
import com.zxhl.cms.widget.RecycleImageView


class GoodsListAdapter : BaseRecyclerAdapter<Any, GoodsListAdapter.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_rl_goods_item_view?.setOnClickListener {
            listener.onItemClick(it, position, null)
        }
    }

    override fun getItemCount(): Int {
        return 23
    }

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

    class ViewHolder : RecyclerView.ViewHolder {
        var id_rl_goods_item_view: RelativeLayout?
        var id_item_goods_img: RecycleImageView?
        var id_tv_goods_name: TextView?
        var id_tv_yhq_value: TextView?
        var id_tv_manjian_value: TextView?
        var id_tv_tb_price_value: TextView?
        var id_tv_goods_price: TextView?

        constructor(
            itemView: View
        ) : super(itemView) {
            id_rl_goods_item_view =
                itemView.findViewById<RelativeLayout>(R.id.id_rl_goods_item_view)
            id_item_goods_img = itemView.findViewById<RecycleImageView>(R.id.id_item_goods_img)
            id_tv_goods_name = itemView.findViewById<TextView>(R.id.id_tv_goods_name)
            id_tv_yhq_value = itemView.findViewById<TextView>(R.id.id_tv_yhq_value)
            id_tv_manjian_value = itemView.findViewById<TextView>(R.id.id_tv_manjian_value)
            id_tv_tb_price_value = itemView.findViewById<TextView>(R.id.id_tv_tb_price_value)
            id_tv_goods_price = itemView.findViewById<TextView>(R.id.id_tv_goods_price)


        }
    }
}