package com.xyzshell.myphoneinfo.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.xyzshell.myphoneinfo.databinding.ItemCommonTempBinding
import com.xyzshell.myphoneinfo.databinding.ItemListBinding
import com.xyzshell.myphoneinfo.dialog.TempDialogFragment

class TempAdapter: RecyclerView.Adapter<TempAdapter.ListViewHolder>() {
    private lateinit var context: Context
    private lateinit var listener: OnTempClickListener
    override fun onCreateViewHolder(
        parent: ViewGroup,
        viewType: Int
    ): ListViewHolder {
        context = parent.context
        val binding= ItemCommonTempBinding.inflate(LayoutInflater.from(context), parent, false)
        return ListViewHolder(binding)
    }

    override fun onBindViewHolder(
        holder: ListViewHolder,
        position: Int
    ) {
        holder.binding.view.setOnClickListener {
            listener.onTempClick(position)
        }
    }

    override fun getItemCount(): Int {
        return 3
    }
    fun setListener(listener: OnTempClickListener){
        this.listener = listener
    }

    class ListViewHolder(val binding: ItemCommonTempBinding): RecyclerView.ViewHolder(binding.root)
}
interface OnTempClickListener {
    fun onTempClick(position: Int)
}