package com.ym.game.adapter

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.ym.ddhy.R
import com.ym.library.base.BaseRecyclerAdapter
import com.ym.library.module.FlyBoxEntity
import com.ym.modulecommon.AppliContext

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

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

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        var bean = mList[position]
        when (bean.type) {
            //加速剂
            1 -> {
                holder.item_img?.setBackgroundResource(R.mipmap.icon_speed_water)
            }
            //种子
            2 -> {
                when (bean.id) {
                    1 -> {
                        holder.item_img?.setImageResource(R.mipmap.icon_zhongzi_one)
                    }
                    2 -> {
                        holder.item_img?.setImageResource(R.mipmap.icon_zhongzi_two)
                    }
                    3 -> {
                        holder.item_img?.setImageResource(R.mipmap.icon_zhongzi_three)
                    }
                    4 -> {
                        holder.item_img?.setImageResource(R.mipmap.icon_zhongzi_four)
                    }
                    5 -> {
                        holder.item_img?.setImageResource(R.mipmap.icon_zhongzi_five)
                    }
                    6 -> {
                        holder.item_img?.setImageResource(R.mipmap.icon_zhongzi_six)
                    }
                    7 -> {
                        holder.item_img?.setImageResource(R.mipmap.icon_zhongzi_seven)
                    }
                    8 -> {
                        holder.item_img?.setImageResource(R.mipmap.icon_zhongzi_eight)
                    }
                    9 -> {
                        holder.item_img?.setImageResource(R.mipmap.icon_zhongzi_eight)
                    }
                }
            }
            //果实
            3 -> {
                when (bean.id) {
                    1 -> {
                        holder.item_img?.setImageResource(R.mipmap.icon_flower_one)
                    }
                    2 -> {
                        holder.item_img?.setImageResource(R.mipmap.icon_flower_two)
                    }
                    3 -> {
                        holder.item_img?.setImageResource(R.mipmap.icon_flower_three)
                    }
                    4 -> {
                        holder.item_img?.setImageResource(R.mipmap.icon_flower_four)
                    }
                    5 -> {
                        holder.item_img?.setImageResource(R.mipmap.icon_flower_five)
                    }
                    6 -> {
                        holder.item_img?.setImageResource(R.mipmap.icon_flower_six)
                    }
                    7 -> {
                        holder.item_img?.setImageResource(R.mipmap.icon_flower_seven)
                    }
                    8 -> {
                        holder.item_img?.setImageResource(R.mipmap.icon_flower_eight)
                    }
                    9 -> {
                        holder.item_img?.setImageResource(R.mipmap.icon_flower_eight)
                    }

                }
            }
        }
        holder.item_ownnum?.text = bean.ownNum.toString()

    }


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

    class ViewHolder : RecyclerView.ViewHolder {
        var item_img: ImageView?
        var item_ownnum: TextView?

        constructor(
            itemView: View
        ) : super(itemView) {
            item_img = itemView.findViewById<ImageView>(R.id.id_img_item)
            item_ownnum = itemView.findViewById<TextView>(R.id.id_tv_ownnum)
        }
    }

}