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);
}
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);
}
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));
}
}
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));
}
}
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));
}
Aggregations