package com.unis.sxzcl.widget;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.viewpager.widget.PagerAdapter;

import java.util.List;

/**
 * 包名: com.bskapp.bskapp.widget
 * 类名: MyTabFragmentStatePagerAdapter
 * 作用描述:
 * 创建人: mQ
 * 创建时间: 2020/7/19 14:30
 * 更新人:
 * 更新时间: 2020/7/19 14:30
 * 更新说明:
 * 版本号: 1.0
 */
public class TabFragmentPagerAdapter extends FragmentStatePagerAdapter {

    List<Fragment> mFragments;
    List<String> tabs;

    public TabFragmentPagerAdapter(FragmentManager fm, List<String> tabs, List<Fragment> fragments) {
        super(fm);
        this.tabs = tabs;
        mFragments = fragments;
        notifyDataSetChanged();
    }

    @Override
    public Fragment getItem(int i) {
        return mFragments.get(i);
    }

    @Override
    public int getItemPosition(@NonNull Object object) {
        return PagerAdapter.POSITION_NONE;
    }

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

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return tabs.get(position);
    }

}