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.mesBean.ProBadBean;
import com.wd.workoffice.bean.mesBean.ReportProBean;
import com.wd.workoffice.util.MathUtils;

import java.util.List;

import flexible.xd.android_base.utils.ScreenUtils;

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

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

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

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

    }
}

