package com.danding.yang800.Adapter;

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

import com.bumptech.glide.Glide;
import com.danding.yang800.Config.ConfigUtil;
import com.danding.yang800.Entity.MarketInfo;
import com.danding.yang800.Entity.MarketShopInfo;
import com.danding.yang800.R;
import com.danding.yang800.View.MyDialog;
import com.zhy.autolayout.utils.AutoUtils;

import jp.wasabeef.glide.transformations.CropCircleTransformation;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;

public class MarketInfoAdapter extends MyBaseAdapter<MarketShopInfo> {

    public MarketInfoAdapter(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.marketshopinfo_adapter, null);
            info = new Info();
            info.marketShopInfo_adapterIv = (ImageView) convertView.findViewById(R.id.marketShopInfo_adapterIv);
            info.marketShopInfo_adapterNameTv = (TextView) convertView.findViewById(R.id.marketShopInfo_adapterNameTv);
            info.marketShopInfo_adapterTimeTv = (TextView) convertView.findViewById(R.id.marketShopInfo_adapterTimeTv);
            info.marketShopInfo_adapterStatusTv = (TextView) convertView.findViewById(R.id.marketShopInfo_adapterStatusTv);
            convertView.setTag(info);
            AutoUtils.autoSize(convertView);

        } else {
            info = (Info) convertView.getTag();
        }
        Glide.with(context).load(ConfigUtil.getImageUrl(getItem(position).getUrl(), 80, 80)).error(R.drawable.huisebeijing)
                .bitmapTransform(new CropCircleTransformation(context)).crossFade(1000)
                .into(info.marketShopInfo_adapterIv);
        info.marketShopInfo_adapterNameTv.setText(getItem(position).getName());
        info.marketShopInfo_adapterTimeTv.setText(getItem(position).getTime());
        info.marketShopInfo_adapterStatusTv.setText(getItem(position).getStatus());
        return convertView;
    }


    class Info {
        ImageView marketShopInfo_adapterIv;
        TextView marketShopInfo_adapterNameTv;
        TextView marketShopInfo_adapterTimeTv;
        TextView marketShopInfo_adapterStatusTv;
    }
}
