package com.casic.dcms.adapter;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import org.jetbrains.annotations.NotNull;

import java.util.List;

/**
 * @author : Pengxh
 * @time : 2021/4/16 9:37
 * @email : 290677893@qq.com
 **/
public class SubViewPagerAdapter extends FragmentPagerAdapter {

    private final String[] titles;
    private final List<Fragment> list;

    public SubViewPagerAdapter(FragmentManager fm, String[] pageTitles, List<Fragment> fragmentList) {
        super(fm);
        this.titles = pageTitles;
        this.list = fragmentList;
    }

    @NotNull
    @Override
    public Fragment getItem(int position) {
        return list.get(position);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles[position];
    }
}