package com.sheep.gamegroup.view.adapter;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

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

/**
 * 试玩赚钱
 * Created by ljy on 2018/4/26.
 */

public class AdpTryMakemoney extends FragmentStatePagerAdapter {
    private Context mContext;
    private List<Object> mListFragment = new ArrayList<>();
    private List<Object> mTitles = new ArrayList<>();
    public AdpTryMakemoney(FragmentManager fm, Context mContext) {
        super(fm);
        this.mContext = mContext;
    }
    public void add(Fragment fragment, String title) {
        mListFragment.add(fragment);
        mTitles.add(title);
    }

    public void cleanListFragment(){
        mListFragment.clear();
        mTitles.clear();
    }

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

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

    @Override
    public int getItemPosition(Object object) {
        return POSITION_NONE;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return (CharSequence) mTitles.get(position);
    }
//    public void setFragments(ArrayList<Fragment> fragments) {
//        if(this.mFragments != null){
//            FragmentTransaction ft = fm.beginTransaction();
//            for(Fragment f:this.mFragments){
//                ft.remove(f);
//            }
//            ft.commit();
//            ft=null;
//            fm.executePendingTransactions();
//        }
//        this.mFragments = fragments;
//        notifyDataSetChanged();
//    }
}
