package com.qhclh.ytzh.index.fumudai;

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 android.widget.TextView;

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

import java.util.List;

/**
 * Created by 青花瓷 on 2017/12/25.
 */

public class FumudaiAdapter extends RecyclerView.Adapter<FumudaiAdapter.MyViewHolder>{
    private Context mContext;
    private List<FumudaiBean> mList;

    public FumudaiAdapter(Context mContext, List<FumudaiBean> mList) {
        this.mContext = mContext;
        this.mList = mList;
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.item_fumudai,parent,false);
        return new MyViewHolder(view);
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {
        FumudaiBean fumudaiBean = mList.get(position);
        MyViewHolder myViewHolder = holder;
        myViewHolder.getItem_fumudai_iv().setImageResource(fumudaiBean.getImage());
        myViewHolder.getItem_fumudai_tv().setText(fumudaiBean.getTitle());
    }

    @Override
    public int getItemCount() {
        return mList.size();
    }

    @Override
    public long getItemId(int position) {
        return mList.get(position).getId();
    }

    static class MyViewHolder extends RecyclerView.ViewHolder{
        private ImageView item_fumudai_iv;
        private TextView item_fumudai_tv;

        public MyViewHolder(View itemView) {
            super(itemView);
            item_fumudai_iv = itemView.findViewById(R.id.item_fumudai_iv);
            item_fumudai_tv = itemView.findViewById(R.id.item_fumudai_tv);
        }

        public ImageView getItem_fumudai_iv() {
            return item_fumudai_iv;
        }

        public TextView getItem_fumudai_tv() {
            return item_fumudai_tv;
        }
    }
}
