package com.tenlionsoft.baselib.core.widget.base;

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.FuncBean;

import java.util.List;

/**
 * 作者: Adam
 * 日期: 2019/8/14 - 10:01
 * 邮箱: itgaojian@163.com
 * 描述:
 */
public class FunctionTitleNumAdapter extends BaseRecyclerAdapter<FuncBean, FuncNumHolder> {
    public FunctionTitleNumAdapter(Context ctx, List<FuncBean> list) {
        super(ctx, list);
    }

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

    @Override
    public void bindHolder(FuncNumHolder funcHolder, int i) {
        funcHolder.mTvTitle.setText(mData.get(i).getText());
        funcHolder.mIvIcon.setBackgroundResource(mData.get(i).getIconRes());
        if (mData.get(i).getHintNum() == 0) {
            funcHolder.mTvHintNum.setVisibility(View.GONE);
        } else if (mData.get(i).getHintNum() > 99) {
            funcHolder.mTvHintNum.setVisibility(View.VISIBLE);
            funcHolder.mTvHintNum.setText("99+");
        } else {
            funcHolder.mTvHintNum.setVisibility(View.VISIBLE);
            funcHolder.mTvHintNum.setText(mData.get(i).getHintNum() + "");
        }
    }
}
