package com.wasu.cs.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.wasu.cs.model.HomeVipModel.DataEntity.BannerEntity.MiddleEntity.ListEntity;
import com.wasu.frescoimagefetchermodule.FrescoImageFetcherModule;

import java.util.List;

import cn.com.wasu.main.R;

/**
 * Created by Danxx on 2016/7/1.
 */
public class HomeVipViewFlowAdapter extends BaseAdapter {
    private List<ListEntity> mData;
    private LayoutInflater mInflater;

    public HomeVipViewFlowAdapter(Context context , List<ListEntity> data) {
        mData = data;
        mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    @Override
    public int getCount() {
        return Integer.MAX_VALUE;
    }
    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }
    public ListEntity getItemData(int position){

        return mData.get(position);
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.item_image_layout, null);
        }
        String imgUrl  = mData.get(position%mData.size()).getPicUrl();
        ImageView image = (ImageView) convertView
                .findViewById(R.id.ivPic);
        FrescoImageFetcherModule.getInstance().attachImage(imgUrl ,image);
        return convertView;
    }

}
