package com.wasu.cs.adapter;

import android.widget.BaseAdapter;

import com.wasu.cs.model.Model;

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

/**
 * Created by LiuYang on 7/8/15.
 */
public abstract class GridExAdapterBase extends BaseAdapter {

    private List<Model> mData = new ArrayList<Model>();

    public void setData(List<? extends Model> data) {
        this.mData.clear();
        this.mData.addAll(data);
    }
    public Model getItemData(int position) {
        Model res = null;

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

        return res;
    }
    
    public void clearData(){
    	mData.clear();
    }
    
    @Override
    public int getCount() {
        return mData.size();
    }

    @Override
    public Model getItem(int i) {
        Model res = null;
        if(i < mData.size()) {
            res = mData.get(i);
        }
        return res;
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

}
