package com.rv.home.rv.module.ui.main.home.order.adapter;

import android.text.TextUtils;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.ruiwenliu.wrapper.util.BaseGlideHolder;
import com.rv.home.R;
import com.rv.home.R2;

/**
 * Created :Auser
 * Date: 2019/5/30.
 * Desc:添加评价图片
 */

public class EvaluationAdapter extends BaseQuickAdapter<String, BaseGlideHolder> {
    public EvaluationAdapter() {
        super(R.layout.rv_item_evaluation);
    }

    @Override
    protected void convert(BaseGlideHolder helper, String item) {
        if (TextUtils.isEmpty(item)) {
            helper.setGone(R.id.iv_delete, false);
            helper.setImageResource(R.id.iv_evaluation, R.drawable.im_pickup_button_norma);
        } else {
            helper.setGone(R.id.iv_delete, true);
            helper.loadRoundImage(mContext, item, (ImageView) helper.getView(R.id.iv_evaluation), 5);
        }
        helper.addOnClickListener(R.id.iv_delete);
        helper.addOnClickListener(R.id.iv_evaluation);
    }

    public void removeItem(int position) {

        mData.remove(position);
        if (!TextUtils.isEmpty(mData.get(mData.size() - 1))&& mData.size()>=3) {
            mData.add("");
            notifyDataSetChanged();
            return;
        }
        notifyItemRemoved(position);

    }

    public void addItem(String url) {
        mData.add(0, url);
        if (mData.size() == 5) {
            mData.remove(4);
        }
        notifyDataSetChanged();
    }
}
