package com.tanya.careerguidanceproject

import android.content.Context
//import android.content.Intent
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import java.util.ArrayList

class UserRVAdapter (// variable for our array list and context
    private val userModalArrayList: ArrayList<UserModal>, private val context: Context
) :
    RecyclerView.Adapter<UserRVAdapter.ViewHolder>() {
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        // on below line we are inflating our layout
        // file for our recycler view items.
        val view =
            LayoutInflater.from(parent.context).inflate(R.layout.user_rv_item, parent, false)
        return ViewHolder(view)
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        // on below line we are setting data
        // to our views of recycler view item.
        val modal = userModalArrayList[position]
        holder.userName.text = modal.UserName
        holder.userEmailId.text = modal.UserEmailId
        holder.userMobNo.text = modal.UserMobileNumber
        holder.userPassword.text = modal.UserPassword

        // below line is to add on click listener for our recycler view item.
        // below line is to add on click listener for our recycler view item.

    }

    override fun getItemCount(): Int {
        // returning the size of our array list
        return userModalArrayList.size
    }

    inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        // creating variables for our text views.
        val userName: TextView = itemView.findViewById(R.id.UserName)
        val userEmailId: TextView = itemView.findViewById(R.id.UserEmailId)
        val userMobNo: TextView = itemView.findViewById(R.id.UserMobNo)
        val userPassword: TextView = itemView.findViewById(R.id.UserPasword)

    }
}
