use of com.juns.wechat.bean.GroupInfo in project wechat by motianhuo.
the class MyGroupAdpter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = LayoutInflater.from(context).inflate(R.layout.layout_item_mygroup, parent, false);
}
final GroupInfo group = grouplist.get(position);
ImageView img_avar = ViewHolder.get(convertView, R.id.img_photo);
TextView txt_name = ViewHolder.get(convertView, R.id.txt_name);
img_avar.setImageResource(R.drawable.defult_group);
txt_name.setText(group.getGroup_name());
convertView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(context, ChatActivity.class);
intent.putExtra(Constants.NAME, group.getGroup_name());
intent.putExtra(Constants.TYPE, ChatActivity.CHATTYPE_GROUP);
intent.putExtra(Constants.GROUP_ID, group.getGroup_id());
context.startActivity(intent);
}
});
return convertView;
}
use of com.juns.wechat.bean.GroupInfo 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.GroupInfo in project wechat by motianhuo.
the class Fragment_Msg method onItemClick.
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
if (adpter.PublicMsg != null && position == 0) {
// 打开订阅号列表页面
Utils.start_Activity(getActivity(), PublishMsgListActivity.class);
} else {
((MainActivity) getActivity()).updateUnreadLabel();
EMConversation conversation = conversationList.get(position);
Intent intent = new Intent(getActivity(), ChatActivity.class);
Hashtable<String, String> ChatRecord = adpter.getChatRecord();
if (ChatRecord != null) {
if (conversation.isGroup()) {
GroupInfo info = GloableParams.GroupInfos.get(conversation.getUserName());
if (info != null) {
intent.putExtra(Constants.TYPE, ChatActivity.CHATTYPE_GROUP);
intent.putExtra(Constants.GROUP_ID, info.getGroup_id());
// 设置标题
intent.putExtra(Constants.NAME, info.getGroup_name());
getActivity().startActivity(intent);
} else {
intent.putExtra(Constants.TYPE, ChatActivity.CHATTYPE_GROUP);
intent.putExtra(Constants.GROUP_ID, info.getGroup_id());
// 设置标题
intent.putExtra(Constants.NAME, R.string.group_chats);
getActivity().startActivity(intent);
}
} else {
User user = GloableParams.Users.get(conversation.getUserName());
if (user != null) {
// 设置昵称
intent.putExtra(Constants.NAME, user.getUserName());
intent.putExtra(Constants.TYPE, ChatActivity.CHATTYPE_SINGLE);
intent.putExtra(Constants.User_ID, conversation.getUserName());
getActivity().startActivity(intent);
} else {
intent.putExtra(Constants.NAME, "好友");
intent.putExtra(Constants.TYPE, ChatActivity.CHATTYPE_SINGLE);
intent.putExtra(Constants.User_ID, conversation.getUserName());
getActivity().startActivity(intent);
}
}
}
}
}
use of com.juns.wechat.bean.GroupInfo in project wechat by motianhuo.
the class UpdateService method initGroupList.
// 获取群组列表
private void initGroupList() {
GloableParams.ListGroupInfos = db.findAll(GroupInfo.class);
netClient.post(Constants.getGroupListURL, null, new BaseJsonRes() {
@Override
public void onMySuccess(String data) {
GloableParams.ListGroupInfos = JSON.parseArray(data, GroupInfo.class);
for (GroupInfo group : GloableParams.ListGroupInfos) {
if (db.findById(group.getId(), GroupInfo.class) != null)
db.deleteById(GroupInfo.class, group.getId());
db.save(group);
GloableParams.GroupInfos.put(group.getGroup_id(), group);
}
sendBrodcast("GroupList");
}
@Override
public void onMyFailure() {
// initGroupList();
}
});
}
use of com.juns.wechat.bean.GroupInfo 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();
}
Aggregations