本文整理汇总了Java中org.jivesoftware.smack.roster.Roster.getEntry方法的典型用法代码示例。如果您正苦于以下问题:Java Roster.getEntry方法的具体用法?Java Roster.getEntry怎么用?Java Roster.getEntry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smack.roster.Roster
的用法示例。
在下文中一共展示了Roster.getEntry方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeFromRoster
import org.jivesoftware.smack.roster.Roster; //导入方法依赖的package包/类
public boolean removeFromRoster(JID jid) {
if (!this.isConnected()) {
LOGGER.info("not connected");
return false;
}
Roster roster = Roster.getInstanceFor(mConn);
RosterEntry entry = roster.getEntry(jid.toBareSmack());
if (entry == null) {
LOGGER.info("can't find roster entry for jid: "+jid);
return true;
}
try {
// blocking
roster.removeEntry(entry);
} catch (SmackException.NotLoggedInException |
SmackException.NoResponseException |
XMPPException.XMPPErrorException |
SmackException.NotConnectedException |
InterruptedException ex) {
LOGGER.log(Level.WARNING, "can't remove contact from roster", ex);
return false;
}
return true;
}
示例2: updateRosterEntry
import org.jivesoftware.smack.roster.Roster; //导入方法依赖的package包/类
public void updateRosterEntry(JID jid, String newName) {
if (!this.isConnected()) {
LOGGER.info("not connected");
return;
}
Roster roster = Roster.getInstanceFor(mConn);
RosterEntry entry = roster.getEntry(jid.toBareSmack());
if (entry == null) {
LOGGER.warning("can't find roster entry for jid: "+jid);
return;
}
try {
entry.setName(newName);
} catch (SmackException.NotConnectedException |
SmackException.NoResponseException |
XMPPException.XMPPErrorException |
InterruptedException ex) {
LOGGER.log(Level.WARNING, "can't set name for entry", ex);
}
}
示例3: removeContact
import org.jivesoftware.smack.roster.Roster; //导入方法依赖的package包/类
public void removeContact(String remoteAccount) {
try {
Roster roster = Roster.getInstanceFor(mConnection);
RosterEntry entry = roster.getEntry(remoteAccount);
roster.removeEntry(entry);
clearConversationsWith(remoteAccount);
XmppServiceBroadcastEventEmitter.broadcastContactRemoved(remoteAccount);
} catch (Exception exc) {
Logger.error(TAG, "Error while removing contact: " + remoteAccount, exc);
}
}
示例4: renameContact
import org.jivesoftware.smack.roster.Roster; //导入方法依赖的package包/类
public void renameContact(String remoteAccount, String newAlias) {
try {
Roster roster = Roster.getInstanceFor(mConnection);
RosterEntry entry = roster.getEntry(remoteAccount);
entry.setName(newAlias);
XmppServiceBroadcastEventEmitter.broadcastContactRenamed(remoteAccount, newAlias);
} catch (Exception exc) {
Logger.error(TAG, "Error while renaming contact: " + remoteAccount, exc);
}
}
示例5: entriesUpdated
import org.jivesoftware.smack.roster.Roster; //导入方法依赖的package包/类
@Override
public void entriesUpdated(Collection<String> addresses) {
if (addresses == null || addresses.isEmpty()) {
return;
}
Roster roster = Roster.getInstanceFor(mConnection);
if (roster == null) {
Logger.info(TAG, "entriesUpdated - No roster instance, skipping rebuild roster");
return;
}
ArrayList<XmppRosterEntry> entries = getRosterEntries();
if (entries == null || entries.isEmpty()) {
Logger.info(TAG, "entriesUpdated - No roster entries. Skipping rebuild roster");
return;
}
for (String destination : addresses) {
destination = getXmppJid(destination);
RosterEntry entry = roster.getEntry(destination);
XmppRosterEntry xmppRosterEntry = getRosterEntryFor(roster, entry);
int index = entries.indexOf(xmppRosterEntry);
if (index < 0) {
entries.add(xmppRosterEntry);
} else {
entries.set(index, xmppRosterEntry);
}
}
Collections.sort(entries);
XmppServiceBroadcastEventEmitter.broadcastRosterChanged();
}
示例6: getRosterEntry
import org.jivesoftware.smack.roster.Roster; //导入方法依赖的package包/类
RosterEntry getRosterEntry(BareJid jid) {
Roster roster = getRoster();
return (roster != null) ? roster.getEntry(jid) : null;
}