package com.wd.workoffice.ui.adapter;


import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.wd.workoffice.R;
import com.wd.workoffice.bean.LogisticDetailBean;
import com.wd.workoffice.bean.TicketAddBean;
import com.wd.workoffice.util.MathUtils;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import androidx.annotation.Nullable;

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

public class WorkAddLogisticProAdapter extends BaseQuickAdapter<LogisticDetailBean.RecordsBean, BaseViewHolder> {

    Map<Integer, Boolean> isChoose = new HashMap<>();

    public WorkAddLogisticProAdapter(int layoutResId, List data) {
        super(layoutResId, data);
        for (int i = 0; i < isChoose.entrySet().size(); i++) {
            isChoose.put(i, false);

        }
    }

    @Override
    protected void convert(BaseViewHolder helper, LogisticDetailBean.RecordsBean item) {
        helper.setText(R.id.tv_company, item.getLaunchDeptName());
        helper.setText(R.id.tv_client, item.getCustomerName());
        helper.setText(R.id.tv_name, "快递单号："+item.getTrackingNumber());
        helper.setText(R.id.tv_weight, MathUtils.converData(item.getWeight(),3));
        helper.setText(R.id.tv_tax, MathUtils.converData(item.getMoney(),3));
        helper.setText(R.id.tv_person, item.getCreatedByName());
        CheckBox cbChoose = helper.getView(R.id.cb_check);
        cbChoose.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                isChoose.put(helper.getAdapterPosition(), cbChoose.isChecked());
            }
        });
    }

    public Map<Integer, Boolean> getIsChoose() {
        return isChoose;
    }

    public void setIsChoose(Map<Integer, Boolean> isChoose) {
        this.isChoose = isChoose;
    }
}

