package com.zxbw.modulemain.adapter

import android.app.Activity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.zxbw.modulemain.R
import com.zxhl.cms.AppContext
import com.zxhl.cms.common.base.BaseRecyclerAdapter
import com.zxhl.cms.net.model.qy.SkillEntity
import com.zxhl.cms.utils.OnRecycleItemClickListener

class TimeAdapter : BaseRecyclerAdapter<SkillEntity, TimeAdapter.ViewHolder> {
    private var mContext: Activity? = null
    private val listener: OnRecycleItemClickListener<SkillEntity>

    constructor(
        content: Activity?,
        listener: OnRecycleItemClickListener<SkillEntity>
    ) : super() {
        mContext = content
        this.listener = listener
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
       var bean = mList[position]
        holder.id_ll_item?.setOnClickListener {
            listener.onItemClick(it, position, bean)
        }
        holder.id_tv_time?.text="${bean.startTime}"
        holder.id_tv_status_desc?.text="${bean.statusDesc}"
    }
    override fun getItemCount(): Int {
        val size = mList.size
        if (size > 4) {
            return 4
        } else {
            return size
        }
    }

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

    class ViewHolder : RecyclerView.ViewHolder {
        var id_ll_item: LinearLayout?
        var id_tv_status_desc: TextView?
        var id_tv_time: TextView?


        constructor(
            itemView: View
        ) : super(itemView) {
            id_ll_item =
                itemView.findViewById<LinearLayout>(R.id.id_ll_item)
            id_tv_time = itemView.findViewById<TextView>(R.id.id_tv_time)
            id_tv_status_desc = itemView.findViewById<TextView>(R.id.id_tv_status_desc)
        }
    }
}