package com.bbitcn.silk.adapter;

import com.bbitcn.silk.base.BaseDialog;
import com.bbitcn.silk.base.BaseRecyclerAdapter;
import com.bbitcn.silk.databinding.ItemConvertBinding;
import com.bbitcn.silk.model.InfoContent;
import com.bbitcn.silk.ui.dialog.SpinnerDialog;
import com.bbitcn.silk.utils.database.AllTypeDataBase;

import java.util.List;

/**
 * @Author DuanKaiji
 * @CreateTime 2024年04月01日 14:13:39
 */
public class ConvertAdapter extends BaseRecyclerAdapter<InfoContent, ItemConvertBinding> {

    public ConvertAdapter(List<InfoContent> dataList, Class<ItemConvertBinding> bindingClass) {
        super(dataList, bindingClass);
    }

    @Override
    protected void bindData(ItemConvertBinding binding, InfoContent data) {
        binding.tvOld.setText(data.getTv1());
        binding.tvWeight.setText(data.getTv2());
        binding.llConvertTarget.setOnClickListener(v -> {
            new SpinnerDialog(binding.getRoot().getContext(), "目标茧别", "不转换", AllTypeDataBase.getAllTypeName(), new BaseDialog.CustomString() {
                @Override
                public void listener(String selString) {
                    binding.tvNew.setText(selString);
                }
            }, true).show();
        });

    }
}
