package com.gh.gamecenter.gamedetail.fuli.kaifu

import android.content.Context
import android.view.ViewGroup
import com.gh.gamecenter.R
import com.gh.gamecenter.common.base.BaseRecyclerViewHolder
import com.gh.gamecenter.databinding.ItemServersCalendarRemindTimeSettingBinding
import com.lightgame.adapter.BaseRecyclerAdapter

class ServersCalendarRemindTimeSettingAdapter(
    context: Context,
    private val itemCallback: (ServersCalendarAdvancedTime) -> Unit
) : BaseRecyclerAdapter<ServersCalendarRemindTimeSettingAdapter.ServersCalendarRemindTimeSettingViewHolder>(context) {

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ServersCalendarRemindTimeSettingViewHolder {
        val view = mLayoutInflater.inflate(R.layout.item_servers_calendar_remind_time_setting, parent, false)
        return ServersCalendarRemindTimeSettingViewHolder(ItemServersCalendarRemindTimeSettingBinding.bind(view))
    }

    override fun getItemCount(): Int = ServersCalendarAdvancedTime.values().size

    override fun onBindViewHolder(holder: ServersCalendarRemindTimeSettingViewHolder, position: Int) {
        val data = ServersCalendarAdvancedTime.values()[position]
        holder.binding.nameTv.text = data.text
        holder.binding.root.setOnClickListener {
            itemCallback.invoke(data)
        }
    }

    class ServersCalendarRemindTimeSettingViewHolder(val binding: ItemServersCalendarRemindTimeSettingBinding) :
        BaseRecyclerViewHolder<Any>(binding.root)
}