package com.wd.workoffice.ui.adapter;


import android.content.Intent;
import android.view.View;

import com.alibaba.fastjson.JSON;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.wd.workoffice.R;
import com.wd.workoffice.bean.mesBean.OrderBadBean;
import com.wd.workoffice.ui.activity.mes.report.MesReportDetailActivity;

import java.util.List;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import static flexible.xd.android_base.utils.ActivityUtils.startActivity;

/**
 * Created by flexible on 2018/8/13.
 */

public class ReportBadListAdapter extends BaseQuickAdapter<OrderBadBean.ScrapStatisticsListsBean, BaseViewHolder> {

    public ReportBadListAdapter(int layoutResId, List data) {
        super(layoutResId, data);
    }


    @Override
    protected void convert(BaseViewHolder helper, OrderBadBean.ScrapStatisticsListsBean item) {
        RecyclerView rvData = helper.getView(R.id.rv_data);
        rvData.setLayoutManager( new LinearLayoutManager(helper.getConvertView().getContext(),RecyclerView.VERTICAL,false));
        ReportBadAdapter reportBadProAdapter =new ReportBadAdapter(R.layout.item_mes_report_bad,item.getScrapStatistics());
        reportBadProAdapter.bindToRecyclerView(rvData);

        reportBadProAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                Intent intent =new Intent(helper.getConvertView().getContext(),MesReportDetailActivity.class);
                intent.putExtra("info", JSON.toJSONString(item));
                intent.putExtra("data", JSON.toJSONString(item.getScrapStatistics().get(position)));
                startActivity(intent);
            }
        });
    }
}

