use of com.amazon.android.contentbrowser.ContentBrowser.BROADCAST_VIDEO_DETAIL_DATA_LOADED in project zype-firebuilder by zype.
the class ContentLoader method getLoadContentsObservable.
/*
* Zype, Evgeny Cherkasov
*/
public Observable<Object> getLoadContentsObservable(Observable<Object> observable, Recipe recipeDynamicParser) {
return observable.map(contentContainerAsObject -> {
ContentContainer contentContainer = (ContentContainer) contentContainerAsObject;
if (contentContainer.getExtraStringValue(Recipe.KEY_DATA_TYPE_TAG).equals(ZypeSettings.MY_LIBRARY_PLAYLIST_ID)) {
ContentContainer rootMyLibrary = getRootContentContainer().findContentContainerByName(ZypeSettings.ROOT_MY_LIBRARY_PLAYLIST_ID);
if (rootMyLibrary.getExtraValueAsInt(ExtraKeys.NEXT_PAGE) == 1) {
contentContainer.getContents().clear();
}
} else {
if (contentContainer.getExtraValueAsInt(ExtraKeys.NEXT_PAGE) == 1) {
contentContainer.getContents().clear();
}
}
return contentContainerAsObject;
}).concatMap(contentContainerAsObject -> {
ContentContainer contentContainer = (ContentContainer) contentContainerAsObject;
if (DEBUG_RECIPE_CHAIN) {
Log.d(TAG, "getLoadContentsObservable:" + contentContainer.getName());
}
if (contentContainer.getExtraStringValue(Recipe.KEY_DATA_TYPE_TAG).equals(ZypeSettings.MY_LIBRARY_PLAYLIST_ID)) {
// Loading My Library videos
return getMyLibraryVideosObservable(contentContainerAsObject);
} else if (contentContainer.getExtraStringValue(Recipe.KEY_DATA_TYPE_TAG).equals(ZypeSettings.FAVORITES_PLAYLIST_ID)) {
// Load favorites videos
return getFavoriteVideosFeedObservable(contentContainerAsObject);
} else {
LocalBroadcastManager.getInstance(mContext).sendBroadcast(new Intent(BROADCAST_VIDEO_DETAIL_DATA_LOADED));
// Loading playlist videos
return getPlaylistVideosFeedObservable(contentContainerAsObject);
}
}).concatMap(objectPair -> {
ContentContainer contentContainer = (ContentContainer) objectPair.first;
String feed = (String) objectPair.second;
String[] params = new String[] { contentContainer.getExtraStringValue(Recipe.KEY_DATA_TYPE_TAG) };
if (TextUtils.isEmpty(feed)) {
return Observable.just(Pair.create(contentContainer, null));
} else {
return mDynamicParser.cookRecipeObservable(recipeDynamicParser, feed, null, params).map(contentAsObject -> {
if (DEBUG_RECIPE_CHAIN) {
Log.d(TAG, "Parser got an content");
}
Content content = (Content) contentAsObject;
if (content != null) {
contentContainer.addContent(content);
if (ZypeConfiguration.displayWatchedBarOnVideoThumbnails()) {
content.setExtraValue(Content.EXTRA_PLAYBACK_POSITION_PERCENTAGE, getContentPlaybackPositionPercentage(content));
}
}
return Pair.create(contentContainer, contentAsObject);
});
}
});
}
Aggregations