package com.zj365.health.adapter

import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.xty.base.adapter.BaseAdapter
import com.zj365.health.R

class SleepAdapter(var allInt: Int=0):BaseAdapter<Int>(R.layout.item_sleep) {
    var recycle:RecyclerView?=null
    override fun onAttachedToRecyclerView(recyclerView: RecyclerView) {
        super.onAttachedToRecyclerView(recyclerView)
        recycle=recyclerView
    }
    override fun convert(holder: BaseViewHolder, item: Int) {
        if(allInt==0){
            return
        }
        recycle?.let {
            var width= item/allInt.toFloat()*it.width
            var parme=holder.itemView.layoutParams as ViewGroup.LayoutParams
            parme.width=width.toInt()
            if((holder.layoutPosition)%2==0){
                holder.itemView.setBackgroundResource(R.color.col_009)
                parme.height=it.height
            }else{
                holder.itemView.setBackgroundResource(R.color.col_e03)
                parme.height=it.height-40
            }



            holder.itemView.layoutParams=parme
        }






    }
}