package com.zhaohaoting.framework.abs.adapter;

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

import com.zhaohaoting.framework.abs.AbsV4Fragment;
import com.zhaohaoting.framework.abs.entity.Tag;

import java.util.List;

/**
 * author：Created by zhaohaoting on 2018/1/10 11:51
 * email：526309416@qq.com
 * desc：
 */
public class TabAdapter extends FragmentPagerAdapter {
    private List<? extends AbsV4Fragment> mFragments;
    private List<? extends Tag> tabNames;

    public TabAdapter(FragmentManager fm, List<? extends AbsV4Fragment> mFragments, List<? extends Tag> tabNames) {
        super(fm);
        this.mFragments = mFragments;
        this.tabNames = tabNames;
    }

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

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

    @Override
    public CharSequence getPageTitle(int position) {
        return tabNames.get(position).getName();
    }

}
