package com.oo.eye.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.app.baselibrary.recycler.adapter.BaseRecyclerViewAdapter;
import com.app.baselibrary.recycler.itemholder.ItemViewHolder;
import com.oo.eye.R;
import com.oo.eye.bean.ChartsBean;
import com.oo.eye.bean.StudentBean;

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

/**
 * Date : 2018/8/28.
 * Author:  cxh
 */

public class MorePeopleAdapter extends BaseRecyclerViewAdapter<StudentBean, ItemViewHolder> {
    private final LayoutInflater mInflater;
    private List<StudentBean> mBeanList = new ArrayList<>();

    public MorePeopleAdapter(List<StudentBean> list, Context context) {
        super(list, context);
        if (list != null) {
            mBeanList = list;
        }
        mInflater = LayoutInflater.from(mContext);
    }

    @Override
    public ItemViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new ItemViewHolder(mInflater.inflate(R.layout.item_people, parent, false));
    }

    @Override
    public void onBindViewHolder(ItemViewHolder holder, final int position) {
        final StudentBean studentBean = mBeanList.get(position);
        ImageView imageView = (ImageView) holder.itemView.findViewById(R.id.chick_iv);
        imageView.setImageResource(studentBean.isChick() ? R.drawable.select2_sel : R.drawable.select2_nor);
        holder.itemView.findViewById(R.id.choice_lay).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                studentBean.setChick(!studentBean.isChick());
                notifyDataSetChanged();
            }
        });
    }


    @Override
    public int getItemCount() {
        return 10;
    }
}
