package com.casic.dcms.adapter;

import android.view.ViewGroup;

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

import java.util.List;

public class MainPageAdapter extends FragmentPagerAdapter {

    private final List<Fragment> fragmentList;

    public MainPageAdapter(@NonNull FragmentManager fm, List<Fragment> pages) {
        super(fm);
        this.fragmentList = pages;
    }

    @NonNull
    @Override
    public Fragment getItem(int position) {
        return fragmentList.get(position);
    }

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

    @Override
    public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
        //注释掉父类方法，一直不销毁Fragment
    }
}
