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


Java Roster.isLoaded方法代码示例

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


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

示例1: removeContact

import org.jivesoftware.smack.roster.Roster; //导入方法依赖的package包/类
public void removeContact(String jidString)
        throws SmackException.NotLoggedInException, InterruptedException,
        SmackException.NotConnectedException, XMPPException.XMPPErrorException,
        SmackException.NoResponseException, XmppStringprepException {
    Roster roster = Roster.getInstanceFor(XMPPSession.getInstance().getXMPPConnection());
    if (!roster.isLoaded()) {
        roster.reloadAndWait();
    }

    BareJid jid = JidCreate.bareFrom(jidString);
    roster.removeEntry(roster.getEntry(jid));

    Presence presence = new Presence(Presence.Type.unsubscribe);
    presence.setTo(JidCreate.from(jidString));
    XMPPSession.getInstance().sendStanza(presence);
}
 
开发者ID:esl,项目名称:mangosta-android,代码行数:17,代码来源:RosterManager.java

示例2: addContact

import org.jivesoftware.smack.roster.Roster; //导入方法依赖的package包/类
public void addContact(String jidString)
        throws SmackException.NotLoggedInException, InterruptedException,
        SmackException.NotConnectedException, XMPPException.XMPPErrorException,
        SmackException.NoResponseException, XmppStringprepException {
    Roster roster = Roster.getInstanceFor(XMPPSession.getInstance().getXMPPConnection());
    if (!roster.isLoaded()) {
        roster.reloadAndWait();
    }

    BareJid jid = JidCreate.bareFrom(jidString);
    String name = XMPPUtils.fromJIDToUserName(jidString);
    String[] groups = new String[]{"Buddies"};

    roster.createEntry(jid, name, groups);
    roster.sendSubscriptionRequest(jid);
}
 
开发者ID:esl,项目名称:mangosta-android,代码行数:17,代码来源:RosterManager.java

示例3: listRoster

import org.jivesoftware.smack.roster.Roster; //导入方法依赖的package包/类
/**
 * creates a list of all RosterEntries
 * @return the rosterEntryArray
 */
public RosterEntry[] listRoster(){
  try{
    // get the roster and if it is not loaded reload it
    Roster roster = Roster.getInstanceFor(connection);
    if (!roster.isLoaded())
      roster.reloadAndWait();
    RosterEntry[] result = new RosterEntry[roster.getEntries().size()];
    int i = 0;
    // loop through all roster entries and append them to the array
    for (RosterEntry entry: roster.getEntries()){
      result[i++] = entry;
    }
    return result;
  }catch (Exception e){
    e.printStackTrace();
  }
  return new RosterEntry[0];
}
 
开发者ID:Nik-Sch,项目名称:ChatApp-Android,代码行数:23,代码来源:XmppManager.java

示例4: run

import org.jivesoftware.smack.roster.Roster; //导入方法依赖的package包/类
@Override
public void run(){
  Roster roster = xmppManager.getRoster();
  if (roster != null && !roster.isLoaded())
    try{
      roster.reloadAndWait();
      Log.d("SERVICE_DEBUG", "reloaded roster");
    }catch (Exception e){
      Log.e("SERVICE_ERROR", "Couldn't load the roster");
      e.printStackTrace();
    }

  if (roster != null){
    Collection<RosterEntry> entries = roster.getEntries();
    for (RosterEntry entry : entries)
      presenceReceived(roster.getPresence(entry.getUser()));
    roster.addRosterListener(rosterListener);
  }
}
 
开发者ID:Nik-Sch,项目名称:ChatApp-Android,代码行数:20,代码来源:MessageService.java

示例5: removeAllContacts

import org.jivesoftware.smack.roster.Roster; //导入方法依赖的package包/类
public void removeAllContacts()
        throws SmackException.NotLoggedInException, InterruptedException,
        SmackException.NotConnectedException, XMPPException.XMPPErrorException,
        SmackException.NoResponseException {
    Roster roster = Roster.getInstanceFor(XMPPSession.getInstance().getXMPPConnection());
    if (!roster.isLoaded()) {
        roster.reloadAndWait();
    }
    for (RosterEntry entry : roster.getEntries()) {
        roster.removeEntry(entry);
        Presence presence = new Presence(Presence.Type.unsubscribe);
        presence.setTo(entry.getJid());
        XMPPSession.getInstance().sendStanza(presence);
    }
}
 
开发者ID:esl,项目名称:mangosta-android,代码行数:16,代码来源:RosterManager.java

示例6: getContacts

import org.jivesoftware.smack.roster.Roster; //导入方法依赖的package包/类
public HashMap<Jid, Presence.Type> getContacts()
        throws SmackException.NotLoggedInException, InterruptedException,
        SmackException.NotConnectedException {
    Roster roster = Roster.getInstanceFor(XMPPSession.getInstance().getXMPPConnection());
    if (!roster.isLoaded()) {
        roster.reloadAndWait();
    }

    String groupName = "Buddies";

    RosterGroup group = roster.getGroup(groupName);

    if (group == null) {
        roster.createGroup(groupName);
        group = roster.getGroup(groupName);
    }

    HashMap<Jid, Presence.Type> buddies = new HashMap<>();

    List<RosterEntry> entries = group.getEntries();
    for (RosterEntry entry : entries) {
        BareJid jid = entry.getJid();
        Presence.Type status = roster.getPresence(jid).getType();
        buddies.put(jid, status);
    }

    return buddies;
}
 
开发者ID:esl,项目名称:mangosta-android,代码行数:29,代码来源:RosterManager.java

示例7: getContactsWithSubscriptionPending

import org.jivesoftware.smack.roster.Roster; //导入方法依赖的package包/类
public HashMap<Jid, Presence.Type> getContactsWithSubscriptionPending()
        throws SmackException.NotLoggedInException, InterruptedException,
        SmackException.NotConnectedException {
    Roster roster = Roster.getInstanceFor(XMPPSession.getInstance().getXMPPConnection());
    if (!roster.isLoaded()) {
        roster.reloadAndWait();
    }

    String groupName = "Buddies";

    RosterGroup group = roster.getGroup(groupName);

    if (group == null) {
        roster.createGroup(groupName);
        group = roster.getGroup(groupName);
    }

    HashMap<Jid, Presence.Type> buddiesPending = new HashMap<>();

    List<RosterEntry> entries = group.getEntries();
    for (RosterEntry entry : entries) {
        if (entry.isSubscriptionPending()) {
            BareJid jid = entry.getJid();
            Presence.Type status = roster.getPresence(jid).getType();
            buddiesPending.put(jid, status);
        }
    }

    return buddiesPending;
}
 
开发者ID:esl,项目名称:mangosta-android,代码行数:31,代码来源:RosterManager.java

示例8: isRosterLoaded

import org.jivesoftware.smack.roster.Roster; //导入方法依赖的package包/类
private boolean isRosterLoaded() {
    Roster roster = getRoster();
    return roster != null && roster.isLoaded();
}
 
开发者ID:kontalk,项目名称:androidclient,代码行数:5,代码来源:MessageCenterService.java


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