package com.cooleshow.teacher.adapter;

import java.util.ArrayList;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;

/**
 * Author by pq, Date on 2022/4/20.
 */
public class HomePageAdapter extends FragmentStateAdapter {
    private ArrayList<Fragment> mFragments;

    public void setFragments(ArrayList<Fragment> fragments) {
        this.mFragments = fragments;
    }

    public HomePageAdapter(@NonNull FragmentActivity fragmentActivity) {
        super(fragmentActivity);
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        Fragment fragment = mFragments.get(position);
        return fragment;
    }

    @Override
    public int getItemCount() {
        return mFragments != null ? mFragments.size() : 0;
    }
}
