private void initData() { try { /** 获取好友列表 */ groupNames = ContacterManager.getGroupNames(XmppConnectionManager .getInstance().getConnection().getRoster()); rGroups = ContacterManager.getGroups(XmppConnectionManager .getInstance().getConnection().getRoster()); /** 获取聊天室列表 */ Iterator<?> it = ServiceDiscoveryManager .getInstanceFor( XmppConnectionManager.getInstance().getConnection()) .discoverItems("conference.wangxc").getItems(); while (it.hasNext()) { DiscoverItems.Item item = (DiscoverItems.Item) it.next(); chatRoomList.add(item); roomNames.add(item.getName()); } } catch (Exception e) { groupNames = new ArrayList<String>(); rGroups = new ArrayList<MRosterGroup>(); } }
/** * 刷新当前的列表 */ 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(); }