package com.lianxin.pubqq.main.adpter;

import java.util.List;
import android.content.Context;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.lianxin.pubqq.R;

import com.lianxin.panqq.main.bean.LivePerson;

public class LiveListAdapter extends BaseAdapter{

	private List<LivePerson> mList;
	private LayoutInflater mInflater; 
	private Context mContext;	
	 
	public LiveListAdapter(Context context,List<LivePerson> userList) {
		mInflater = LayoutInflater.from(context);
		mContext=context;
		this.mList=userList;

	}

	@Override
	public int getCount() {
		return mList==null?0:mList.size();
	}

	@Override
	public LivePerson getItem(int position) {
		return mList.get(position);
	}

 
	public String getUser(int position) {
		return mList.get(position).getNickName();
	}
	
	 @Override
	public long getItemId(int position) {
		return position;		
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
	    final ViewHolder holder;
		if (convertView == null) {
			holder = new ViewHolder();
			convertView = mInflater.inflate(R.layout.layout_item_live, null);
			holder.img_gridview = (ImageView)convertView.findViewById(R.id.img_item_gridview);
			holder.tv_roomname = (TextView)convertView.findViewById(R.id.tv_roomname);
			holder.tv_nickname = (TextView)convertView.findViewById(R.id.tv_nickname);			
			holder.tv_onlinenum = (TextView) convertView.findViewById(R.id.tv_onlinenum);

			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
	//	if(position<80){
		final LivePerson person = getItem(position);
	    holder.tv_roomname.setText(person.getRoomName());
	    holder.tv_nickname.setText(person.getNickName());
	    String str = ""+person.getNickName()+",女,18岁,云南大理";
	    holder.tv_nickname.setText(str);	    
	    holder.tv_onlinenum.setText("观看人数:"+person.getOnlineNum());
	

		return convertView;
	}

	private static class ViewHolder {

        //        图片
     //   public SimpleDraweeView img_item_gridview;
		public ImageView img_gridview;		
        //        房间名称
        public TextView tv_roomname;
        //        在线人数
        public TextView tv_onlinenum;
        //        昵称
        public TextView tv_nickname;
        //        Icon
        public RelativeLayout rl_liveicon;		
		public TextView name;
		public ImageView avator;
		TextView content;
		Button command;
	}

}
