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


Java RosterGroup类代码示例

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


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

示例1: getGroupView

import org.jivesoftware.smack.RosterGroup; //导入依赖的package包/类
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
    GroupHolder holder;
    if (convertView == null) {
        holder = new GroupHolder();
        convertView = LayoutInflater.from(getActivity()).inflate(R.layout.friend_group_layout, parent, false);
        holder.tv = (TextView) convertView.findViewById(R.id.textView);
        holder.iv = (ImageView) convertView.findViewById(R.id.imageView);
        convertView.setTag(holder);

    } else {
        holder = (GroupHolder) convertView.getTag();
    }

    if (isExpanded) {
        holder.iv.setImageResource(R.mipmap.friend_group_point_xia);
    } else {
        holder.iv.setImageResource(R.mipmap.friend_group_point);
    }
    RosterGroup group = (RosterGroup) getGroup(groupPosition);
    holder.tv.setText(group.getName() + "[" + childs.get(groups.get(groupPosition)).size() + "]");


    return convertView;

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

示例2: 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));
        }
    }

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

示例3: getEntrysByGroup

import org.jivesoftware.smack.RosterGroup; //导入依赖的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;

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

示例4: findFriends

import org.jivesoftware.smack.RosterGroup; //导入依赖的package包/类
public void findFriends() {
	try {
		listGroup=new ArrayList<Group>();
		XMPPConnection conn = QQApplication.xmppConnection;
		Roster roster = conn.getRoster();
		Collection<RosterGroup> groups = roster.getGroups();
		for (RosterGroup group : groups) {
			Group mygroup=new Group();
			mygroup.setGroupName(group.getName());
			Collection<RosterEntry> entries = group.getEntries();
			List<Child> childList=new ArrayList<Child>();
			for (RosterEntry entry : entries) {
				if(entry.getType().name().equals("both")){
					Child child=new Child();
					child.setUsername(entry.getUser().split("@")[0]);
					childList.add(child);
				}
			}
			mygroup.setChildList(childList);
			listGroup.add(mygroup);
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:cowthan,项目名称:AyoSunny,代码行数:26,代码来源:ConstactFragment.java

示例5: 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();
            }
}
 
开发者ID:cowthan,项目名称:AyoSunny,代码行数:24,代码来源:XmppUtil.java

示例6: addRosterEntry

import org.jivesoftware.smack.RosterGroup; //导入依赖的package包/类
/**
   * Adds a roster entry to the packet.
   *
   * @param rosterEntry a roster entry to add.
   */
  public void addRosterEntry(RosterEntry rosterEntry) {
// Obtain a String[] from the roster entry groups name 
List<String> groupNamesList = new ArrayList<String>();
String[] groupNames;
for (RosterGroup group : rosterEntry.getGroups()) {
	groupNamesList.add(group.getName());
}
groupNames = groupNamesList.toArray(new String[groupNamesList.size()]);

      // Create a new Entry based on the rosterEntry and add it to the packet
      RemoteRosterEntry remoteRosterEntry = new RemoteRosterEntry(rosterEntry.getUser(),
              rosterEntry.getName(), groupNames);

      addRosterEntry(remoteRosterEntry);
  }
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:21,代码来源:RosterExchange.java

示例7: getGroups

import org.jivesoftware.smack.RosterGroup; //导入依赖的package包/类
/**
 * ������з�����ϵ��
 * 
 * @return
 */
public static List<MRosterGroup> getGroups(Roster roster) {
	if (contacters == null)
		throw new RuntimeException("contacters is null");

	List<MRosterGroup> groups = new ArrayList<ContacterManager.MRosterGroup>();
	groups.add(new MRosterGroup(Constant.ALL_FRIEND, getContacterList()));
	for (RosterGroup group : roster.getGroups()) {
		List<User> groupUsers = new ArrayList<User>();
		for (RosterEntry entry : group.getEntries()) {
			groupUsers.add(contacters.get(entry.getUser()));
		}
		groups.add(new MRosterGroup(group.getName(), groupUsers));
	}
	groups.add(new MRosterGroup(Constant.NO_GROUP_FRIEND,
			getNoGroupUserList(roster)));
	return groups;
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:23,代码来源:ContacterManager.java

示例8: removeUserFromGroup

import org.jivesoftware.smack.RosterGroup; //导入依赖的package包/类
/**
 * ��һ�����Ѵ�����ɾ��
 * 
 * @param user
 * @param groupName
 */
public static void removeUserFromGroup(final User user,
		final String groupName, final XMPPConnection connection) {
	if (groupName == null || user == null)
		return;
	new Thread() {
		public void run() {
			RosterGroup group = connection.getRoster().getGroup(groupName);
			if (group != null) {
				try {
					System.out.println(user.getJID() + "----------------");
					RosterEntry entry = connection.getRoster().getEntry(
							user.getJID());
					if (entry != null)
						group.removeEntry(entry);
				} catch (XMPPException e) {
					e.printStackTrace();
				}
			}
		}
	}.start();
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:28,代码来源:ContacterManager.java

示例9: addGroup

import org.jivesoftware.smack.RosterGroup; //导入依赖的package包/类
/**
 * ��ӷ��� .
 * 
 * @param user
 * @param groupName
 * @param connection
 */
public static void addGroup(final String groupName,
		final XMPPConnection connection) {
	if (StringUtil.empty(groupName)) {
		return;
	}

	// ��һ��rosterEntry��ӵ�group����PacketCollector���������߳�
	new Thread() {
		public void run() {

			try {
				RosterGroup g = connection.getRoster().getGroup(groupName);
				if (g != null) {
					return;
				}
				connection.getRoster().createGroup(groupName);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}.start();
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:30,代码来源:ContacterManager.java

示例10: 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());
		}
	}
}
 
开发者ID:victoryckl,项目名称:XmppTest,代码行数:20,代码来源:SmackImpl.java

示例11: buddyCountOnlineForGroup

import org.jivesoftware.smack.RosterGroup; //导入依赖的package包/类
/**
 * Used by Velocity renderer
 * 
 * @param groupname
 * @return a String representing the online buddies out of the number of total buddies for a single group like (3/5)
 */
protected String buddyCountOnlineForGroup(final String groupname) {
    final RosterGroup rosterGroup = connection.getRoster().getGroup(groupname);
    int buddyEntries = rosterGroup.getEntryCount();
    final int allBuddies = buddyEntries;
    for (final Iterator I = rosterGroup.getEntries().iterator(); I.hasNext();) {
        final RosterEntry entry = (RosterEntry) I.next();
        final Presence presence = connection.getRoster().getPresence(entry.getUser());
        if (presence.getType() == Presence.Type.unavailable) {
            buddyEntries--;
        }
    }
    // final string looks like e.g. "(3/5)"
    final StringBuilder sb = new StringBuilder(10);
    sb.append("(");
    sb.append(buddyEntries);
    sb.append("/");
    sb.append(allBuddies);
    sb.append(")");
    return sb.toString();
}
 
开发者ID:huihoo,项目名称:olat,代码行数:27,代码来源:InstantMessagingClient.java

示例12: getRosterGroups

import org.jivesoftware.smack.RosterGroup; //导入依赖的package包/类
/**
 * 获得花名册包含的分组列表
 */
public static List<IMRosterGroup> getRosterGroups(Roster roster) {

	List<IMRosterGroup> groups = new ArrayList<IMRosterGroup>();
	groups.add(new IMRosterGroup(IMConstant.ALL_FRIEND, getContacterList()));
	for (RosterGroup group : roster.getGroups()) {
		List<IMUser> users = new ArrayList<IMUser>();
		for (RosterEntry entry : group.getEntries()) {
			users.add(contacters.get(entry.getUser()));
		}
		groups.add(new IMRosterGroup(group.getName(), users));
	}
	groups.add(new IMRosterGroup(IMConstant.NO_GROUP_FRIEND,
			getNoGroupUserList(roster)));
	return groups;
}
 
开发者ID:jingshauizh,项目名称:androidsummary,代码行数:19,代码来源:IMUtil.java

示例13: addRosterEntry

import org.jivesoftware.smack.RosterGroup; //导入依赖的package包/类
/**
 * Adds a roster entry to the packet.
 * 
 * @param rosterEntry
 *            a roster entry to add.
 */
public void addRosterEntry(RosterEntry rosterEntry) {
	// Obtain a String[] from the roster entry groups name
	List<String> groupNamesList = new ArrayList<String>();
	String[] groupNames;
	for (RosterGroup group : rosterEntry.getGroups()) {
		groupNamesList.add(group.getName());
	}
	groupNames = groupNamesList.toArray(new String[groupNamesList.size()]);

	// Create a new Entry based on the rosterEntry and add it to the packet
	RemoteRosterEntry remoteRosterEntry = new RemoteRosterEntry(
			rosterEntry.getUser(), rosterEntry.getName(), groupNames);

	addRosterEntry(remoteRosterEntry);
}
 
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:22,代码来源:RosterExchange.java

示例14: 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());
		}
	}
}
 
开发者ID:misty-rain,项目名称:smartedu,代码行数:20,代码来源:SmackImpl.java

示例15: ParcelableRoster

import org.jivesoftware.smack.RosterGroup; //导入依赖的package包/类
public ParcelableRoster(RosterEntry entry, Presence presence) {

        if(entry != null) {
            // entry data 파싱
            this.userID = entry.getUser();
            this.userName = entry.getName();
            for(RosterGroup rosterGroup : entry.getGroups()) { this.group = rosterGroup.getName(); }
        }

        if(presence != null) {
            // 접속상태 확인
            this.availablity = presence.getType().toString();
            if(availablity.equals("available")) parseStatusString( presence.getStatus() );
            if(presence.getMode() != null) this.mode = presence.getMode().toString();
        }
    }
 
开发者ID:rokoroku,项目名称:LoLMessenger,代码行数:17,代码来源:ParcelableRoster.java


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