package com.fxy.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
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;


/**
 * 项目名称：FingerCRM
 * 类描述：新增图片适配器
 * 创建人：lzy
 * 创建时间：2016/10/12 15:59
 * 修改人：COMP-021-2001
 * 修改时间：2016/10/12 15:59
 * 修改备注：
 */
public class NewPhotoAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
    private Context mContext1;
    private String first = "add_img";

    public NewPhotoAdapter(Context context,  List<String> data) {

        super(R.layout.item_add_img, data);
         XLog.d("====data===="+data);
        if (data.isEmpty()||!first.equals(data.get(data.size()-1))) {
            getData().add(first);
        }
        this.mContext1 = context;

    }

    public String getFirst(){
        return first;
    }


    @Override
    public void addData(@NonNull String data) {

        super.addData(getData().size() - 1, 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() == 12) {
                helper.setVisible(R.id.image, false);
            }
        } else {
            XLog.d("=====GlideUtil=======" + item);
            GlideUtil.getInstance().loadImage(mContext1, (ImageView) helper.getView(R.id.image), item, false);
        }
    }
}





















