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.AfterServiceInfo;
import com.danding.yang800.Entity.DetailsInfo;
import com.danding.yang800.R;
import com.zhy.autolayout.utils.AutoUtils;

public class AfterServiceAdapter extends MyBaseAdapter<AfterServiceInfo> {

    public AfterServiceAdapter(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.afterservice_adapter, null);
            info = new Info();
            info.afterservice_imageIv = (ImageView) convertView.findViewById(R.id.afterservice_imageIv);
            info.afterservice_nameTv = (TextView) convertView.findViewById(R.id.afterservice_nameTv);
            info.afterservice_numberTv = (TextView) convertView.findViewById(R.id.afterservice_numberTv);
            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.afterservice_imageIv);
        info.afterservice_nameTv.setText(getItem(position).getName());
        info.afterservice_numberTv.setText("x" + getItem(position).getNumber());
        return convertView;
    }


    class Info {
        ImageView afterservice_imageIv;
        TextView afterservice_nameTv;
        TextView afterservice_numberTv;
    }
}
