package com.casic.br.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.casic.br.R

class SolutionAdapter(
    val context: Context, private val dataRows: MutableList<String>
) : RecyclerView.Adapter<SolutionAdapter.ItemViewHolder>() {

    private var layoutInflater: LayoutInflater = LayoutInflater.from(context)

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder {
        return ItemViewHolder(
            layoutInflater.inflate(R.layout.item_solution_rv_l, parent, false)
        )
    }

    override fun onBindViewHolder(holder: ItemViewHolder, position: Int) {
        holder.solutionView.text = dataRows[position]
    }

    override fun getItemCount(): Int = dataRows.size

    class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        val solutionView: TextView = itemView.findViewById(R.id.solutionView)
    }
}