Java Code Examples for org.jivesoftware.smack.Roster#getGroup()

The following examples show how to use org.jivesoftware.smack.Roster#getGroup() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XmppTool.java    From xmpp with Apache License 2.0 6 votes vote down vote up
/**
 * 添加到分组
 *
 * @param
 * @param userName
 * @param groupName
 */
public void addUserToGroup(String userName, String groupName) {
    Roster roster = con.getRoster();
    RosterGroup group = roster.getGroup(groupName);
    if (null == group) {
        group = roster.createGroup(groupName);
    }
    RosterEntry entry = roster.getEntry(userName);
    if (entry != null) {
        try {
            group.addEntry(entry);
        } catch (XMPPException e) {
            SLog.e(tag, Log.getStackTraceString(e));
        }
    }

}
 
Example 2
Source File: XmppTool.java    From xmpp with Apache License 2.0 6 votes vote down vote up
/**
 * 获取某一个分组的成员
 *
 * @param
 * @param groupName
 * @return
 */
public List<RosterEntry> getEntrysByGroup(String groupName) {

    Roster roster = getCon().getRoster();
    List<RosterEntry> list = new ArrayList<RosterEntry>();
    RosterGroup group = roster.getGroup(groupName);
    Collection<RosterEntry> rosterEntiry = group.getEntries();
    Iterator<RosterEntry> iter = rosterEntiry.iterator();
    while (iter.hasNext()) {
        RosterEntry entry = iter.next();
        SLog.i("xmpptool", entry.getUser() + "\t" + entry.getName() + entry.getType().toString());
        if (entry.getType().toString().equals("both")) {
            list.add(entry);
        }

    }
    return list;

}
 
Example 3
Source File: XmppManager.java    From weixin with Apache License 2.0 5 votes vote down vote up
/**
 * 获得某个组里面的所有好友
 * 
 * @param roster
 * @param groupName 组名
 * @return
 */
public List<RosterEntry> getEntriesByGroup(Roster roster, String groupName) {
	List<RosterEntry> entriesList = new ArrayList<RosterEntry>();
	RosterGroup rosterGroup = roster.getGroup(groupName);
	Collection<RosterEntry> rosterEntries = rosterGroup.getEntries();
	Iterator<RosterEntry> i = rosterEntries.iterator();
	while (i.hasNext()) {
		entriesList.add(i.next());
	}
	return entriesList;
}