@Override protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attMap, List<? extends PacketExtension> content) { return new EventElement(EventElementType.valueOf(content.get(0) .getElementName()), (NodeExtension) content.get(0)); }
private void receiveBlogPosts() { PEPManager pepManager = PEPManager.getInstanceFor(mXMPPConnection); pepManager.addPEPListener(new PEPListener() { @Override public void eventReceived(EntityBareJid entityBareJid, EventElement eventElement, Message message) { if (EventElementType.items == eventElement.getEventType()) { ItemsExtension itemsExtension = (ItemsExtension) eventElement.getExtensions().get(0); PayloadItem payloadItem = (PayloadItem) itemsExtension.getItems().get(0); PostEntryExtension postEntryExtension = (PostEntryExtension) payloadItem.getPayload(); String id = postEntryExtension.getId(); String jid = entityBareJid.toString(); String title = postEntryExtension.getTitle(); Date published = postEntryExtension.getPublished(); Date updated = postEntryExtension.getUpdated(); BlogPost blogPost = new BlogPost(id, jid, null, title, published, updated); RealmManager.getInstance().saveBlogPost(blogPost); String commentsNode = PublishCommentExtension.NODE + "/" + id; ServiceDiscoveryManager.getInstanceFor(mXMPPConnection).addFeature(commentsNode + "+notify"); notifyNewBlogPost(); } } private void notifyNewBlogPost() { MangostaApplication mangostaApplication = MangostaApplication.getInstance(); if (mangostaApplication.isClosed()) { BlogPostNotifications.newBlogPostNotification(); } else { mangostaApplication.getCurrentActivity().runOnUiThread(new Runnable() { @Override public void run() { new Event(Event.Type.BLOG_POST_CREATED).post(); } }); } } }); }
@Override protected EventElement createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attMap, List<? extends ExtensionElement> content) { return new EventElement(EventElementType.valueOf(content.get(0).getElementName()), (NodeExtension)content.get(0)); }
@Override protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attMap, List<? extends PacketExtension> content) { return new EventElement(EventElementType.valueOf(content.get(0).getElementName()), (NodeExtension)content.get(0)); }