package com.sipai.jspatrol.Patrol;

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

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.sipai.jspatrol.Bean.EquList;
import com.sipai.jspatrol.R;

import java.util.List;

/**
 * created by lvliming on 2019/8/5
 */
public class PatrolEquAdapter extends RecyclerView.Adapter<PatrolEquAdapter.ViewHolder> {
    private List<EquList> list;
    private Context context;

    public PatrolEquAdapter(List<EquList> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_patrol_equ ,parent,false);
        ViewHolder holder = new ViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        EquList item = list.get(position);
        holder.tv_name.setText(item.getEquipmentname());
        holder.tv_cardId.setText(item.getEquipmentcardid());
    }

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

    class ViewHolder extends RecyclerView.ViewHolder{
        LinearLayout ll_all;
        TextView tv_name,tv_status,tv_cardId;
        View root;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            root = itemView;
            ll_all = itemView.findViewById(R.id.moudle_item_patrol_equ_ll_all);
            tv_name = itemView.findViewById(R.id.moudle_item_patrol_equ_tv_title);
            tv_status = itemView.findViewById(R.id.moudle_item_patrol_equ_tv_status);
            tv_cardId = itemView.findViewById(R.id.moudle_item_patrol_equ_tv_content);
        }
    }
}
