package com.wmdigit.wmposdemo.adapter;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.wmdigit.wmposdemo.R;
import com.wmdigit.wmposdemo.model.bean.ApiButton;

import java.util.List;

public class ButtonAdapter extends BaseQuickAdapter<ApiButton, BaseViewHolder> {

    public ButtonAdapter(int layoutResId, List<ApiButton> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, ApiButton apiButton) {
        baseViewHolder.setText(R.id.tv_interface_number, apiButton.getMethodNo());
        baseViewHolder.setText(R.id.tv_interface_method, apiButton.getMethodName());
        baseViewHolder.setText(R.id.tv_interface_desc, apiButton.getMethodDesc());
        // 接口等级
        switch (apiButton.getLevel()){
            case LEVEL_ABANDON:
                baseViewHolder.setText(R.id.tv_level, "废弃");
                baseViewHolder.setTextColorRes(R.id.tv_level, R.color.gray);
                break;

            case LEVEL_IMPORTANT:
                baseViewHolder.setText(R.id.tv_level, "重要");
                baseViewHolder.setTextColorRes(R.id.tv_level, R.color.red);
                break;

            default:
                baseViewHolder.setText(R.id.tv_level, "");
                baseViewHolder.setTextColorRes(R.id.tv_level, R.color.gray);
                break;
        }
    }
}
