Search in sources :

Example 1 with FeedCategoryManager

use of gov.whitehouse.core.manager.FeedCategoryManager in project wh-app-android by WhiteHouse.

the class LiveService method updateEvents.

private void updateEvents() {
    final FeedCategoryManager fcm = FeedCategoryManager.get();
    final FeedCategoryConfig config = fcm.getFeedCategoryConfig().toBlocking().first();
    final List<FeedItem> feedItems;
    final List<FeedItem> validItems = new ArrayList<>();
    FeedCategoryItem liveItem = null;
    for (FeedCategoryItem c : config.feeds()) {
        if (FeedCategoryItem.VIEW_TYPE_LIVE.equals(c.viewType())) {
            liveItem = c;
            break;
        }
    }
    if (liveItem == null) {
        return;
    }
    FeedManager.updateFeedFromServer(liveItem.feedUrl(), liveItem.title(), liveItem.viewType());
    feedItems = FeedManager.observeFeedItems(liveItem.feedUrl()).toBlocking().first();
    for (FeedItem item : feedItems) {
        if (item != null && item.pubDate() != null) {
            validItems.add(item);
        }
    }
    sLiveItemCountObservable.onNext(Observable.just(validItems.size()));
    mLiveEvents = validItems;
}
Also used : FeedCategoryConfig(gov.whitehouse.data.model.FeedCategoryConfig) FeedItem(gov.whitehouse.data.model.FeedItem) FeedCategoryManager(gov.whitehouse.core.manager.FeedCategoryManager) ArrayList(java.util.ArrayList) FeedCategoryItem(gov.whitehouse.data.model.FeedCategoryItem)

Aggregations

FeedCategoryManager (gov.whitehouse.core.manager.FeedCategoryManager)1 FeedCategoryConfig (gov.whitehouse.data.model.FeedCategoryConfig)1 FeedCategoryItem (gov.whitehouse.data.model.FeedCategoryItem)1 FeedItem (gov.whitehouse.data.model.FeedItem)1 ArrayList (java.util.ArrayList)1