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.ui.activity.model.VideoOrderInfo;
import com.android.chmo.utils.XUtilsImage;

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

public class VideoOrderAdapter extends CommonAdapter<VideoOrderInfo> {
    private BaseActivity baseActivity;

    public VideoOrderAdapter(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) {
            holder = new ViewHolder();
            convertView = mInflater.inflate(R.layout.list_video_order_item, null);
            holder.headView = (ImageView) convertView.findViewById(R.id.head);
            holder.nameView = (TextView) convertView.findViewById(R.id.name);
            holder.timeView = (TextView) convertView.findViewById(R.id.time);
            holder.priceView = (TextView) convertView.findViewById(R.id.price);
            holder.videoTimeView = (TextView) convertView.findViewById(R.id.videoTime);
            convertView.setTag(holder);
        }

        VideoOrderInfo info = mList.get(position);

        XUtilsImage.display(holder.headView, HttpApi.getImgUrl(info.hphoto),R.mipmap.def_img2);
        holder.nameView.setText(info.pet);
        holder.timeView.setText("时间：" + info.begdate);
        holder.priceView.setText(info.coin + "元");
        holder.videoTimeView.setText("/" + info.duration + "分钟");

        return convertView;
    }


    private class ViewHolder {
        ImageView headView;
        TextView nameView;
        TextView timeView;
        TextView priceView;
        TextView videoTimeView;
    }
}
