package com.dahe.gldriver.adapter

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.viewpager2.adapter.FragmentStateAdapter


/**
 * @ClassName PagersAdapter
 * @Author john
 * @Date 2024/2/7 10:26
 * @Description TODO
 */
class PagersAdapter(fragmentActivity: FragmentActivity,list:MutableList<Fragment>) : FragmentStateAdapter(fragmentActivity) {
    private var fragmentList : MutableList<Fragment> =ArrayList()
    init {
        this.fragmentList = list
    }

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

    override fun createFragment(position: Int): Fragment {
        return  fragmentList[position]
    }

    fun addFragment(fragment: Fragment){
        fragmentList.add(fragment)
    }
}