package com.maxmoney.maxcddconsole.Adapter;


import android.graphics.Color;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.maxmoney.maxcddconsole.Class.PaySlipClass;
import com.maxmoney.maxcddconsole.R;

import java.util.List;

public class PaySlipAdapter extends RecyclerView.Adapter<PaySlipAdapter.MyViewHolder> {

    private List<PaySlipClass> menuList;

    public class MyViewHolder extends RecyclerView.ViewHolder {
        public TextView tv1, tv2, tv3, tv4,tv5, tv6, tv7, tv8,tv9, tv10, tv11, tv12,tv13;
        LinearLayout linear_all;
        public MyViewHolder(View view) {
            super(view);
            tv1 = (TextView) view.findViewById(R.id.textView_1);
            tv2 = (TextView) view.findViewById(R.id.textView_2);
            tv3 = (TextView) view.findViewById(R.id.textView_3);
            tv4 = (TextView) view.findViewById(R.id.textView_4);
            tv5 = (TextView) view.findViewById(R.id.textView_5);
            tv6 = (TextView) view.findViewById(R.id.textView_6);
            tv7 = (TextView) view.findViewById(R.id.textView_7);
            tv8 = (TextView) view.findViewById(R.id.textView_8);
            tv9 = (TextView) view.findViewById(R.id.textView_9);
            tv10 = (TextView) view.findViewById(R.id.textView_10);
            tv11 = (TextView) view.findViewById(R.id.textView_11);
            tv12 = (TextView) view.findViewById(R.id.textView_12);
            tv13 = (TextView) view.findViewById(R.id.textView_13);
            linear_all = view.findViewById(R.id.linear_all);

        }
    }


    public PaySlipAdapter(List<PaySlipClass> menuList) {
        this.menuList = menuList;
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.list_payslip, parent, false);

        return new MyViewHolder(itemView);
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {
        PaySlipClass menu = menuList.get(position);
        holder.tv1.setText(menu.getTv1());
        holder.tv2.setText(menu.getTv2());
        holder.tv3.setText(menu.getTv3());
        holder.tv4.setText(menu.getTv4());
        holder.tv5.setText(menu.getTv5());
        holder.tv6.setText(menu.getTv6());
        holder.tv7.setText(menu.getTv7());
        holder.tv8.setText(menu.getTv8());
        holder.tv9.setText(menu.getTv9());
        holder.tv10.setText(menu.getTv10());
        holder.tv11.setText(menu.getTv11());
        holder.tv12.setText(menu.getTv12());
        holder.tv13.setText(menu.getTv13());


        if(position % 2 == 0){
            Log.d("yaw","yaw");
            holder.linear_all.setBackgroundColor(Color.parseColor("#BBDEFB"));
        }else{
            Log.d("yaw","yaws");
            holder.linear_all.setBackgroundColor(Color.parseColor("#FFFFFF"));
        }

    }

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