package com.partynetwork.iparty.iparty;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.partynetwork.dataprovider.util.ActionUtil;
import com.partynetwork.iparty.R;
import com.partynetwork.iparty.app.common.BitmapManager;
import com.partynetwork.iparty.app.entities.CommonUser;
import com.partynetwork.iparty.app.util.StringUtils;
import com.partynetwork.iparty.helper.IntentHelper;
import com.partynetwork.iparty.info.OrderUserInfo;
import com.partynetwork.myview.myimageview.CircularImage;
public class IpartyParticipantView extends LinearLayout implements
OnClickListener {
private CircularImage head;
private TextView name;
private TextView content;
private TextView money;
private TextView time;
/** 数据源 */
private OrderUserInfo info;
private BitmapManager bitmapManager;
public IpartyParticipantView(Context context, BitmapManager bitmapManager) {
super(context);
this.bitmapManager = bitmapManager;
View.inflate(context, R.layout.iparty_participant_item, this);
initView();
}
/**
* 实例化对象
*/
private void initView() {
head = (CircularImage) this.findViewById(R.id.head);
head.setOnClickListener(this);
name = (TextView) this.findViewById(R.id.name);
content = (TextView) this.findViewById(R.id.content);
money = (TextView) this.findViewById(R.id.money);
time = (TextView) this.findViewById(R.id.time);
}
/**
* 事件监听
*
* @param view
*/
public void onClick(View view) {
switch (view.getId()) {
case R.id.head:
IntentHelper.goPersonalCenterActivity(getContext(),
Integer.parseInt(view.getTag().toString()));
break;
default:
break;
}
}
/**
* 设置数据源
*
* @param contact
*/
public void setInfo(CommonUser info) {
// 头像
bitmapManager.loadBitmap(info.getUserHeadUrl(), head);
head.setTag(info.getUserId());
// 姓名
name.setText(info.getUserName());
// 性别
Drawable right = null;
if (info.getUserSex() == ActionUtil.user.MALE) {
right = getResources()
.getDrawable(R.drawable.sex_boy_small_pressed);
} else if (info.getUserSex() == ActionUtil.user.FEMALE) {
right = getResources().getDrawable(
R.drawable.sex_girl_small_pressed);
} else {
right = getResources().getDrawable(
R.drawable.sex_neutral_small_pressed);
}
right.setBounds(0, 0, right.getMinimumWidth(), right.getMinimumHeight());
name.setCompoundDrawables(null, null, right, null);
content.setText(info.userCity + " " + info.getUserAge() + " "
+ info.getUserState());
try {
this.info = (OrderUserInfo) info;
if (this.info.getOrderMoney() == 0) {
money.setText("免");
} else {
money.setText("¥" + this.info.getOrderMoney());
}
time.setText(StringUtils.friendly_time(this.info.getEventTime()));
} catch (Exception e) {
}
}
}