private void requestReadingList() throws HttpException, IOException { if (!this.isRight()) return; int originalSize = 0; if (feed != null) { items = feed.getItems(); originalSize = items.size(); } String url = "https://www.google.com/reader/atom/user/-/state/com.google/reading-list?n=" + String.valueOf(pagenumber * everypage); HttpClient httpclient = new DefaultHttpClient(); getreadinglistmethod = new HttpGet(url); getreadinglistmethod.setHeader("Authorization", "GoogleLogin auth=" + auth); getreadinglistmethod.setHeader("Cookie", "SID=" + sid); getreadinglistmethod.setHeader("accept-encoding", "gzip, deflate"); HttpResponse response = null; response = httpclient.execute(getreadinglistmethod); int result = response.getStatusLine().getStatusCode(); // Log.d("GOOGLE_READER", "load result"+result); if (result >= 200 && result <= 299) { RssParser rp = new RssParser(response.getEntity().getContent()); // //System.out.println("++++++++++"); // //System.out.println((rp != null ? 1 : 0)); rp.parse(); feed = rp.getFeed(); try { items = feed.getItems(); if (items.size() == originalSize) { throw new NoMoreStatusException(); } } catch (Exception e) { e.printStackTrace(); throw new NoNetworkException(e); } greaderlistItems = new ArrayList<GreaderListItem>(); for (RssParser.Item item : items) { { GreaderListItem greaderlistItem = new GreaderListItem(); greaderlistItem.setId(item.id); greaderlistItem.setTitle(item.title); greaderlistItem.setLink(item.link); greaderlistItem.setAuthor(item.author); greaderlistItems.add(greaderlistItem); } } fromindex = (pagenumber - 1) * everypage; pagenumber += 1; lastModified = new Date(); // this.getreadingliststring=getreadinglistmethod.getResponseBodyAsString(); } else { throw new NoNetworkException(); } releaseReadingList(getreadinglistmethod); }
@Override protected RssItem doInBackground(RssParser... params) { RssParser parser = params[0]; RssItem item = null; try { SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = spf.newSAXParser(); XMLReader xr = sp.getXMLReader(); xr.setContentHandler(parser); // chamar arquivo xml // xr.parse(new InputSource(activity.getAssets().open("image_of_the_day.xml"))); // chamar link na internet URL url = new URL("http://www.nasa.gov/rss/dyn/image_of_the_day.rss"); xr.parse(new InputSource(url.openConnection().getInputStream())); item = parser.getFirstItem(); if (item != null) { /*item.setImagem( BitmapFactory.decodeResource( activity.getResources(), R.drawable.image_of_the_day));*/ item.setImagem(getBitmap(item.getImagemUrl())); } } catch (Exception e) { e.printStackTrace(); } return item; }
private String parseFeed(JDFeedMeFeed feed, String timestamp, String content) throws Exception { String new_timestamp = timestamp; boolean found_new_posts = false; // parse the rss xml RssParser feed_parser = new RssParser(feed); feed_parser.parseContent(content); int feed_item_number = 0; JDFeedMePost post = null; while ((post = feed_parser.getPost()) != null) { feed_item_number++; // get the original description String post_description = post.getDescription(); // originally we removed the description from the posts since posts are saved in xml and this // could become large // new feature: let's do save the description, but make it somewhat shorter (extract links // from it) post.setDescription( extractLinksFromHtml( post_description, JDFeedMeFeed.HOSTER_ANY_HOSTER, JDFeedMeFeed.HOSTER_EXCLUDE)); // handle the rss item if (post.isValid()) { boolean is_new = handlePost(feed, post, post_description, timestamp); if (is_new) found_new_posts = true; if (post.isTimestampNewer(new_timestamp)) new_timestamp = post.getTimestamp(); } else { logger.severe( "JDFeedMe rss item " + Integer.toString(feed_item_number) + " is invalid for feed: " + feed.getAddress()); } } // if found new posts, update the feed if (found_new_posts) gui.setFeedNewposts(feed, true); return new_timestamp; }
// org.openoffice.rssreader.XBungeniRSSReader: public String OpenFeed(String feedURL) { // TODO !!! // Exchange the default return implementation. // NOTE: Default initialized polymorphic structs can cause problems // because of missing default initialization of primitive types of // some C++ compilers or different Any initialization in Java and C++ // polymorphic structs. String warmedFeed = ""; try { java.net.URL obj = new URL(feedURL); m_rssParser = new RssParser(obj); // System.out.println("parsing feed"); m_rssParser.parseFeed(); // System.out.println("printing feed"); } catch (Exception ex) { java.util.logging.Logger.getLogger("global") .log(java.util.logging.Level.ALL, ex.getMessage(), ex); } finally { return warmedFeed; } }
public org.openoffice.rssreader.BungeniRssRecord[] RssRecords() { return m_rssParser.rssRecords(); }
public org.openoffice.rssreader.BungeniRssHeader RssHeader() { return m_rssParser.rssHeader(); }