package com.danding.yang800.Adapter;


import android.content.Context;
import android.content.SharedPreferences;
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.Config.ConfigUtil;
import com.danding.yang800.Entity.SeeShopInfo;
import com.danding.yang800.General.Yang800App;
import com.danding.yang800.R;
import com.danding.yang800.SeeActivity;
import com.zhy.autolayout.utils.AutoUtils;

public class SeeShopTwoAdapter extends MyBaseAdapter<SeeShopInfo> {
    SeeActivity context;

    public SeeShopTwoAdapter(SeeActivity context) {
        super(context);
        this.context = context;
    }


    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Info info = null;
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.see_shop_twoitem, null);
            info = new Info();
            info.seeshoptwo_goodsIv = (ImageView) convertView.findViewById(R.id.seeshoptwo_goodsIv);
            info.seeshoptwo_noneIv = (ImageView) convertView.findViewById(R.id.seeshoptwo_noneIv);
            info.seeshoptwo_goodsNameTv = (TextView) convertView.findViewById(R.id.seeshoptwo_goodsNameTv);
            info.seeshoptwo_goodsPrcieIv = (TextView) convertView.findViewById(R.id.seeshoptwo_goodsPrcieIv);
            info.seeshoptwo_expFreeTv = (TextView) convertView.findViewById(R.id.seeshoptwo_expFreeTv);
            info.seeshoptwo_taxFreeTv = (TextView) convertView.findViewById(R.id.seeshoptwo_taxFreeTv);
            convertView.setTag(info);
            AutoUtils.autoSize(convertView);
        } else {
            info = (Info) convertView.getTag();
        }
        Glide.with(context).load(ConfigUtil.getImageUrl(getItem(position).getGoodsImgUrl(), 300, 300)).error(R.drawable.huisebeijing).diskCacheStrategy(DiskCacheStrategy.SOURCE)
                .into(info.seeshoptwo_goodsIv);
        info.seeshoptwo_goodsNameTv.setText(getItem(position).getGoodsName());
        info.seeshoptwo_goodsPrcieIv.setText("￥" + getItem(position).getPrice());
        if (getItem(position).isExpFree()) {
            info.seeshoptwo_expFreeTv.setVisibility(View.VISIBLE);
        } else {
            info.seeshoptwo_expFreeTv.setVisibility(View.GONE);
        }
        if (getItem(position).isTaxFree()) {
            info.seeshoptwo_taxFreeTv.setVisibility(View.VISIBLE);
        } else {
            info.seeshoptwo_taxFreeTv.setVisibility(View.GONE);
        }
        if (getItem(position).getStats().equals("3")) {
            info.seeshoptwo_noneIv.setVisibility(View.VISIBLE);
        } else {
            info.seeshoptwo_noneIv.setVisibility(View.GONE);
        }
        return convertView;
    }

    class Info {
        ImageView seeshoptwo_goodsIv;
        ImageView seeshoptwo_noneIv;
        TextView seeshoptwo_goodsNameTv;
        TextView seeshoptwo_goodsPrcieIv;
        TextView seeshoptwo_expFreeTv;
        TextView seeshoptwo_taxFreeTv;
    }

}
