Search in sources :

Example 56 with Content

use of com.amazon.android.model.content.Content in project zype-firebuilder by zype.

the class ContentTranslatorTest method testMapToModelWithBadRecipeTitle.

/**
 * Tests the {@link ContentTranslator#mapToModel(Map, Recipe)} with a recipe that's missing the
 * title field.
 */
@Test
public void testMapToModelWithBadRecipeTitle() throws Exception {
    Recipe badRecipe = Recipe.newInstance(getBadContentRecipeJsonString("mTitle"));
    Content content = mContentTranslator.mapToModel(createValidMap(), badRecipe);
    assertNull("Content should be null due to bad translation", content);
}
Also used : Recipe(com.amazon.android.recipe.Recipe) Content(com.amazon.android.model.content.Content) Test(org.junit.Test)

Example 57 with Content

use of com.amazon.android.model.content.Content in project zype-firebuilder by zype.

the class ContentTranslatorTest method testMapToModelWithBadRecipeBackgroundImageUrl.

/**
 * Tests the {@link ContentTranslator#mapToModel(Map, Recipe)} with a recipe that's missing the
 * backgroundImageUrl field.
 */
@Test
public void testMapToModelWithBadRecipeBackgroundImageUrl() throws Exception {
    Recipe badRecipe = Recipe.newInstance(getBadContentRecipeJsonString("mBackgroundImageUrl"));
    Content content = mContentTranslator.mapToModel(createValidMap(), badRecipe);
    assertNull("Content should be null due to bad translation", content);
}
Also used : Recipe(com.amazon.android.recipe.Recipe) Content(com.amazon.android.model.content.Content) Test(org.junit.Test)

Example 58 with Content

use of com.amazon.android.model.content.Content in project zype-firebuilder by zype.

the class ContentDetailsFragment method setupRelatedContentRow.

/**
 * Builds the related content row. Uses contents from the selected content's category.
 */
private void setupRelatedContentRow() {
    ContentContainer recommended = ContentBrowser.getInstance(getActivity()).getRecommendedListOfAContentAsAContainer(mSelectedContent);
    ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(new CardPresenter());
    for (Content c : recommended) {
        listRowAdapter.add(c);
    }
    /* Zype, Evgeny Cherkasov */
    String playlistId = mSelectedContent.getExtraValueAsString(Content.EXTRA_PLAYLIST_ID);
    // Update header for Favorites
    if (!TextUtils.isEmpty(playlistId) && playlistId.equals(ZypeSettings.FAVORITES_PLAYLIST_ID)) {
        recommended.setName(getString(R.string.content_details_recommended_header_favorites));
    }
    // Add a button for loading next page of playlist videos
    ContentContainer contentContainer = ContentBrowser.getInstance(getActivity()).getRootContentContainer().findContentContainerById(playlistId);
    if (contentContainer != null) {
        if (contentContainer.getExtraValueAsInt(ExtraKeys.NEXT_PAGE) > 0) {
            PlaylistAction action = new PlaylistAction();
            action.setAction(ContentBrowser.NEXT_PAGE).setIconResourceId(com.amazon.android.contentbrowser.R.drawable.ic_add_white_48dp).setLabel1(getString(R.string.action_load_more));
            action.setExtraValue(PlaylistAction.EXTRA_PLAYLIST_ID, contentContainer.getExtraStringValue(Recipe.KEY_DATA_TYPE_TAG));
            listRowAdapter.add(action);
        }
    }
    // Only add the header and row for recommendations if there are any recommended content.
    if (listRowAdapter.size() > 0) {
        HeaderItem header = new HeaderItem(0, recommended.getName());
        mAdapter.add(new ListRow(header, listRowAdapter));
    }
}
Also used : PlaylistAction(com.amazon.android.model.PlaylistAction) Content(com.amazon.android.model.content.Content) CardPresenter(com.amazon.android.tv.tenfoot.presenter.CardPresenter) ContentContainer(com.amazon.android.model.content.ContentContainer) ArrayObjectAdapter(androidx.leanback.widget.ArrayObjectAdapter) SparseArrayObjectAdapter(androidx.leanback.widget.SparseArrayObjectAdapter) HeaderItem(androidx.leanback.widget.HeaderItem) ListRow(androidx.leanback.widget.ListRow)

Example 59 with Content

use of com.amazon.android.model.content.Content in project zype-firebuilder by zype.

