Search in sources :

Example 1 with BROADCAST_VIDEO_DETAIL_DATA_LOADED

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);
            });
        }
    });
}
Also used : Arrays(java.util.Arrays) ZypeDataDownloaderHelper(com.amazon.dataloader.datadownloader.ZypeDataDownloaderHelper) VideoFavoriteResponse(com.zype.fire.api.Model.VideoFavoriteResponse) AndroidSchedulers(rx.android.schedulers.AndroidSchedulers) GsonBuilder(com.google.gson.GsonBuilder) NavigatorModel(com.amazon.android.navigator.NavigatorModel) PlaylistData(com.zype.fire.api.Model.PlaylistData) Gson(com.google.gson.Gson) VideosResponse(com.zype.fire.api.Model.VideosResponse) Map(java.util.Map) Schedulers(rx.schedulers.Schedulers) ExtraKeys(com.amazon.android.model.content.constants.ExtraKeys) ContentContainerTranslator(com.amazon.android.model.translators.ContentContainerTranslator) Log(android.util.Log) ResponseBody(okhttp3.ResponseBody) Preferences(com.amazon.android.utils.Preferences) List(java.util.List) ZypeConfiguration(com.zype.fire.api.ZypeConfiguration) NavigatorModelParser(com.amazon.android.navigator.NavigatorModelParser) Data(com.amazon.utils.model.Data) ZypeSettings(com.zype.fire.api.ZypeSettings) BROADCAST_VIDEO_DETAIL_DATA_LOADED(com.amazon.android.contentbrowser.ContentBrowser.BROADCAST_VIDEO_DETAIL_DATA_LOADED) ZypeContentContainerTranslator(com.amazon.android.model.translators.ZypeContentContainerTranslator) Call(retrofit2.Call) Subscription(rx.Subscription) Context(android.content.Context) Recipe(com.amazon.android.recipe.Recipe) VideoFavoritesHelper(com.amazon.android.contentbrowser.database.helpers.VideoFavoritesHelper) Pair(android.util.Pair) ZypeContentTranslator(com.amazon.android.model.translators.ZypeContentTranslator) Intent(android.content.Intent) LocalBroadcastManager(androidx.localbroadcastmanager.content.LocalBroadcastManager) HashMap(java.util.HashMap) Response(retrofit2.Response) RecentRecord(com.amazon.android.contentbrowser.database.records.RecentRecord) ArrayList(java.util.ArrayList) Observable(rx.Observable) ZypeAuthentication(com.zype.fire.auth.ZypeAuthentication) VideoResponse(com.zype.fire.api.Model.VideoResponse) VideoEntitlementsResponse(com.zype.fire.api.Model.VideoEntitlementsResponse) BROADCAST_DATA_LOADED(com.amazon.android.contentbrowser.ContentBrowser.BROADCAST_DATA_LOADED) TextUtils(android.text.TextUtils) VideoData(com.zype.fire.api.Model.VideoData) Content(com.amazon.android.model.content.Content) DynamicParser(com.amazon.dynamicparser.DynamicParser) ZypeApi(com.zype.fire.api.ZypeApi) Callback(retrofit2.Callback) VideoEntitlementData(com.zype.fire.api.Model.VideoEntitlementData) RecentDatabaseHelper(com.amazon.android.contentbrowser.database.helpers.RecentDatabaseHelper) ContentTranslator(com.amazon.android.model.translators.ContentTranslator) DataLoadManager(com.amazon.dataloader.dataloadmanager.DataLoadManager) Navigator(com.amazon.android.navigator.Navigator) ContentContainer(com.amazon.android.model.content.ContentContainer) Content(com.amazon.android.model.content.Content) ContentContainer(com.amazon.android.model.content.ContentContainer) Intent(android.content.Intent)

Aggregations

Context (android.content.Context)1 Intent (android.content.Intent)1 TextUtils (android.text.TextUtils)1 Log (android.util.Log)1 Pair (android.util.Pair)1 LocalBroadcastManager (androidx.localbroadcastmanager.content.LocalBroadcastManager)1 BROADCAST_DATA_LOADED (com.amazon.android.contentbrowser.ContentBrowser.BROADCAST_DATA_LOADED)1 BROADCAST_VIDEO_DETAIL_DATA_LOADED (com.amazon.android.contentbrowser.ContentBrowser.BROADCAST_VIDEO_DETAIL_DATA_LOADED)1 RecentDatabaseHelper (com.amazon.android.contentbrowser.database.helpers.RecentDatabaseHelper)1 VideoFavoritesHelper (com.amazon.android.contentbrowser.database.helpers.VideoFavoritesHelper)1 RecentRecord (com.amazon.android.contentbrowser.database.records.RecentRecord)1 Content (com.amazon.android.model.content.Content)1 ContentContainer (com.amazon.android.model.content.ContentContainer)1 ExtraKeys (com.amazon.android.model.content.constants.ExtraKeys)1 ContentContainerTranslator (com.amazon.android.model.translators.ContentContainerTranslator)1 ContentTranslator (com.amazon.android.model.translators.ContentTranslator)1 ZypeContentContainerTranslator (com.amazon.android.model.translators.ZypeContentContainerTranslator)1 ZypeContentTranslator (com.amazon.android.model.translators.ZypeContentTranslator)1 Navigator (com.amazon.android.navigator.Navigator)1 NavigatorModel (com.amazon.android.navigator.NavigatorModel)1