package com.kfzs.duanduan.adp;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.kfzs.duanduan.bean.VipStyle;

import java.util.ArrayList;
import java.util.List;

/**
 * @ Created by Dlg
 * @ <p>TiTle:  AdpViewPagerMainPage</p>
 * @ <p>Description: 首页的ViewPager监听</p>
 * @ date:  2017/6/14 13:21
 * @ QQ:    315096953
 */

public class AdpViewPagerDetail extends FragmentPagerAdapter {

    private List<String> mTitles = new ArrayList<>();
    private List<Fragment> mListFragment = new ArrayList<>();

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

    public void add(Fragment fragment, String title) {
        mListFragment.add(fragment);
        mTitles.add(title);
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return position == 1 ? VipStyle.getInstance().getViptypename() + mTitles.get(position) : mTitles.get(position);
    }

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

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


}