the class RecommendedContentFragment method loadRootContentContainer.

private void loadRootContentContainer(ArrayObjectAdapter rowsAdapter) {
    ContentContainer rootContentContainer = ContentBrowser.getInstance(getActivity()).getRootContentContainer();
    CardPresenter cardPresenter = new CardPresenter();
    for (ContentContainer contentContainer : rootContentContainer.getContentContainers()) {
        HeaderItem header = new HeaderItem(0, contentContainer.getName());
        ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(cardPresenter);
        for (ContentContainer innerContentContainer : contentContainer.getContentContainers()) {
            listRowAdapter.add(innerContentContainer);
        }
        for (Content content : contentContainer.getContents()) {
            listRowAdapter.add(content);
        }
        rowsAdapter.add(new ListRow(header, listRowAdapter));
    }
}
Also used : Content(com.amazon.android.model.content.Content) CardPresenter(com.amazon.android.tv.tenfoot.presenter.CardPresenter) ContentContainer(com.amazon.android.model.content.ContentContainer) HeaderItem(androidx.leanback.widget.HeaderItem) ArrayObjectAdapter(androidx.leanback.widget.ArrayObjectAdapter) ListRow(androidx.leanback.widget.ListRow)

Example 60 with Content

use of com.amazon.android.model.content.Content in project zype-firebuilder by zype.

the class VerticalContentGridFragment method setupFragment.

private void setupFragment() {
    VerticalGridPresenter gridPresenter = new VerticalGridPresenter();
    gridPresenter.setNumberOfColumns(NUM_COLUMNS);
    setGridPresenter(gridPresenter);
    ArrayObjectAdapter mAdapter = new ArrayObjectAdapter(new CardPresenter());
    ContentContainer contentContainer = ContentBrowser.getInstance(getActivity()).getLastSelectedContentContainer();
    for (Content content : contentContainer) {
        mAdapter.add(content);
    }
    setAdapter(mAdapter);
    setOnItemViewClickedListener((itemViewHolder, item, rowViewHolder, row) -> {
        Log.i(TAG, "item clicked: " + ((Content) item).getTitle());
        if (item instanceof Content) {
            Content content = (Content) item;
            Log.d(TAG, "Content with title " + content.getTitle() + " was clicked");
            ContentBrowser.getInstance(getActivity()).setLastSelectedContent(content).switchToScreen(ContentBrowser.CONTENT_DETAILS_SCREEN, content);
        }
    });
    setOnItemViewSelectedListener((itemViewHolder, item, rowViewHolder, row) -> Log.i(TAG, "item selected: " + ((Content) item).getTitle()));
    setOnSearchClickedListener(view -> ContentBrowser.getInstance(getActivity()).switchToScreen(ContentBrowser.CONTENT_SEARCH_SCREEN));
}
Also used : VerticalGridPresenter(androidx.leanback.widget.VerticalGridPresenter) Content(com.amazon.android.model.content.Content) CardPresenter(com.amazon.android.tv.tenfoot.presenter.CardPresenter) ContentContainer(com.amazon.android.model.content.ContentContainer) ArrayObjectAdapter(androidx.leanback.widget.ArrayObjectAdapter)

Aggregations

Content (com.amazon.android.model.content.Content)76 ContentContainer (com.amazon.android.model.content.ContentContainer)28 Test (org.junit.Test)26 ArrayObjectAdapter (androidx.leanback.widget.ArrayObjectAdapter)13 ListRow (androidx.leanback.widget.ListRow)13 ArrayList (java.util.ArrayList)11 Recipe (com.amazon.android.recipe.Recipe)10 Intent (android.content.Intent)8 RecentDatabaseHelper (com.amazon.android.contentbrowser.database.helpers.RecentDatabaseHelper)7 TextUtils (android.text.TextUtils)6 RecentRecord (com.amazon.android.contentbrowser.database.records.RecentRecord)6 CardPresenter (com.amazon.android.tv.tenfoot.presenter.CardPresenter)6 List (java.util.List)6 Context (android.content.Context)5 HeaderItem (androidx.leanback.widget.HeaderItem)5 Action (com.amazon.android.model.Action)5 NavigatorModel (com.amazon.android.navigator.NavigatorModel)5 AndroidSchedulers (rx.android.schedulers.AndroidSchedulers)5 Bundle (android.os.Bundle)4 Log (android.util.Log)4