Пример #1
0
  public void update() {
    if (feedURL == null) {
      System.out.println("ERROR - URL for id " + ID + " was not found, removing feed.");
      throw new NullPointerException("URL is null");
    }
    SyndFeed feed = RSSUtil.getElements(feedURL);
    lastCheck = System.currentTimeMillis();

    // Check if there is anything new to add
    if (feed.getEntries().get(0).getPublishedDate().getTime() > lastDate) {
      SyndEntry[] entries = RSSUtil.getNewEntries(feed.getEntries(), lastDate);
      ArrayUtils.reverse(entries);

      notifySubscribers(entries);

      // Update time
      lastDate = feed.getEntries().get(0).getPublishedDate().getTime();
    }
  }
Пример #2
0
  public RSSSubscription(
      URL url, String id, ArrayList<String> subscriber, long lastDate, long lastCheck) {
    SyndFeed feed = RSSUtil.getElements(url);

    if (feed != null) {
      feedURL = url;
      ID = id;

      title = feed.getTitle();
      // Assume the first element is the newest and get the date
      this.lastDate =
          lastDate == -1 ? feed.getEntries().get(0).getPublishedDate().getTime() : lastDate;
      this.lastCheck = lastCheck == -1 ? System.currentTimeMillis() : lastCheck;

      subscribers = subscriber;

      System.out.println("Successfully added RSS: " + url.toString());
    } else {
      System.out.println("Unable to add RSS: " + url.toString());
    }
  }