package com.fxy.main.adapter;

import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import com.fxy.baselibrary.base.BaseFragment;
import com.fxy.main.MainActivity;

import java.util.List;

/**
 * 项目名称：FingerShipWork
 * 类描述：
 * 创建人：ww
 * 创建时间：2018/3/19 09:54
 * 修改人：COMP-021-2002
 * 修改时间：2017/8/28 17:55
 * 修改备注：
 */

public class MainViewPagerAdapter extends FragmentStatePagerAdapter {

    public List<BaseFragment> mFragments;

    public MainViewPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    public MainViewPagerAdapter(FragmentManager fm,List<BaseFragment> mFragments) {
        super(fm);
        this.mFragments = mFragments;
    }

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

    @Override
    public int getCount() {
//        return mFragments == null ? 0 : mFragments.size();
        return MainActivity.ITEMPAGER;
    }

    public void setmFragments(List<BaseFragment> mFragments) {
        this.mFragments = mFragments;
        notifyDataSetChanged();
    }

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

}
