use of gov.whitehouse.data.model.FeedCategoryItem in project wh-app-android by WhiteHouse.
the class DrawerFragment method onCreate.
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
mMenu = new MenuBuilder(getActivity());
bindSubscription(AndroidObservable.bindFragment(this, FeedCategoryManager.get().getFeedCategoryConfig().first().subscribeOn(Schedulers.newThread())).subscribe(feedCategoryConfig -> {
List<FeedCategoryItem> items = feedCategoryConfig.feeds();
int i = 0;
int group = 0;
for (FeedCategoryItem c : items) {
switch(c.viewType()) {
case FeedCategoryItem.VIEW_TYPE_ARTICLE_LIST:
group = GROUP_ARTICLES;
break;
case FeedCategoryItem.VIEW_TYPE_PHOTO_GALLERY:
group = GROUP_PHOTOS;
break;
case FeedCategoryItem.VIEW_TYPE_VIDEO_GALLERY:
group = GROUP_VIDEOS;
break;
case FeedCategoryItem.VIEW_TYPE_LIVE:
mLivePosition = i + 1;
group = GROUP_LIVE;
break;
}
mMenu.add(group, Menu.NONE, i++, c.title()).setIntent(new Intent().setData(Uri.parse(c.feedUrl())));
}
mMenu.add(GROUP_FAVORITES, Menu.NONE, i++, R.string.title_favorites);
getAdapter().addHeader(new Object());
getAdapter().fillWith(getMenuItems());
getAdapter().selectOnly(mCheckedPosition);
getProgressBar().setVisibility(View.GONE);
getRecyclerView().setVisibility(View.VISIBLE);
if (mDrawerCallbacks != null) {
if (icicle == null) {
mDrawerCallbacks.onRestoreSelectedItem(getAdapter().getItem(mCheckedPosition));
}
updateTitle();
}
}));
}
use of gov.whitehouse.data.model.FeedCategoryItem 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;
}
Aggregations