package com.wasu.cs.adapter;

import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import com.wasu.cs.model.Model;

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

/**
 * Created by LiuYang on 7/3/15.
 */
public abstract class BlockPageAdapter extends FragmentStatePagerAdapter {

    private List<Model> mData = new ArrayList<Model>();
	/*哪一个tab被选中*/
	private int tabSelected = 0;

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

    public void setData(List<? extends Model> data) {
        this.mData.clear();
        this.mData.addAll(data);
    }

    public void clearData(){
    	this.mData.clear();
    }
    
    public Model getItemData(int position) {
        Model res = null;

        if(position < mData.size()) {
            res = mData.get(position);
        }

        return res;
    }

    @Override
    public int getCount() {
        return mData.size();
    }
    public void setTabSelected(int position){
    	this.tabSelected = position;
    }
    
    public int getTabSelected(){
    	return tabSelected;
    }
}
