package com.baidu.base;
import java.util.List;
import com.baidu.vo.Mydata;
import com.bwie.yd.R;
import com.lidroid.xutils.BitmapUtils;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
public class Shujubase extends BaseAdapter {
private List<Mydata> list;
private Context con;
public Shujubase(Context con, List<Mydata> list) {
this.list = list;
this.con = con;
}
public int getCount() {
return list.size();
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return null;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return 0;
}
public View getView(int position, View convertView, ViewGroup parent) {
int id = 0;
if (list.get(position).getImage_list() != null)
id = list.get(position).getImage_list().size();
Viewholder vh0;
Viewholder1 vh1;
Viewholder2 vh2;
Viewholder3 vh3;
if (convertView == null) {
switch (id) {
case 0:
if (list.get(position).getMiddle_image() != null) {
convertView = View.inflate(con, R.layout.shujubase1, null);
vh1 = new Viewholder1();
vh1.title = (TextView) convertView.findViewById(R.id.titel);
vh1.iv4 = (ImageView) convertView.findViewById(R.id.image4);
convertView.setTag(vh1);
BitmapUtils bi = new BitmapUtils(con);
bi.display(vh1.iv4, list.get(position).getMiddle_image()
.getUrl());
vh1.title.setText(list.get(position).getTitle());
} else {
convertView = View.inflate(con, R.layout.shujubase, null);
vh0 = new Viewholder();
vh0.title = (TextView) convertView.findViewById(R.id.titel);
convertView.setTag(vh0);
vh0.title.setText(list.get(position).getTitle());
}
break;
case 1:
if(list.get(position).getImage_list()!=null){
convertView = View.inflate(con, R.layout.shujubase2, null);
vh2 = new Viewholder2();
vh2.title = (TextView) convertView.findViewById(R.id.titel);
vh2.iv4 = (ImageView) convertView.findViewById(R.id.image4);
vh2.iv5 = (ImageView) convertView.findViewById(R.id.image5);
convertView.setTag(vh2);
BitmapUtils bu2 = new BitmapUtils(con);
bu2.display(vh2.iv4,
list.get(position).getImage_list().get(0).url);
bu2.display(vh2.iv5,
list.get(position).getImage_list().get(1).url);
vh2.title.setText(list.get(position).getTitle());
}else{
convertView = View.inflate(con, R.layout.shujubase1, null);
vh1 = new Viewholder1();
vh1.title = (TextView) convertView.findViewById(R.id.titel);
vh1.iv4 = (ImageView) convertView.findViewById(R.id.image4);
convertView.setTag(vh1);
BitmapUtils bu1 = new BitmapUtils(con);
bu1.display(vh1.iv4,
list.get(position).getImage_list().get(0).url);
vh1.title.setText(list.get(position).getTitle());
}
break;
case 2:
convertView = View.inflate(con, R.layout.shujubase2, null);
vh2 = new Viewholder2();
vh2.title = (TextView) convertView.findViewById(R.id.titel);
vh2.iv4 = (ImageView) convertView.findViewById(R.id.image4);
vh2.iv5 = (ImageView) convertView.findViewById(R.id.image5);
convertView.setTag(vh2);
BitmapUtils bu2 = new BitmapUtils(con);
bu2.display(vh2.iv4,
list.get(position).getImage_list().get(0).url);
bu2.display(vh2.iv5,
list.get(position).getImage_list().get(1).url);
vh2.title.setText(list.get(position).getTitle());
break;
case 3:
convertView = View.inflate(con, R.layout.shujubase3, null);
vh3 = new Viewholder3();
vh3.titel = (TextView) convertView.findViewById(R.id.titel);
vh3.iv4 = (ImageView) convertView.findViewById(R.id.image4);
vh3.iv5 = (ImageView) convertView.findViewById(R.id.image5);
vh3.iv6 = (ImageView) convertView.findViewById(R.id.image6);
convertView.setTag(vh3);
BitmapUtils bu3 = new BitmapUtils(con);
bu3.display(vh3.iv4,
list.get(position).getImage_list().get(0).url);
bu3.display(vh3.iv5,
list.get(position).getImage_list().get(1).url);
bu3.display(vh3.iv6,
list.get(position).getImage_list().get(2).url);
vh3.titel.setText(list.get(position).getTitle());
break;
}
}
return convertView;
}
class Viewholder {
TextView title;
}
class Viewholder1 {
TextView title;
ImageView iv4;
}
class Viewholder2 { ImageView iv4; TextView title;
ImageView iv5;
}
class Viewholder3 {
ImageView iv4;
ImageView iv5;
ImageView iv6;
TextView titel;
}
}