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


Java PayloadItem.getPayload方法代码示例

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


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

示例1: eventReceived

import org.jivesoftware.smackx.pubsub.PayloadItem; //导入方法依赖的package包/类
@Override
public void eventReceived(String from, String node, List<Item> items) {
    if (!"urn:xmpp:avatar:metadata".equals(node))
	return;
    Item i = items.get(0);
    if (i instanceof PayloadItem) {
	PayloadItem<PacketExtension> pi = (PayloadItem<PacketExtension>) i;
	PacketExtension ex = pi.getPayload();
	if (ex instanceof AvatarMetadataExtension) {
	    AvatarMetadataExtension ext = (AvatarMetadataExtension) ex;
	    String id = i.getId();
	    List<Info> infos = ext.getInfos();
	    if (infos.size() > 0 && mAutoDownload) {
		Info info = selectAvatar(infos);
		if (!mCache.contains(id))
		    downloadAvatar(from, id, info);
	    }
	    fireListeners(from, id, infos);
	}
    }
}
 
开发者ID:BoogieMAN2K,项目名称:Beem,代码行数:22,代码来源:AvatarManager.java

示例2: handlePublishedItems

import org.jivesoftware.smackx.pubsub.PayloadItem; //导入方法依赖的package包/类
/**
 * Item handler of this data handler implementation. Checks if received items are already cached,
 * if not, it caches them. Ultimately it sends the items to the subscribed listeners.
 */
@Override
public void handlePublishedItems(ItemPublishEvent<PayloadItem<SimplePayload>> items){
	String spaceId = getSpaceId(items.getNodeId());
	if (spaceId == null) return;
	List<String> toRequest = new ArrayList<String>();
	for (PayloadItem<SimplePayload> item:items.getItems()){
       	if (item.getPayload() == null && !pendingPayloadRequests.containsKey(item.getId())){
       		toRequest.add(item.getId());
       		continue;
       	}
       	DataObject obj = parseItemToDataObject(item);
       	if (dataObjectFilter == null || dataObjectFilter.isDataObjectValid(obj)) {
			if (!datawrapper.isDataObjectAlreadyCached(item.getId())){
				datawrapper.saveDataObject(items.getNodeId(), obj, item.getId());
			}
			for (DataObjectListener listener:listeners){
				listener.handleDataObject(obj, spaceId);
			}
		}
	}
	if (!toRequest.isEmpty()){
		for (String id:toRequest){
			try {
				retrievePayload(items.getNodeId(), id);
			} catch (Exception e) {
				//Ignore
				continue;
			}
		}
	}
}
 
开发者ID:MirrorIP,项目名称:msf-spaces-sdk-android,代码行数:36,代码来源:DataHandler.java

示例3: processMetadataEvent

import org.jivesoftware.smackx.pubsub.PayloadItem; //导入方法依赖的package包/类
void processMetadataEvent(JID jid, ItemsExtension itemsExt) {
    List<? extends ExtensionElement> items = itemsExt.getItems();
    if (items.isEmpty()) {
        LOGGER.warning("no items in items event");
        return;
    }

    // there should be only one item
    ExtensionElement e = items.get(0);
    if (!(e instanceof PayloadItem)) {
        LOGGER.warning("element not a payloaditem");
        return;
    }

    PayloadItem item = (PayloadItem) e;
    ExtensionElement metadataExt = item.getPayload();
    if (!(metadataExt instanceof AvatarMetadataExtension)) {
        LOGGER.warning("payload not avatar metadata");
        return;
    }
    AvatarMetadataExtension metadata = (AvatarMetadataExtension) metadataExt;
    List<AvatarMetadataExtension.Info> infos = metadata.getInfos();
    if (infos.isEmpty()) {
        // this means the contact disabled avatar publishing
        mHandler.onNotify(jid, "");
        return;
    }
    // assuming infos are always in the same order
    for (AvatarMetadataExtension.Info info : infos) {
        if (AvatarHandler.SUPPORTED_TYPES.contains(info.getType())) {
            mHandler.onNotify(jid, info.getId());
            break;
        } else {
            LOGGER.info("image type not supported: "+info.getType());
        }
    }
}
 
开发者ID:kontalk,项目名称:desktopclient-java,代码行数:38,代码来源:AvatarSendReceiver.java

示例4: getAvatar

import org.jivesoftware.smackx.pubsub.PayloadItem; //导入方法依赖的package包/类
@Override
   public byte[] getAvatar() {
try {
    LeafNode node = mPubsub.getPEPNode(AVATARDATANODE);
    List<Item> items = node.getItems(Arrays.asList(mId));
    PayloadItem<AvatarExtension> item = (PayloadItem<AvatarExtension>) items.get(0);
    AvatarExtension avatar = item.getPayload();
    return avatar.getData();
} catch (XMPPException e) {
    return null;
}
   }
 
开发者ID:BoogieMAN2K,项目名称:Beem,代码行数:13,代码来源:XmppAvatarRetriever.java


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