package com.qhclh.ytzh.work.scan;

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

import com.qhclh.ytzh.R;
import com.qhclh.ytzh.bean.BreedBean;

import java.util.List;

/**
 * Created by 青花瓷 on 2018/1/23.
 */

public class BreedAdapter extends BaseAdapter {
    private Context context;
    private List<BreedBean> list;
    private LayoutInflater layoutInflater;

    public BreedAdapter(Context context, List<BreedBean> list) {
        this.context = context;
        this.list = list;
        layoutInflater = LayoutInflater.from(context);
    }

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

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return list.get(i).getId();
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder viewHolder;
        BreedBean message = list.get(i);

        if (view == null){
            view = layoutInflater.inflate(R.layout.item_breed,viewGroup,false);
            viewHolder = new ViewHolder();

            viewHolder.item_breed_name = view.findViewById(R.id.item_breed_name);
            view.setTag(viewHolder);
        }else {
            viewHolder = (ViewHolder) view.getTag();
        }

        viewHolder.item_breed_name.setText(message.getName());
        return view;
    }

    private class ViewHolder{
        private TextView item_breed_name;

    }
}
