本文整理汇总了Java中org.jivesoftware.smack.Roster.getGroup方法的典型用法代码示例。如果您正苦于以下问题:Java Roster.getGroup方法的具体用法?Java Roster.getGroup怎么用?Java Roster.getGroup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smack.Roster
的用法示例。
在下文中一共展示了Roster.getGroup方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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));
}
}
}
示例2: getEntrysByGroup
import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
* 获取某一个分组的成员
*
* @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;
}
示例3: removeContactFromGroup
import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
* Removes a contact item from the group.
*
* @param item the ContactItem to remove.
*/
private void removeContactFromGroup(ContactItem item) {
String groupName = item.getGroupName();
ContactGroup contactGroup = getContactGroup(groupName);
Roster roster = SparkManager.getConnection().getRoster();
RosterEntry entry = roster.getEntry(item.getJID());
if (entry != null && contactGroup != offlineGroup) {
try {
RosterGroup rosterGroup = roster.getGroup(groupName);
if (rosterGroup != null) {
RosterEntry rosterEntry = rosterGroup.getEntry(entry.getUser());
if (rosterEntry != null) {
rosterGroup.removeEntry(rosterEntry);
}
}
contactGroup.removeContactItem(contactGroup.getContactItemByJID(item.getJID()));
checkGroup(contactGroup);
}
catch (Exception e) {
Log.error("Error removing user from contact list.", e);
}
}
}
示例4: TransferGroupUI
import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
public TransferGroupUI(String groupName) {
setLayout(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 0, true, false));
setBackground(Color.white);
final Roster roster = SparkManager.getConnection().getRoster();
final RosterGroup rosterGroup = roster.getGroup(groupName);
final List<RosterEntry> entries = new ArrayList<RosterEntry>(rosterGroup.getEntries());
Collections.sort(entries, entryComparator);
for (RosterEntry entry : entries) {
final UserEntry userEntry = new UserEntry(entry);
userEntries.add(userEntry);
add(userEntry);
}
}
示例5: getRosterEntrysForGroup
import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
* 获取某个分组下的所有好友
* @param xmppConnection
* @param groupName
* @return
*/
public static List<RosterEntry> getRosterEntrysForGroup(XMPPConnection xmppConnection,String groupName){
// 获取花名册对象
Roster roster = xmppConnection.getRoster();
// 获取所有好友
RosterGroup rosterGroup = roster.getGroup(groupName);
Collection<RosterEntry> rosterEntries = rosterGroup.getEntries();
return rosterEntries.stream().collect(Collectors.toList());
}
示例6: getEntriesByGroup
import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
* 返回相应(groupName)组里的所有用户<RosterEntry>
* @return List(RosterEntry)
*/
public static List<RosterEntry> getEntriesByGroup(Roster roster,
String groupName) {
List<RosterEntry> EntriesList = new ArrayList<RosterEntry>();
RosterGroup rosterGroup = roster.getGroup(groupName);
Collection<RosterEntry> rosterEntry = rosterGroup.getEntries();
Iterator<RosterEntry> i = rosterEntry.iterator();
while (i.hasNext())
EntriesList.add(i.next());
return EntriesList;
}
示例7: getDeviceNamesOnline
import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
* Gets the device names online.
*
* @param deviceType
* the device type
* @return the device names online
*/
public List<String> getDeviceNamesOnline(String deviceType)
{
List<String> list = new ArrayList<String>();
if (connection == null)
{
return list;
}
Roster roster = connection.getRoster();
if (roster == null)
{
return list;
}
try
{
RosterGroup rg = roster.getGroup(deviceType);
for (RosterEntry re : rg.getEntries())
{
Presence p = connection.getRoster().getPresence(re.getUser());
if (p.isAvailable())
{
list.add(re.getName());
}
}
}
catch (NullPointerException e)
{
}
return list;
}
示例8: 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));
}
}
示例9: doRemoveContactFromListAsync
import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
@Override
protected void doRemoveContactFromListAsync(Contact contact, ContactList list) {
// FIXME synchronize this to executor thread
if (mConnection == null)
return;
Roster roster = mConnection.getRoster();
String address = contact.getAddress().getAddress();
try {
RosterGroup group = roster.getGroup(list.getName());
if (group == null) {
debug(TAG, "could not find group " + list.getName() + " in roster");
return;
}
RosterEntry entry = roster.getEntry(address);
if (entry == null) {
debug(TAG, "could not find entry " + address + " in group " + list.getName());
//just ignore it then
}
else
{
// Remove from Roster if this is the last group
if (entry.getGroups().size() <= 1)
roster.removeEntry(entry);
group.removeEntry(entry);
}
} catch (XMPPException e) {
debug(TAG, "remove entry failed: " + e.getMessage());
throw new RuntimeException(e);
}
//otherwise, send unsub message and delete from local contact database
org.jivesoftware.smack.packet.Presence response = new org.jivesoftware.smack.packet.Presence(
org.jivesoftware.smack.packet.Presence.Type.unsubscribed);
response.setTo(address);
sendPacket(response);
notifyContactListUpdated(list, ContactListListener.LIST_CONTACT_REMOVED, contact);
}
示例10: 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;
}
示例11: getEntrysByGroup
import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
* ��ȡijһ������ij�Ա
*
* @param roster
* @param groupName
* @return
*/
public List<RosterEntry> getEntrysByGroup(Roster roster, String groupName) {
List<RosterEntry> list = new ArrayList<RosterEntry>();
RosterGroup group = roster.getGroup(groupName);
list.addAll(group.getEntries());
return list;
}