package xn.hxp.ui.adapter;

import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.blankj.utilcode.util.ClickUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.rc.httpcore.bean.HxpChemicalVo;

import xn.hxp.R;
import xn.hxp.weidith.TextTool;

import java.util.List;

public class SelectChemicalDialogAdapter extends BaseQuickAdapter<HxpChemicalVo, BaseViewHolder> {
    public SelectChemicalDialogAdapter(int layoutResId, @Nullable List<HxpChemicalVo> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, HxpChemicalVo hxpChemicalVo) {
        baseViewHolder.setText(R.id.chemicalName, TextUtils.isEmpty(hxpChemicalVo.getChemicalName()) ? "" : hxpChemicalVo.getChemicalName());
        TextView chemicalNameView = baseViewHolder.getView(R.id.chemicalName);
        chemicalNameView.setOnClickListener(new ClickUtils.OnDebouncingClickListener() {
            @Override
            public void onDebouncingClick(View v) {
                TextTool.showPop(baseViewHolder.itemView.getContext(), chemicalNameView);
            }
        });
        baseViewHolder.setText(R.id.casNum, TextUtils.isEmpty(hxpChemicalVo.getCasNum()) ? "" : hxpChemicalVo.getCasNum());
        baseViewHolder.setText(R.id.chemicalPurity, TextUtils.isEmpty(hxpChemicalVo.getChemicalPurity()) ? "" : hxpChemicalVo.getChemicalPurity());
    }
}
