package com.duben.microtribe.ui.adapter

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

/**
 *  @author Assen
 *  @date 2023/4/11
 *  @desc
 */
class RecommendPageAdapter(private val fragments: List<Fragment>, fragment: Fragment) :
    FragmentStateAdapter(fragment) {

    private val fid1 = 111L
    private val fid2 = 222L

    private val ids = arrayListOf(fid1, fid2)
    private val createID = hashSetOf<Long>()

    override fun getItemId(position: Int): Long {
        return position.toLong()
    }

    override fun getItemCount() = fragments.size

    override fun createFragment(position: Int): Fragment {
        val id = ids[position]
        createID.add(id)
        return fragments[position]
    }

    override fun containsItem(itemId: Long): Boolean {
        return createID.contains(itemId)
    }

}