/** * UI级添加分组 */ public void addGroupNamesUi(String newGroupName) { groupNames.add(newGroupName); newNames.add(newGroupName); MRosterGroup mg = new MRosterGroup(newGroupName, new ArrayList<User>()); rGroups.add(rGroups.size() - 1, mg); expandAdapter.setContacter(rGroups); expandAdapter.notifyDataSetChanged(); }
/** * UI级移动用户,把用户加入某组 */ private void addUserGroupUI(User user, String groupName) { for (MRosterGroup g : rGroups) { if (groupName.equals(g.getName())) { List<User> users = g.getUsers(); users.add(user); g.setUsers(users); } } expandAdapter.setContacter(rGroups); expandAdapter.notifyDataSetChanged(); }
/** * UI级删除用户 */ private void deleteUserUI(User user) { for (MRosterGroup g : rGroups) { List<User> us = g.getUsers(); if (us != null && us.size() > 0) { if (us.contains(user)) { us.remove(user); g.setUsers(us); } } } expandAdapter.setContacter(rGroups); expandAdapter.notifyDataSetChanged(); }
/** * UI更改组名 */ private void updateGroupNameUI(String old, String newGroupName) { if (StringUtil.empty(old) || Constant.ALL_FRIEND.equals(old) || Constant.NO_GROUP_FRIEND.equals(old)) { return; } if (StringUtil.empty(newGroupName) || Constant.ALL_FRIEND.equals(newGroupName) || Constant.NO_GROUP_FRIEND.equals(newGroupName)) { return; } if (newNames.contains(old)) { newNames.remove(old); newNames.add(newGroupName); return; } for (MRosterGroup g : rGroups) { if (g.getName().equals(old)) { g.setName(newGroupName); } } expandAdapter.notifyDataSetChanged(); }
/** * UI级移动用户,把用户移除某组 */ private void removeUserFromGroupUI(User user) { for (MRosterGroup g : rGroups) { if (g.getUsers().contains(user)) { if (StringUtil.notEmpty(g.getName()) && !Constant.ALL_FRIEND.equals(g.getName())) { List<User> users = g.getUsers(); users.remove(user); g.setUsers(users); } } } expandAdapter.setContacter(rGroups); expandAdapter.notifyDataSetChanged(); }
/** * 刷新当前的列表 */ private void refreshList() { /** 刷新好友列表 */ rGroups = ContacterManager.getGroups(XmppConnectionManager .getInstance().getConnection().getRoster()); for (String newGroupName : newNames) { MRosterGroup mg = new MRosterGroup(newGroupName, new ArrayList<User>()); rGroups.add(rGroups.size() - 1, mg); } expandAdapter.setContacter(rGroups); expandAdapter.notifyDataSetChanged(); /** 刷新最近联系人列表 */ inviteNotices = MessageManager.getInstance(this) .getRecentContactsWithLastMsg(); noticeAdapter.setNoticeList(inviteNotices); noticeAdapter.notifyDataSetChanged(); /** * 有新消息进来的气泡设置 */ setPaoPao(); }