Package org.rssowl.core.persist

Examples of org.rssowl.core.persist.NewsCounterItem


   * @param feedLinkRef The reference to the link of the Feed.
   * @return the number of unread News for the Feed having the given Id.
   */
  public int getUnreadCount(FeedLinkReference feedLinkRef) {
    synchronized (this) {
      NewsCounterItem counter = getFromCounter(feedLinkRef);

      /* Feed has no news */
      if (counter == null)
        return 0;

      return counter.getUnreadCounter();
    }
  }
View Full Code Here


   * @param feedLinkRef The reference to the link of the Feed.
   * @return the number of unread News for the Feed having the given link.
   */
  public int getNewCount(FeedLinkReference feedLinkRef) {
    synchronized (this) {
      NewsCounterItem counter = getFromCounter(feedLinkRef);

      /* Feed has no news */
      if (counter == null)
        return 0;

      return counter.getNewCounter();
    }
  }
View Full Code Here

   * @param feedLinkRef The reference to the link of the Feed.
   * @return the number of sticky News for the Feed having the given Id.
   */
  public int getStickyCount(FeedLinkReference feedLinkRef) {
    synchronized (this) {
      NewsCounterItem counter = getFromCounter(feedLinkRef);

      /* Feed has no news */
      if (counter == null)
        return 0;

      return counter.getStickyCounter();
    }
  }
View Full Code Here

  private NewsCounterItem getFromCounter(FeedLinkReference feedRef) {
    return fCounter.get(feedRef.getLink());
  }

  private NewsCounterItem count(IFeed feed) {
    NewsCounterItem counterItem = new NewsCounterItem();

    List<INews> newsList = feed.getVisibleNews();
    for (INews news : newsList) {
      if (ModelUtils.isUnread(news.getState()))
        counterItem.incrementUnreadCounter();
      if (INews.State.NEW.equals(news.getState()))
        counterItem.incrementNewCounter();
      if (news.isFlagged())
        counterItem.incrementStickyCounter();
    }

    return counterItem;
  }
View Full Code Here

    for (NewsEvent event : events) {
      INews news = event.getEntity();
      FeedLinkReference feedRef = news.getFeedReference();

      synchronized (this) {
        NewsCounterItem counter = getFromCounter(feedRef);

        /* Create Counter if not yet done */
        if (counter == null) {
          counter = new NewsCounterItem();
          putInCounter(feedRef, counter);
        }

        /* Update Counter */
        if (news.getState() == INews.State.NEW)
          counter.incrementNewCounter();
        if (ModelUtils.isUnread(news.getState()))
          counter.incrementUnreadCounter();
        if (news.isFlagged())
          counter.incrementStickyCounter();
      }
    }
  }
View Full Code Here

  private void onNewsDeleted(Set<NewsEvent> events) {
    for (NewsEvent event : events) {
      INews news = event.getEntity();

      synchronized (this) {
        NewsCounterItem counter = getFromCounter(news.getFeedReference());
        if (counter != null) {

          /* Update Counter */
          if (news.getState() == INews.State.NEW)
            counter.decrementNewCounter();
          if (ModelUtils.isUnread(news.getState()))
            counter.decrementUnreadCounter();
          if (news.isFlagged())
            counter.decrementStickyCounter();
        }
      }
    }
  }
View Full Code Here

      /* No Change - continue */
      if (oldStateUnread == currentStateUnread && oldStateNew == currentStateNew && oldStateSticky == newStateSticky)
        continue;

      synchronized (this) {
        NewsCounterItem counter = getFromCounter(feedRef);

        /* News became read */
        if (oldStateUnread && !currentStateUnread)
          counter.decrementUnreadCounter();

        /* News became unread */
        else if (!oldStateUnread && currentStateUnread)
          counter.incrementUnreadCounter();

        /* News no longer New */
        if (oldStateNew && !currentStateNew)
          counter.decrementNewCounter();

        /* News became New */
        else if (!oldStateNew && currentStateNew)
          counter.incrementNewCounter();

        /* News became unsticky */
        if (oldStateSticky && !newStateSticky)
          counter.decrementStickyCounter();

        /* News became sticky */
        else if (!oldStateSticky && newStateSticky)
          counter.incrementStickyCounter();
      }
    }
  }
View Full Code Here

    INewsBin bin = fFactory.createNewsBin(null, root, "Bin");
    input.add(bin);

    NewsCounter count = new NewsCounter();
    NewsCounterItem item = new NewsCounterItem(1, 0, 0);
    count.put(feed1.getLink().toString(), item);
    ((BookMark) bookmark1).setNewsCounter(count);

    count = new NewsCounter();
    item = new NewsCounterItem(0, 1, 0);
    count.put(feed2.getLink().toString(), item);
    ((BookMark) bookmark2).setNewsCounter(count);

    count = new NewsCounter();
    item = new NewsCounterItem(0, 0, 1);
    count.put(feed3.getLink().toString(), item);
    ((BookMark) bookmark3).setNewsCounter(count);

    INews news = fFactory.createNews(null, fFactory.createFeed(null, new URI("feed4")), new Date());
    news.setState(INews.State.NEW);
View Full Code Here

  private static void addNewsCounterItem(NewsCounter newsCounter, Feed feed) {
    Map<State, Integer> stateToCountMap = feed.getNewsCount();
    int unreadCount = getCount(stateToCountMap, EnumSet.of(State.NEW, State.UNREAD, State.UPDATED));
    Integer newCount = stateToCountMap.get(INews.State.NEW);
    newsCounter.put(feed.getLink().toString(), new NewsCounterItem(newCount, unreadCount, feed.getStickyCount()));
  }
View Full Code Here

          continue;

        if (news.getState() == INews.State.DELETED) //Could be DELETED from filters
          continue;

        NewsCounterItem newsCounterItem = fNewsCounter.get(news.getFeedLinkAsText());

        /* Create Counter if not yet done */
        if (newsCounterItem == null) {
          newsCounterItem = new NewsCounterItem();
          fNewsCounter.put(news.getFeedLinkAsText(), newsCounterItem);
          newsCounterUpdated = true;
        }

        /* Update Counter */
        if (news.getState() == INews.State.NEW)
          newsCounterItem.incrementNewCounter();
        if (isUnread(news.getState()))
          newsCounterItem.incrementUnreadCounter();
        if (news.isFlagged())
          newsCounterItem.incrementStickyCounter();

        if (!newsCounterUpdated)
          updatedCounterItems.put(news.getFeedLinkAsText(), newsCounterItem);
      }
      if (newsCounterUpdated)
View Full Code Here

TOP

Related Classes of org.rssowl.core.persist.NewsCounterItem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.