当前位置: 首页>>代码示例>>Java>>正文


Java Roster.createGroup方法代码示例

本文整理汇总了Java中org.jivesoftware.smack.Roster.createGroup方法的典型用法代码示例。如果您正苦于以下问题:Java Roster.createGroup方法的具体用法?Java Roster.createGroup怎么用?Java Roster.createGroup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jivesoftware.smack.Roster的用法示例。


在下文中一共展示了Roster.createGroup方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addUserToGroup

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
 * 添加到分组
 *
 * @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));
        }
    }

}
 
开发者ID:jiangzehui,项目名称:xmpp,代码行数:24,代码来源:XmppTool.java

示例2: addGroup

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/** * ���һ���� */
public static boolean addGroup(Roster roster, String groupName) {
	try {
		roster.createGroup(groupName);
		return true;
	} catch (Exception e) {
		e.printStackTrace();
		return false;
	}
}
 
开发者ID:jiangzehui,项目名称:xmpp,代码行数:11,代码来源:XmppTool.java

示例3: addGroup

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/** 
    * 创建一个组 
    */ 
public static boolean addGroup(Roster roster,String groupName)  
   {  
       try {  
           roster.createGroup(groupName);  
           return true;  
       } catch (Exception e) {  
           e.printStackTrace();  
           Log.e("jj", "创建分组异常:"+e.getMessage());
           return false;  
       }  
   }
 
开发者ID:cowthan,项目名称:AyoSunny,代码行数:15,代码来源:XmppUtil.java

示例4: addGroup

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
 * ��ӷ���
 * 
 * @param roster
 * @param groupName
 * @return
 */
public boolean addGroup(Roster roster, String groupName) {
	try {
		roster.createGroup(groupName);
		return true;
	} catch (Exception e) {
		SLog.e(tag, Log.getStackTraceString(e));
	}
	return false;
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:17,代码来源:XmppConnectionManager.java

示例5: addUserToGroup

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
 * ��ӵ�����
 * 
 * @param roster
 * @param userName
 * @param groupName
 */
public void addUserToGroup(Roster roster, String userName, String groupName) {
	RosterGroup group = roster.getGroup(groupName);
	if (null == group) {
		group = roster.createGroup(groupName);
	}
	RosterEntry entry = roster.getEntry(userName);
	try {
		group.addEntry(entry);
	} catch (XMPPException e) {
		SLog.e(tag, Log.getStackTraceString(e));
	}
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:20,代码来源:XmppConnectionManager.java

示例6: addContactItem

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
private void addContactItem(final ContactGroup contactGroup, final ContactItem item) {
    ContactItem newContact = UIComponentRegistry.createContactItem(Res.getString("group.empty"), null, null);
    newContact.setPresence(item.getPresence());
    newContact.setIcon(item.getIcon());
    newContact.getNicknameLabel().setFont(item.getNicknameLabel().getFont());

    if (!PresenceManager.isOnline(item.getJID())) {
        contactGroup.addOfflineContactItem(item.getAlias(), item.getNickname(), item.getJID(), null);
    }
    else {
        contactGroup.addContactItem(newContact);
    }
    contactGroup.clearSelection();
    contactGroup.fireContactGroupUpdated(); //Updating group title

    final ContactGroup oldGroup = getContactGroup(item.getGroupName());

    SwingWorker worker = new SwingWorker() {
        public Object construct() {
            Roster roster = SparkManager.getConnection().getRoster();
            RosterEntry entry = roster.getEntry(item.getJID());

            RosterGroup groupFound = null;

            for (RosterGroup group : roster.getGroups()) {
                if (group.getName().equals(contactGroup.getGroupName())) {
                    try {
                        groupFound = group;
                        group.addEntry(entry);
                    }
                    catch (XMPPException e1) {
                        Log.error(e1);
                        return false;
                    }
                }
            }

            // This is a new group
            if (groupFound == null) {
                groupFound = roster.createGroup(contactGroup.getGroupName());
                try {
                    groupFound.addEntry(entry);
                }
                catch (XMPPException e) {
                    Log.error(e);
                }
            }
            return true;
        }

        public void finished() {
            if ((Boolean)get()) {
                // Now try and remove the group from the old one.
                removeContactItem(oldGroup, item);
            }
        }

    };

    worker.start();
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:62,代码来源:ContactGroupTransferHandler.java

示例7: addEntry

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
 * Adds a new entry to the users Roster.
 *
 * @param jid      the jid.
 * @param nickname the nickname.
 * @param group    the contact group.
 * @return the new RosterEntry.
 */
public RosterEntry addEntry(String jid, String nickname, String group) {
    String[] groups = {group};

    Roster roster = SparkManager.getConnection().getRoster();
    RosterEntry userEntry = roster.getEntry(jid);

    boolean isSubscribed = true;
    if (userEntry != null) {
        isSubscribed = userEntry.getGroups().size() == 0;
    }

    if (isSubscribed) {
        try {
            roster.createEntry(jid, nickname, new String[]{group});
        }
        catch (XMPPException e) {
            Log.error("Unable to add new entry " + jid, e);
        }
        return roster.getEntry(jid);
    }


    try {
        RosterGroup rosterGroup = roster.getGroup(group);
        if (rosterGroup == null) {
            rosterGroup = roster.createGroup(group);
        }

        if (userEntry == null) {
            roster.createEntry(jid, nickname, groups);
            userEntry = roster.getEntry(jid);
        }
        else {
            userEntry.setName(nickname);
            rosterGroup.addEntry(userEntry);
        }

        userEntry = roster.getEntry(jid);
    }
    catch (XMPPException ex) {
        Log.error(ex);
    }
    return userEntry;
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:53,代码来源:SubscriptionDialog.java


注:本文中的org.jivesoftware.smack.Roster.createGroup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。