Exemplo n.º 1
0
  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);
  }
Exemplo n.º 2
0
 public List<String> getAllReadingListItemsLinks() {
   List<String> links = new ArrayList<String>();
   if (this.greaderlistItems != null && this.greaderlistItems.size() != 0) {
     for (GreaderListItem greaderlistItem : this.greaderlistItems)
       links.add(greaderlistItem.getLink());
     return links;
   } else return null;
 }