use of com.juns.wechat.bean.User in project wechat by motianhuo.
the class FromContactAdapter method getView.
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = LayoutInflater.from(context).inflate(R.layout.layout_item_newfriend, parent, false);
}
ImageView img_avar = ViewHolder.get(convertView, R.id.img_photo);
TextView txt_name = ViewHolder.get(convertView, R.id.txt_name);
TextView txt_msg = ViewHolder.get(convertView, R.id.txt_msg);
final TextView txt_add = ViewHolder.get(convertView, R.id.txt_add);
final User user = UserInfos.get(position);
txt_name.setText(user.getUserName());
txt_add.setText("添加");
txt_msg.setText("微信号:" + user.getTelephone() + " " + user.getUserName());
txt_add.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
}
});
convertView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(context, FriendMsgActivity.class);
intent.putExtra(Constants.NAME, user.getUserName());
intent.putExtra(Constants.TYPE, ChatActivity.CHATTYPE_SINGLE);
intent.putExtra(Constants.User_ID, user.getTelephone());
context.startActivity(intent);
}
});
return convertView;
}
use of com.juns.wechat.bean.User in project wechat by motianhuo.
the class NewFriendsAdapter method getView.
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = LayoutInflater.from(context).inflate(R.layout.layout_item_newfriend, parent, false);
}
ImageView img_avar = ViewHolder.get(convertView, R.id.img_photo);
TextView txt_name = ViewHolder.get(convertView, R.id.txt_name);
final TextView txt_add = ViewHolder.get(convertView, R.id.txt_add);
final User user = GloableParams.UserInfos.get(position);
txt_name.setText(user.getUserName());
txt_add.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
txt_add.setTextColor(context.getResources().getColor(R.color.black1));
txt_add.setBackgroundResource(R.drawable.btn_bg_gray1);
txt_add.setText("已添加");
Utils.showLongToast(context, "添加好友成功,等待对方同意");
try {
EMContactManager.getInstance().addContact(user.getTelephone(), "请求添加你为朋友");
} catch (EaseMobException e) {
e.printStackTrace();
}
}
});
convertView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(context, FriendMsgActivity.class);
intent.putExtra(Constants.NAME, user.getUserName());
intent.putExtra(Constants.TYPE, ChatActivity.CHATTYPE_SINGLE);
intent.putExtra(Constants.User_ID, user.getTelephone());
context.startActivity(intent);
}
});
return convertView;
}
use of com.juns.wechat.bean.User in project wechat by motianhuo.
the class NewMsgAdpter method getMessageDigest.
/**
* 根据消息内容和消息类型获取消息内容提示
*
* @param message
* @param context
* @return
*/
private String getMessageDigest(EMMessage message, Context context) {
String digest = "";
switch(message.getType()) {
case // 位置消息
LOCATION:
if (message.direct == EMMessage.Direct.RECEIVE) {
digest = getStrng(context, R.string.location_recv);
String name = message.getFrom();
if (GloableParams.UserInfos != null) {
User user = GloableParams.Users.get(message.getFrom());
if (user != null && null != user.getUserName())
name = user.getUserName();
}
digest = String.format(digest, name);
return digest;
} else {
digest = getStrng(context, R.string.location_prefix);
}
break;
case // 图片消息
IMAGE:
ImageMessageBody imageBody = (ImageMessageBody) message.getBody();
digest = getStrng(context, R.string.picture) + imageBody.getFileName();
break;
case // 语音消息
VOICE:
digest = getStrng(context, R.string.voice_msg);
break;
case // 视频消息
VIDEO:
digest = getStrng(context, R.string.video);
break;
case // 文本消息
TXT:
if (!message.getBooleanAttribute(Constant.MESSAGE_ATTR_IS_VOICE_CALL, false)) {
TextMessageBody txtBody = (TextMessageBody) message.getBody();
digest = txtBody.getMessage();
} else {
TextMessageBody txtBody = (TextMessageBody) message.getBody();
digest = getStrng(context, R.string.voice_call) + txtBody.getMessage();
}
break;
case // 普通文件消息
FILE:
digest = getStrng(context, R.string.file);
break;
default:
System.err.println("error, unknow type");
return "";
}
return digest;
}
use of com.juns.wechat.bean.User in project wechat by motianhuo.
the class SplashActivity method initData.
private void initData() {
GloableParams.UserInfos = new ArrayList<User>();
GloableParams.Users = new HashMap<String, User>();
GloableParams.ListGroupInfos = new ArrayList<GroupInfo>();
GloableParams.GroupInfos = new HashMap<String, GroupInfo>();
FinalDb db = FinalDb.create(this, Constants.DB_NAME, false);
GloableParams.ListGroupInfos = db.findAll(GroupInfo.class);
GloableParams.UserInfos = db.findAll(User.class);
}
use of com.juns.wechat.bean.User in project wechat by motianhuo.
the class SetMoneyActivity method initView.
@Override
protected void initView() {
String UserId = getIntent().getStringExtra(Constants.User_ID);
String money = getIntent().getStringExtra(Constants.NAME);
User user = GloableParams.Users.get(UserId);
String strname = "您正在向 " + user.getUserName() + "<br/>微信号:" + UserId + " 付钱";
tv_msg.setText(Html.fromHtml(strname));
String strmoney = "¥<font color='#ff11aca6'>" + money + "<small>元</small></font> ";
tv_money.setText(Html.fromHtml(strmoney));
}
Aggregations