package com.android.chmo.ui.adpater;

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

import com.android.chmo.R;
import com.android.chmo.base.BaseActivity;
import com.android.chmo.http.HttpApi;
import com.android.chmo.model.ActivitiesInfo;
import com.android.chmo.utils.XUtilsImage;

/**
 * Created by Administrator on 2018/8/7.
 */

public class SignAdapter extends CommonAdapter<ActivitiesInfo> {
    private BaseActivity baseActivity;

    public SignAdapter(BaseActivity activity) {
        super(activity);
        baseActivity = activity;
    }

    @Override
    public View getItemView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if(null != convertView) {
            holder = (ViewHolder) convertView.getTag();
        }
        if(null == holder) {
            convertView = mInflater.inflate(R.layout.list_my_sign_item, null);
            holder = new ViewHolder();
            holder.imageView = (ImageView) convertView.findViewById(R.id.image);
            holder.titleView = (TextView) convertView.findViewById(R.id.stitle);
            holder.infoView = (TextView) convertView.findViewById(R.id.info);
            holder.timeView = (TextView) convertView.findViewById(R.id.time);
            convertView.setTag(holder);
        }

        ActivitiesInfo info = mList.get(position);
        holder.titleView.setText(info.caption);
        holder.infoView.setText(info.intro);
        holder.timeView.setText("开始时间：" + info.beg);
        XUtilsImage.display(holder.imageView, HttpApi.getImgUrl(info.pic), R.mipmap.def_img2);
        return convertView;
    }


    class ViewHolder {
        ImageView imageView;
        TextView titleView;
        TextView infoView;
        TextView timeView;
    }
}
