package com.cooleshow.teacher.adapter;

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

import java.util.List;

/**
 * 创建日期：2022/5/23 10:53
 *
 * @author Ryan
 * 类说明：
 */
public class HomeWorkPagerAdapter extends FragmentPagerAdapter {

    private List<String> titles;

    private List<Fragment> fragments;

    public HomeWorkPagerAdapter(FragmentManager fm, List<Fragment> fragments, List<String> titles) {
        super(fm);
        this.titles = titles;
        this.fragments = fragments;
    }

    @Override
    public Fragment getItem(int position) {
        return fragments != null && fragments.size() > position ? fragments.get(position) : null;
    }

    @Override
    public int getCount() {
        return fragments == null ? 0 : fragments.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles != null && titles.size() > position ? titles.get(position) : "";
    }
}
