package com.tenlionsoft.baselib.core.widget;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.tenlionsoft.baselib.R;
import com.tenlionsoft.baselib.core.beans.OperateBean;
import com.tenlionsoft.baselib.core.widget.base.BaseRecyclerAdapter;

import java.util.List;

/**
 * 作者: adam
 * 日期: 2021/10/20 - 11:18 上午
 * 邮箱: itgaojian@163.com
 * 描述:
 */
public class OperateAdapter extends BaseRecyclerAdapter<OperateBean, OperateHolder> {

    public OperateAdapter(Context ctx, List<OperateBean> list) {
        super(ctx, list);
    }

    @Override
    public OperateHolder createHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.item_operate_layout, parent, false);
        return new OperateHolder(view);
    }

    @Override
    public void bindHolder(OperateHolder holder, int i) {
        OperateBean bean = mData.get(i);
        holder.mTvName.setText(bean.getName());
        if (bean.getResId() != 0) {
            holder.mIvIcon.setVisibility(View.VISIBLE);
            holder.mIvIcon.setBackgroundResource(bean.getResId());
        } else {
            holder.mIvIcon.setVisibility(View.GONE);
        }
    }

}
