package com.wisewoods.eduandroid.ui.adapter;

import com.blankj.utilcode.util.ConvertUtils;
import com.wisewoods.base.base.BaseAdapter;
import com.wisewoods.base.base.BaseVH;
import com.wisewoods.base.bean.ResList;
import com.wisewoods.eduandroid.R;

import org.jetbrains.annotations.NotNull;

public class ResAdapter extends BaseAdapter<ResList.DataBean> {
    public ResAdapter() {
        super(R.layout.item_recycler_res);
        addChildClickViewIds(R.id.tv_delete, R.id.card_dir);
        addChildLongClickViewIds(R.id.card_dir);
    }

    @Override
    protected void convert(@NotNull BaseVH baseVH, ResList.DataBean dataBean) {
        baseVH.setGone(R.id.card_dir, !"目录".equals(dataBean.type))
                .setGone(R.id.rl_file, "目录".equals(dataBean.type))
                .setText(R.id.tv_name, dataBean.directoryName)
                .setText(R.id.tv_dir, dataBean.directoryName)
                .setText(R.id.tv_time, dataBean.updateTime)
                .setGone(R.id.tv_size,dataBean.getSize() == 0)
                .setText(R.id.tv_size, ConvertUtils.byte2FitMemorySize(dataBean.getSize()))
        ;
    }
}
