package com.gamedog.vididin.widget.loopViewpager

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

class LoopPagerAdapter<T>(
    private val activity: FragmentActivity,
    private val dataList: List<T>,
    private val fragmentCreatorFun: (List<T>, Int) -> Fragment
) : FragmentStateAdapter(activity) {

    private val mRealPageCount = 3

    override fun getItemCount(): Int = Int.MAX_VALUE

    override fun createFragment(position: Int): Fragment {
        val realPosition = position % mRealPageCount
        return fragmentCreatorFun(dataList, realPosition)
    }

}