package com.fxy.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.view.View;
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.R;
import com.fxy.baselibrary.views.dialog.RxDialogZoomImageView;
import com.fxy.logic.ViewLogic;

import org.json.JSONObject;

import java.util.List;



public  class GoodsAdapter extends BaseQuickAdapter<JSONObject, BaseViewHolder> {

    private Context mContext;

    public GoodsAdapter(Context context, List<JSONObject> data) {
        super(R.layout.item_fxy_check_goods, data);
        this.mContext = context;
    }
    @Override
    protected void convert(BaseViewHolder holder, JSONObject jsonObject) {
        //XLog.e(jsonObject);

        try {

            holder.setText(R.id.mt_order_number, jsonObject.getString("order_number"));
            holder.setText(R.id.mt_cn_name, jsonObject.getString("cn_name"));
            holder.setText(R.id.mt_model_number, jsonObject.getString("specification"));
            holder.setText(R.id.mt_qty, jsonObject.getString("qty"));
            final String image_url = jsonObject.getString("image_url");

            holder.setGone(R.id.ll_right_icon,true);

            ImageView ivGoodsImg =  (ImageView)holder.getView(R.id.iv_goods_img);
            new  ViewLogic.GlideImageLoder(mContext,ivGoodsImg,image_url);
            ivGoodsImg.setOnClickListener(new View.OnClickListener(){
                @Override
                public void onClick(View v) {
                    RxDialogZoomImageView rxDialogZoomImageView = new RxDialogZoomImageView(mContext);
                    rxDialogZoomImageView.setImagePath(image_url);
                    rxDialogZoomImageView.show();
                }
            });

        } catch (Exception e) {
            XLog.e("查验列表数据渲染失败："+e.getMessage());
            e.printStackTrace();
        }

    }
}
