use of com.juns.wechat.bean.User in project wechat by motianhuo.
the class AddGroupChatActivity method initData.
@Override
protected void initData() {
// 获取好友列表
alluserList = new ArrayList<User>();
for (User user : GloableParams.UserInfos) {
if (!user.getUserName().equals(Constant.NEW_FRIENDS_USERNAME) & !user.getUserName().equals(Constant.GROUP_USERNAME))
alluserList.add(user);
}
contactAdapter = new ContactAdapter(AddGroupChatActivity.this, alluserList);
listView.setAdapter(contactAdapter);
}
use of com.juns.wechat.bean.User in project wechat by motianhuo.
the class AddGroupChatActivity method setListener.
@Override
protected void setListener() {
img_back.setOnClickListener(this);
tv_header.setOnClickListener(this);
txt_right.setOnClickListener(this);
et_search.addTextChangedListener(new TextWatcher() {
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (s.length() > 0) {
String str_s = et_search.getText().toString().trim();
List<User> users_temp = new ArrayList<User>();
for (User user : alluserList) {
String usernick = user.getUserName();
if (usernick.contains(str_s)) {
users_temp.add(user);
}
contactAdapter = new ContactAdapter(AddGroupChatActivity.this, users_temp);
listView.setAdapter(contactAdapter);
}
} else {
contactAdapter = new ContactAdapter(AddGroupChatActivity.this, alluserList);
listView.setAdapter(contactAdapter);
}
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
public void afterTextChanged(Editable s) {
}
});
}
use of com.juns.wechat.bean.User in project wechat by motianhuo.
the class AddGroupChatActivity method save.
/**
* 确认选择的members
*
* @param v
*/
public void save() {
if (addList.size() == 0) {
Utils.showLongToast(AddGroupChatActivity.this, "请选择用户");
return;
}
// 如果只有一个用户说明只是单聊,并且不是从群组加人
if (addList.size() == 1 && isCreatingNewGroup) {
String userId = addList.get(0);
User user = GloableParams.Users.get(userId);
Intent intent = new Intent(AddGroupChatActivity.this, ChatActivity.class);
intent.putExtra(Constants.NAME, user.getUserName());
intent.putExtra(Constants.TYPE, ChatActivity.CHATTYPE_SINGLE);
intent.putExtra(Constants.User_ID, user.getTelephone());
startActivity(intent);
overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out);
} else {
if (isCreatingNewGroup) {
getLoadingDialog("正在创建群聊...").show();
} else {
getLoadingDialog("正在加人...").show();
}
// 创建群组
creatNewGroup(addList);
}
}
use of com.juns.wechat.bean.User in project wechat by motianhuo.
the class AddGroupChatActivity method creatNewGroup.
private void creatNewGroup(final List<String> members) {
// TODO 请求服务器创建群组,服务端实现接口
new Thread(new Runnable() {
@Override
public void run() {
// 调用sdk创建群组方法
try {
final String[] strmembers = new String[members.size()];
for (int i = 0; i < members.size(); i++) {
User user = GloableParams.Users.get(members.get(i));
if (user != null) {
if (i < 3) {
if (i == 0)
groupName = user.getUserName();
else
groupName += "、" + user.getUserName();
} else if (i == 4) {
groupName += "...";
}
strmembers[i] = user.getTelephone();
if (i == 0) {
manber = user.getTelephone();
} else {
manber += "、" + user.getTelephone();
}
}
}
final EMGroup group = EMGroupManager.getInstance().createPublicGroup(groupName, "", strmembers, true);
runOnUiThread(new Runnable() {
public void run() {
if (group != null) {
// TODO 保存本地数据库
GloableParams.GroupInfos = new HashMap<String, GroupInfo>();
GroupInfo info = new GroupInfo();
info.setGroup_id(group.getGroupId());
info.setGroup_name(groupName);
info.setMembers(manber);
String owner_id = Utils.getValue(AddGroupChatActivity.this, Constants.User_ID);
info.setOwner_id(owner_id);
GloableParams.GroupInfos.put(group.getGroupId(), info);
FinalDb db = FinalDb.create(AddGroupChatActivity.this, Constants.DB_NAME, false);
db.save(info);
addServieGroup(group.getGroupId(), groupName, manber, // 保存服务器
owner_id);
}
}
});
} catch (final EaseMobException e) {
runOnUiThread(new Runnable() {
public void run() {
Utils.showLongToast(AddGroupChatActivity.this, "创建失败");
getLoadingDialog("正在创建群聊...").dismiss();
}
});
}
}
}).start();
}
use of com.juns.wechat.bean.User in project wechat by motianhuo.
the class FriendMsgActivity method initData.
@Override
protected void initData() {
UserId = getIntent().getStringExtra(Constants.User_ID);
Name = getIntent().getStringExtra(Constants.NAME);
if (TextUtils.isEmpty(UserId))
finish();
else {
User user = GloableParams.Users.get(UserId);
tv_name.setText(user.getUserName());
tv_accout.setText("微信号:" + UserId);
}
}
Aggregations