package com.wd.workoffice.ui.adapter;


import android.graphics.Color;
import android.widget.LinearLayout;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.wd.workoffice.R;
import com.wd.workoffice.bean.AllAccountBean;
import com.wd.workoffice.bean.workEnum.PagePermissionType;
import com.wd.workoffice.util.MathUtils;
import com.wd.workoffice.util.WorkUtils;

import java.util.List;

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

public class WorkFinancialAccountAdapter extends BaseQuickAdapter<AllAccountBean.RecordsBean, BaseViewHolder> {

    private String[] topColor = {"#359486", "#C45D5D", "#3F617F", "#E3AD6E", "#6A82DB"};
    private String[] bottomColor = {"#37A999", "#D66E6E", "#53789A", "#EDB36F", "#738BE3"};

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

    @Override
    protected void convert(BaseViewHolder helper, AllAccountBean.RecordsBean item) {
        LinearLayout llTop = helper.getView(R.id.ll_top);
        LinearLayout llBottom = helper.getView(R.id.ll_bottom);
        llTop.setBackgroundColor(Color.parseColor(topColor[helper.getAdapterPosition() % 5]));
        llBottom.setBackgroundColor(Color.parseColor(bottomColor[helper.getAdapterPosition() % 5]));
        helper.setText(R.id.tv_dep_freeze_price, MathUtils.converData(item.getFrozenAmount(), 3));
        helper.setText(R.id.tv_dep_price, MathUtils.converData(item.getBalance(), 3));
        helper.setText(R.id.tv_name, item.getName());
        helper.addOnClickListener(R.id.tv_freeze);
        helper.addOnClickListener(R.id.tv_thaw);
        helper.addOnClickListener(R.id.tv_see_flow);
        if (!WorkUtils.hasPermission(PagePermissionType.BALANCE_UPDATE.getPermission())) {
            helper.setGone(R.id.tv_freeze, true);
            helper.setGone(R.id.tv_thaw, true);
        }
        if (!WorkUtils.hasPermission(PagePermissionType.FINANCE_FLOW_LIST.getPermission())) {
            helper.setGone(R.id.tv_see_flow, true);
        }

    }
}

