package com.oo.eye.adapter;

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

import com.oo.eye.R;
import com.oo.eye.bean.PopuBean;

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

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

public class PopuAdapter extends BaseAdapter {
    private Context mContext;
    private List<PopuBean> mBeanList = new ArrayList<>();

    public PopuAdapter(Context context, List<PopuBean> beans) {
        mContext = context;
        if (beans != null) {
            mBeanList = beans;
        }
    }

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

    @Override
    public Object getItem(int position) {
        return null;
    }

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

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater inflater = LayoutInflater.from(mContext);
        View view = inflater.inflate(R.layout.item_popu_more, null);
        final TextView textView = (TextView) view.findViewById(R.id.name_tv);
        ImageView imageView = (ImageView) view.findViewById(R.id.choice_tv);
        PopuBean bean = mBeanList.get(position);
        if (bean.isChick()) {
            imageView.setVisibility(View.VISIBLE);
            imageView.setImageResource(R.drawable.selectitem);
        } else {
            imageView.setVisibility(View.INVISIBLE);
        }
        textView.setText(bean.getName());
        return view;
    }
    public List<PopuBean> getBeanList(){
        return mBeanList;
    }
}
