use of gov.whitehouse.core.FeedItemData in project wh-app-android by WhiteHouse.
the class FeedItemListFragment method onStart.
@Override
public void onStart() {
super.onStart();
showList(false);
showProgress(true);
if (mFeedType == TYPE_FAVORITES) {
bindSubscription(AndroidObservable.bindFragment(this, FeedManager.observeFavorites()).map(feedItems -> {
List<FeedItemData> processed = new ArrayList<>(feedItems.size());
FeedItemData data;
for (FeedItem item : feedItems) {
data = new FeedItemData();
data.item = item;
processed.add(data);
}
return processed;
}).subscribe(this));
FeedManager.updateFavorites(getActivity());
} else {
bindSubscription(fetchData());
String viewType;
switch(mFeedType) {
default:
case TYPE_ARTICLE:
viewType = FeedCategoryItem.VIEW_TYPE_ARTICLE_LIST;
break;
case TYPE_LIVE:
viewType = FeedCategoryItem.VIEW_TYPE_LIVE;
break;
case TYPE_PHOTOS:
viewType = FeedCategoryItem.VIEW_TYPE_PHOTO_GALLERY;
break;
case TYPE_VIDEOS:
viewType = FeedCategoryItem.VIEW_TYPE_VIDEO_GALLERY;
break;
}
FeedManager.updateFeedFromServer(mFeedUrl, mFeedTitle, viewType);
}
if (mFeedType == TYPE_FAVORITES) {
Drawable d = getResources().getDrawable(R.drawable.ic_action_bookmark_outline);
String s = getString(R.string.empty_favorites_list);
SpannableString ss = new SpannableString(s);
ImageSpan is = new ImageSpan(d, ImageSpan.ALIGN_BOTTOM);
int index = s.indexOf("{icon}");
d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
d.setColorFilter(Color.DKGRAY, PorterDuff.Mode.MULTIPLY);
ss.setSpan(is, index, index + 6, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
getEmptyView().setText(ss);
} else if (mFeedType == TYPE_LIVE) {
getEmptyView().setText(R.string.empty_live_list);
}
if (getTracker() != null) {
getTracker().setScreenName("FeedItemList");
if (mFeedType == TYPE_FAVORITES) {
getTracker().setPage("Favorites");
} else {
getTracker().setPage(mFeedUrl);
}
}
}
use of gov.whitehouse.core.FeedItemData in project wh-app-android by WhiteHouse.
the class MainActivity method onFeedItemSelected.
@Override
public void onFeedItemSelected(List<FeedItemData> items, int selectedPosition) {
FeedItem item = items.get(selectedPosition).item;
FragmentManager fm;
FragmentTransaction ft;
Fragment f;
Intent intent;
final List<FeedItem> feedItems;
if (item.type().equals(FeedType.TYPE_LIVE)) {
intent = new Intent(Intent.ACTION_VIEW, Uri.parse(item.link()));
startActivity(intent);
return;
}
fm = getSupportFragmentManager();
ft = fm.beginTransaction();
if (item.type().equals(FeedType.TYPE_PHOTO)) {
feedItems = new ArrayList<>(items.size());
for (FeedItemData data : items) {
feedItems.add(data.item);
}
f = GalleryFragment.newInstance(feedItems, selectedPosition);
} else if (item.type().equals(FeedType.TYPE_VIDEO)) {
if (item.isYouTubeVideo()) {
intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(item.videoLink()));
startActivity(intent);
return;
} else {
f = VideoPlayerFragment.newInstance(item);
}
} else {
f = ArticleViewFragment.newInstance(item);
}
if (mSearchVisible && !mTogglingSearch) {
toggleSearch();
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
}
Fragment old = fm.findFragmentByTag("contentFragment");
if (old != null) {
ft.remove(old);
}
ft.add(R.id.fragment_container, f, "contentFragment").addToBackStack(null).commit();
}
Aggregations