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.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.danding.yang800.Entity.GiftListInfo;
import com.danding.yang800.Entity.InviteNoteInfo;
import com.danding.yang800.GiftListActivity;
import com.danding.yang800.R;
import com.zhy.autolayout.utils.AutoUtils;

public class GiftListAdapter extends MyBaseAdapter<GiftListInfo> {
    GiftListActivity context;

    public GiftListAdapter(GiftListActivity context) {
        super(context);
        this.context = context;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        Info info = null;
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.gistlist_adapter, null);
            info = new Info();
            info.giftlist_Iv = (ImageView) convertView.findViewById(R.id.giftlist_Iv);
            info.giftlist_nameTv = (TextView) convertView.findViewById(R.id.giftlist_nameTv);
            info.giftlist_priceIntTv = (TextView) convertView.findViewById(R.id.giftlist_priceIntTv);
            info.giftlist_priceTv = (TextView) convertView.findViewById(R.id.giftlist_priceTv);
            info.giftList_adapterBuyTv = (TextView) convertView.findViewById(R.id.giftList_adapterBuyTv);
            convertView.setTag(info);
            AutoUtils.autoSize(convertView);
        } else {
            info = (Info) convertView.getTag();
        }
        info.giftList_adapterBuyTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                context.toGiftInfo(getItem(position).getStoreSkuSn());
            }
        });
        info.giftlist_nameTv.setText(getItem(position).getSkuName());
        info.giftlist_priceIntTv.setText("￥" + getItem(position).getPriceInt());
        info.giftlist_priceTv.setText( getItem(position).getPrice());
        Glide.with(context).load(getItem(position).getImageUrl()).diskCacheStrategy(DiskCacheStrategy.ALL).into(info.giftlist_Iv);
        return convertView;
    }

    class Info {
        ImageView giftlist_Iv;
        TextView giftlist_nameTv;
        TextView giftlist_priceIntTv;
        TextView giftlist_priceTv;
        TextView giftList_adapterBuyTv;
    }

}
