package com.danding.yang800.Adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.android.volley.RequestQueue;
import com.android.volley.toolbox.ImageLoader;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.danding.yang800.Config.ConfigUtil;
import com.danding.yang800.Entity.DetailsInfo;
import com.danding.yang800.General.SingleRequestQueue;
import com.danding.yang800.R;
import com.zhy.autolayout.utils.AutoUtils;

import java.io.Serializable;

public class DetailsAdapter extends MyBaseAdapter<DetailsInfo> {

    public DetailsAdapter(Context context) {
        super(context);
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        Info info = null;
        if (convertView == null) {
            convertView = inflater
                    .inflate(R.layout.details_adapter, null);
            info = new Info();
            info.details_image = (ImageView) convertView.findViewById(R.id.details_image);
            info.details_name = (TextView) convertView.findViewById(R.id.details_name);
            info.details_price = (TextView) convertView.findViewById(R.id.details_price);
            info.details_number = (TextView) convertView.findViewById(R.id.details_number);
            convertView.setTag(info);
            AutoUtils.autoSize(convertView);

        } else {
            info = (Info) convertView.getTag();
        }
        Glide.with(context).load(getItem(position).getUrl()).error(R.drawable.huisebeijing).diskCacheStrategy(DiskCacheStrategy.SOURCE).into(info.details_image);
        info.details_name.setText(getItem(position).getName());
        info.details_price.setText("￥" + getItem(position).getPrice());
        info.details_number.setText("x" + getItem(position).getNumber());
        return convertView;
    }


    class Info {
        ImageView details_image;
        TextView details_name;
        TextView details_price;
        TextView details_number;
    }
}
