package com.tanya.careerguidanceproject.activities

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.tanya.careerguidanceproject.R
import com.tanya.careerguidanceproject.model.Course

class CourseRecyclerAdapter(val context : Context, private val courseInfoList : ArrayList<Course>) : RecyclerView.Adapter<CourseRecyclerAdapter.DashboardViewHolder> (){
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): DashboardViewHolder {
        val view = LayoutInflater.from(parent.context).inflate(R.layout.course_rv_item, parent, false)

        return DashboardViewHolder(view)
    }

    override fun getItemCount(): Int {
        return courseInfoList.size
    }

    override fun onBindViewHolder(holder: DashboardViewHolder, position: Int) {
        val modal = courseInfoList[position]
        holder.courseName.text = modal.courseName
        holder.courseDuration.text = modal.courseDuration
        holder.courseStream.text = modal.courseStream
        holder.courseDesc.text = modal.courseDescription

    }
    class DashboardViewHolder(view: View) : RecyclerView.ViewHolder(view){
        val courseName : TextView = view.findViewById(R.id.txtCourseName)
        val courseDuration : TextView = view.findViewById(R.id.txtCourseDuration)
        val courseStream : TextView = view.findViewById(R.id.txtCourseStream)
        val courseDesc : TextView = view.findViewById(R.id.txtCourseDescription)

    }
}