本文整理汇总了Java中org.jivesoftware.smack.RosterGroup.addEntry方法的典型用法代码示例。如果您正苦于以下问题:Java RosterGroup.addEntry方法的具体用法?Java RosterGroup.addEntry怎么用?Java RosterGroup.addEntry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smack.RosterGroup
的用法示例。
在下文中一共展示了RosterGroup.addEntry方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addUserToGroup
import org.jivesoftware.smack.RosterGroup; //导入方法依赖的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));
}
}
}
示例2: addUserToGroup
import org.jivesoftware.smack.RosterGroup; //导入方法依赖的package包/类
/**
* 把一个好友添加到一个组中
* @param userJid
* @param groupName
*/
public static void addUserToGroup(final String userJid, final String groupName,
final XMPPConnection connection) {
RosterGroup group = connection.getRoster().getGroup(groupName);
// 这个组已经存在就添加到这个组,不存在创建一个组
RosterEntry entry = connection.getRoster().getEntry(userJid);
try {
if (group != null) {
if (entry != null)
group.addEntry(entry);
} else {
RosterGroup newGroup = connection.getRoster().createGroup("我的好友");
if (entry != null)
newGroup.addEntry(entry);
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例3: tryToMoveRosterEntryToGroup
import org.jivesoftware.smack.RosterGroup; //导入方法依赖的package包/类
private void tryToMoveRosterEntryToGroup(String userName, String groupName)
throws XXException {
mRoster = mXMPPConnection.getRoster();
RosterGroup rosterGroup = getRosterGroup(groupName);
RosterEntry rosterEntry = mRoster.getEntry(userName);
removeRosterEntryFromGroups(rosterEntry);
if (groupName.length() == 0)
return;
else {
try {
rosterGroup.addEntry(rosterEntry);
} catch (XMPPException e) {
throw new XXException(e.getLocalizedMessage());
}
}
}
示例4: tryToMoveRosterEntryToGroup
import org.jivesoftware.smack.RosterGroup; //导入方法依赖的package包/类
private void tryToMoveRosterEntryToGroup(String userName, String groupName)
throws AppException {
mRoster = mXMPPConnection.getRoster();
RosterGroup rosterGroup = getRosterGroup(groupName);
RosterEntry rosterEntry = mRoster.getEntry(userName);
removeRosterEntryFromGroups(rosterEntry);
if (groupName.length() == 0)
return;
else {
try {
rosterGroup.addEntry(rosterEntry);
} catch (XMPPException e) {
throw new AppException(e.getLocalizedMessage());
}
}
}
示例5: tryToMoveRosterEntryToGroup
import org.jivesoftware.smack.RosterGroup; //导入方法依赖的package包/类
private void tryToMoveRosterEntryToGroup(String userName, String groupName)
throws YaximXMPPException {
RosterGroup rosterGroup = getRosterGroup(groupName);
RosterEntry rosterEntry = mRoster.getEntry(userName);
removeRosterEntryFromGroups(rosterEntry);
if (groupName.length() == 0)
return;
else {
try {
rosterGroup.addEntry(rosterEntry);
} catch (XMPPException e) {
throw new YaximXMPPException(e.getLocalizedMessage());
}
}
}
示例6: addUserToGroup
import org.jivesoftware.smack.RosterGroup; //导入方法依赖的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));
}
}
示例7: addContactToGroup
import org.jivesoftware.smack.RosterGroup; //导入方法依赖的package包/类
@Override
public void addContactToGroup(String groupName, String jid) throws RemoteException {
createGroup(groupName);
RosterGroup group = mAdaptee.getGroup(groupName);
try {
group.addEntry(mAdaptee.getEntry(jid));
} catch (XMPPException e) {
e.printStackTrace();
}
}
示例8: addContactItem
import org.jivesoftware.smack.RosterGroup; //导入方法依赖的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();
}
示例9: addEntry
import org.jivesoftware.smack.RosterGroup; //导入方法依赖的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;
}