package com.fxy.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.elvishew.xlog.XLog;
import com.fxy.baselibrary.imageloader.GlideUtil;
import com.fxy.R;

import java.util.List;

/**
 * Created by lijie on 2018/4/10.
 */

public class ShowImgAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
    private Context mContext;
    private String first = "add_img";
    private int maxNum = 12;
    public ShowImgAdapter(Context context, @Nullable List<String> data) {
        super(R.layout.item_add_img, data);
        this.mContext = context;
    }

    public String getFirst(){
        return first;
    }

    //shezhi
    public void setMaxNum(int num){
        maxNum = num;
    }

    @Override
    public void addData(@NonNull String data) {
        super.addData(data);
    }

    @Override
    protected void convert(BaseViewHolder helper, String item) {
        XLog.d("=======helper.getLayoutPosition()=====" + helper.getLayoutPosition() + "====getData().size()====" + getData().size() + "========item==" + item);
        if (first.equals(item)) {
            helper.setImageResource(R.id.image, R.drawable.ic_add_img);
            if (helper.getLayoutPosition() == maxNum) {
                helper.setGone(R.id.image, false);
            }
        } else {
            XLog.d("=====GlideUtil=======" + item);
            GlideUtil.getInstance().loadImage(mContext, (ImageView) helper.getView(R.id.image), item, false);
        }
    }
}


