package com.zxbw.modulemain.adapter

import android.app.Activity
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
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.qy.RightsDetailEntity
import com.zxhl.cms.widget.RecycleImageView


class ItemVipOrderAdapter :
    BaseRecyclerAdapter<RightsDetailEntity, ItemVipOrderAdapter.ViewHolder> {
    private var mContext: Activity? = null

    constructor(
        content: Activity?
    ) : super() {
        mContext = content
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        var bean = mList[position]
        if (mContext?.isDestroyed != true){
            Glide.with(mContext!!).load(bean.bgImage).placeholder(R.drawable.img_vip_rights_bg)
                .into(holder?.id_img_rights_bg!!)
        }
        holder.id_img_rights_icon?.setLoadImageUrl(bean.icon, false)
        holder.id_tv_vip_goods_name?.text = "${bean.brand} ${bean.category} ${bean.goodsName}"
        holder.id_tv_vip_goods_price?.text = "¥${bean.salePrice}"
//        holder.id_tv_vip_goods_num?.text = "${bean.salePrice}"
    }


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

    class ViewHolder : RecyclerView.ViewHolder {
        var id_img_rights_bg: ImageView?
        var id_img_rights_icon: RecycleImageView?
        var id_tv_vip_goods_name: TextView?
        var id_tv_vip_goods_price: TextView?
        var id_tv_vip_goods_num: TextView?

        constructor(
            itemView: View
        ) : super(itemView) {
            id_img_rights_bg = itemView.findViewById<ImageView>(R.id.id_img_rights_bg)
            id_img_rights_icon = itemView.findViewById<RecycleImageView>(R.id.id_img_rights_icon)
            id_tv_vip_goods_name = itemView.findViewById<TextView>(R.id.id_tv_vip_goods_name)
            id_tv_vip_goods_price = itemView.findViewById<TextView>(R.id.id_tv_vip_goods_price)
            id_tv_vip_goods_num = itemView.findViewById<TextView>(R.id.id_tv_vip_goods_num)
        }
    }

}