package com.zxhl.main.page.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.zxhl.cms.AppContext
import com.zxhl.cms.common.base.BaseRecyclerAdapter
import com.zxhl.cms.net.model.box.GoodList
import com.zxhl.cms.widget.RecycleImageView
import com.zxhl.main.R

class OrderAdapter : BaseRecyclerAdapter<GoodList, OrderAdapter.ViewHolder> {
    private var mContext: Context? = null

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

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        var bean = mList[position]
        holder?.item_order_img?.setLoadImageUrl(bean.mainImage, false)
        holder?.item_order_name?.text = bean.productName
        holder?.item_order_num?.text = "x ${bean.amount}"
        holder?.id_tv_sale_price?.text="¥ ${bean.salePriceStr}"
    }


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

    class ViewHolder : RecyclerView.ViewHolder {
        var item_order_img: RecycleImageView?
        var item_order_name: TextView?
        var item_order_num: TextView?
        var id_tv_sale_price: TextView?

        constructor(
            itemView: View
        ) : super(itemView) {
            item_order_img = itemView.findViewById<RecycleImageView>(R.id.id_img_order_goods)
            item_order_name = itemView.findViewById<TextView>(R.id.id_tv_order_name)
            item_order_num = itemView.findViewById<TextView>(R.id.id_tv_num)
            id_tv_sale_price = itemView.findViewById<TextView>(R.id.id_tv_sale_price)

        }
    }


}