package com.wd.workoffice.ui.adapter;


import android.view.View;
import android.view.ViewGroup;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.wd.workoffice.R;
import com.wd.workoffice.bean.ProductBean;
import com.wd.workoffice.bean.mesBean.ProBadBean;
import com.wd.workoffice.util.MathUtils;

import java.nio.file.Path;
import java.util.List;

import flexible.xd.android_base.utils.ScreenUtils;

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

public class ReportTopAdapter extends BaseQuickAdapter<ProBadBean.DataBean, BaseViewHolder> {
    double bigValue;
    int width = ScreenUtils.getScreenWidth() / 2;

    public ReportTopAdapter(int layoutResId, List<ProBadBean.DataBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, ProBadBean.DataBean item) {
        View progress = helper.getView(R.id.view_progress);
        ViewGroup.LayoutParams layoutParams = progress.getLayoutParams();
        if (helper.getAdapterPosition() == 0) {
            bigValue = item.getScrapWeight();
            layoutParams.width = width;
        } else {
            if (item.getScrapWeight() == 0d) {
                layoutParams.width = 0;
            } else {
                int lastWidth = Integer.parseInt(MathUtils.multiply(String.valueOf(item.getScrapWeight() / bigValue), width + "", 0));
                if (lastWidth == 0) {
                    lastWidth = lastWidth + 5;
                }
                layoutParams.width = lastWidth;
            }
        }
        helper.setText(R.id.tv_name, item.getVariety());

    }
}

