package com.bassbooster.soundeffects.equalizer.adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.viewpager.widget.PagerAdapter
import com.bassbooster.equalizer.R
import com.bassbooster.soundeffects.equalizer.data.model.Tutorial

class TutorialSplashAdapter(private val itemList: ArrayList<Tutorial>) : PagerAdapter() {

    override fun instantiateItem(container: ViewGroup, position: Int): Any {
        val view = LayoutInflater.from(container.context).inflate(
            R.layout.item_viewpager_splash,
            container,
            false
        )
        view.findViewById<ImageView>(R.id.imgSplash).setImageResource(itemList[position].imgTutorial)
        view.findViewById<TextView>(R.id.tvTitleSplash).text = itemList[position].tvTitle

        container.addView(view)
        return view
    }

    override fun getCount(): Int {
        return itemList.size
    }

    override fun isViewFromObject(view: View, `object`: Any): Boolean {
        return view == `object`
    }

    override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) {
        container.removeView(`object` as View?)
    }
}