package com.wd.workoffice.ui.adapter;


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.ProductBean;
import com.wd.workoffice.util.MathUtils;

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

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

public class TradingProDetailAdapter extends BaseQuickAdapter<ProductBean.RecordsBean, BaseViewHolder> {

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

    public TradingProDetailAdapter(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, ProductBean.RecordsBean item) {
        helper.setText(R.id.tv_name,item.getName() );
        helper.setText(R.id.tv_card, item.getSoleCode() );
        helper.setText(R.id.tv_card_name, item.getSoleCode());
        helper.setText(R.id.tv_spec,item.getSpec());
        helper.setText(R.id.tv_price, MathUtils.converData(item.getInternalPrice(),3));
        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;
    }
}

