use of com.amazon.android.tv.tenfoot.presenter.PosterCardPresenter in project zype-firebuilder by zype.
the class ZypePlaylistContentBrowseFragment method updateContents.
/* Zype, Evgeny Cherkasov */
public void updateContents() {
Log.d(TAG, "updateContents()");
ArrayObjectAdapter rowsAdapter = mRowsAdapter;
ContentContainer rootContentContainer = ContentBrowser.getInstance(getActivity()).getLastSelectedContentContainer();
boolean isMyLibrary = rootContentContainer.getExtraStringValue(Recipe.KEY_DATA_TYPE_TAG).equals(ZypeSettings.ROOT_MY_LIBRARY_PLAYLIST_ID);
boolean isFavorites = rootContentContainer.getExtraStringValue(Recipe.KEY_DATA_TYPE_TAG).equals(ZypeSettings.ROOT_FAVORITES_PLAYLIST_ID);
CardPresenter cardPresenter = new CardPresenter();
PosterCardPresenter posterCardPresenter = new PosterCardPresenter();
int index = 0;
for (ContentContainer contentContainer : rootContentContainer.getContentContainers()) {
// Skip 'My Library' and 'Favorites' content container
if (contentContainer.getExtraStringValue(Recipe.KEY_DATA_TYPE_TAG).equals(ZypeSettings.ROOT_MY_LIBRARY_PLAYLIST_ID) || contentContainer.getExtraStringValue(Recipe.KEY_DATA_TYPE_TAG).equals(ZypeSettings.ROOT_FAVORITES_PLAYLIST_ID)) {
continue;
}
if (index >= rowsAdapter.size()) {
HeaderItem header = new HeaderItem(0, contentContainer.getName());
ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(cardPresenter);
if (contentContainer.getExtraStringValue(ContentContainer.EXTRA_THUMBNAIL_LAYOUT).equals("poster")) {
listRowAdapter = new ArrayObjectAdapter(posterCardPresenter);
}
rowsAdapter.add(new ListRow(header, listRowAdapter));
}
ListRow row = (ListRow) rowsAdapter.get(index);
ArrayObjectAdapter listRowAdapter = (ArrayObjectAdapter) row.getAdapter();
// Remove 'Load more' action button
if (listRowAdapter.size() > 0 && listRowAdapter.get(listRowAdapter.size() - 1) instanceof PlaylistAction) {
listRowAdapter.remove(listRowAdapter.get(listRowAdapter.size() - 1));
}
// Add new contents
for (int i = listRowAdapter.size() - contentContainer.getContentContainerCount(); i < contentContainer.getContentCount(); i++) {
listRowAdapter.add(contentContainer.getContents().get(i));
}
// Add a button for loading next page of playlist videos
if (isMyLibrary) {
if (rootContentContainer.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));
listRowAdapter.add(action);
}
} else if (isFavorites) {
} else {
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);
}
}
// Display message if the Favorites list is empty
if (isFavorites && contentContainer.getContents().isEmpty() && ContentBrowser.getInstance(getActivity()).isFavoritesLoaded()) {
showEmptyFavorites();
}
index++;
}
}
use of com.amazon.android.tv.tenfoot.presenter.PosterCardPresenter in project zype-firebuilder by zype.
the class ZypeContentDetailsPlaylistFragment method loadContentContainer.
private void loadContentContainer(ArrayObjectAdapter rowsAdapter) {
Log.d(TAG, "loadRootContentContainer()");
rowsAdapter.clear();
Content video = ContentBrowser.getInstance(getActivity()).getLastSelectedContent();
if (video != null) {
String playlistId = video.getExtraValueAsString(Content.EXTRA_PLAYLIST_ID);
ContentContainer playlist = ContentBrowser.getInstance(getActivity()).getPlayList(playlistId);
if (playlist == null) {
isDataLoaded = true;
mCallback.onItemSelected(video, null, -1, 0);
Handler handler = new Handler();
handler.postDelayed(() -> {
LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(new Intent(BROADCAST_DATA_LOADED));
}, 1000L);
return;
}
CardPresenter cardPresenter = new CardPresenter();
PosterCardPresenter posterCardPresenter = new PosterCardPresenter();
HeaderItem header = new HeaderItem(0, playlist.getName());
ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(cardPresenter);
if (playlist.getExtraStringValue(ContentContainer.EXTRA_THUMBNAIL_LAYOUT).equals("poster")) {
listRowAdapter = new ArrayObjectAdapter(posterCardPresenter);
}
if (playlist.getContents() != null) {
try {
for (Content content : playlist.getContents()) {
if (playlist.getExtraValueAsInt(ExtraKeys.NEXT_PAGE) > 0 && playlist.getContents().indexOf(content) == playlist.getContentCount() - 1) {
content.setExtraValue(ContentBrowser.NEXT_PAGE, true);
content.setExtraValue(Content.EXTRA_PLAYLIST_ID, playlist.getExtraStringValue(Recipe.KEY_DATA_TYPE_TAG));
}
listRowAdapter.add(content);
}
} catch (Exception e) {
}
}
rowsAdapter.add(new ListRow(header, listRowAdapter));
isDataLoaded = true;
}
}
use of com.amazon.android.tv.tenfoot.presenter.PosterCardPresenter in project zype-firebuilder by zype.
the class ZypePlaylistContentBrowseFragment method loadRootContentContainer.
private void loadRootContentContainer(ArrayObjectAdapter rowsAdapter) {
Log.d(TAG, "loadRootContentContainer()");
rowsAdapter.clear();
ContentContainer rootContentContainer = ContentBrowser.getInstance(getActivity()).getLastSelectedContentContainer();
boolean isMyLibrary = rootContentContainer.getExtraStringValue(Recipe.KEY_DATA_TYPE_TAG).equals(ZypeSettings.ROOT_MY_LIBRARY_PLAYLIST_ID);
boolean isFavorites = rootContentContainer.getExtraStringValue(Recipe.KEY_DATA_TYPE_TAG).equals(ZypeSettings.ROOT_FAVORITES_PLAYLIST_ID);
CardPresenter cardPresenter = new CardPresenter();
PosterCardPresenter posterCardPresenter = new PosterCardPresenter();
for (ContentContainer contentContainer : rootContentContainer.getContentContainers()) {
if (isMyLibrary && contentContainer.getContents().isEmpty() && isDataLoaded) {
dialogError = ErrorDialogFragment.newInstance(getActivity(), ErrorUtils.ERROR_CATEGORY.ZYPE_MY_LIBRARY_ERROR_EMPTY, (ErrorDialogFragment.ErrorDialogFragmentListener) getActivity());
dialogError.show(getFragmentManager(), ErrorDialogFragment.FRAGMENT_TAG_NAME);
break;
}
if (isFavorites) {
if (contentContainer.getContents().isEmpty() && ContentBrowser.getInstance(getActivity()).isFavoritesLoaded()) {
showEmptyFavorites();
break;
}
}
HeaderItem header = new HeaderItem(0, contentContainer.getName());
ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(cardPresenter);
if (contentContainer.getExtraStringValue(ContentContainer.EXTRA_THUMBNAIL_LAYOUT).equals("poster")) {
listRowAdapter = new ArrayObjectAdapter(posterCardPresenter);
}
for (ContentContainer innerContentContainer : contentContainer.getContentContainers()) {
listRowAdapter.add(innerContentContainer);
}
for (Content content : contentContainer.getContents()) {
listRowAdapter.add(content);
}
if (isMyLibrary) {
if (rootContentContainer.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));
listRowAdapter.add(action);
}
} else if (isFavorites) {
} else {
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);
}
}
rowsAdapter.add(new ListRow(header, listRowAdapter));
}
// addSettingsActionsToRowAdapter(rowsAdapter);
// isDataLoaded = false;
addStubRow(rowsAdapter);
}
use of com.amazon.android.tv.tenfoot.presenter.PosterCardPresenter in project zype-firebuilder by zype.
the class BrowseHelper method loadRootContentContainer.
/**
* Loads the content from the root content container into the rows adapter.
*
* @param activity The activity.
* @param rowsAdapter The rows adapter.
*/
public static void loadRootContentContainer(Activity activity, ArrayObjectAdapter rowsAdapter) {
ContentContainer rootContentContainer = ContentBrowser.getInstance(activity).getRootContentContainer();
CardPresenter cardPresenter = new CardPresenter();
/* Zype, Evgeny Cherkasov */
PosterCardPresenter posterCardPresenter = new PosterCardPresenter();
for (ContentContainer contentContainer : rootContentContainer.getContentContainers()) {
// Don't show My Library and Favorites content container
if (contentContainer.getExtraStringValue(Recipe.KEY_DATA_TYPE_TAG).equals(ZypeSettings.ROOT_MY_LIBRARY_PLAYLIST_ID) || contentContainer.getExtraStringValue(Recipe.KEY_DATA_TYPE_TAG).equals(ZypeSettings.ROOT_FAVORITES_PLAYLIST_ID) || contentContainer.getExtraStringValue(Recipe.KEY_DATA_TYPE_TAG).equals(ZypeSettings.ROOT_SLIDERS_PLAYLIST_ID)) {
continue;
}
HeaderItem header = new HeaderItem(0, contentContainer.getName());
ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(cardPresenter);
/* Zype, Evgeny Cherkasov */
if (contentContainer.getExtraStringValue(ContentContainer.EXTRA_THUMBNAIL_LAYOUT).equals("poster")) {
listRowAdapter = new ArrayObjectAdapter(posterCardPresenter);
}
for (ContentContainer innerContentContainer : contentContainer.getContentContainers()) {
listRowAdapter.add(innerContentContainer);
}
// TODO: Probably it would better to move updating NextPage to the getContentsObservable()
if (contentContainer.getExtraValueAsInt(ExtraKeys.NEXT_PAGE) == 1) {
if (contentContainer.getExtraValueAsInt(ContentContainer.EXTRA_PLAYLIST_ITEM_COUNT) > ZypeApi.PER_PAGE_DEFAULT) {
contentContainer.setExtraValue(ExtraKeys.NEXT_PAGE, 2);
} else {
contentContainer.setExtraValue(ExtraKeys.NEXT_PAGE, -1);
}
}
for (Content content : contentContainer.getContents()) {
if (contentContainer.getExtraValueAsInt(ExtraKeys.NEXT_PAGE) > 0 && contentContainer.getContents().indexOf(content) == contentContainer.getContentCount() - 1) {
content.setExtraValue(ContentBrowser.NEXT_PAGE, true);
content.setExtraValue(Content.EXTRA_PLAYLIST_ID, contentContainer.getExtraStringValue(Recipe.KEY_DATA_TYPE_TAG));
}
listRowAdapter.add(content);
}
/* 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("activity.getString(R.string.action_load_more)");
action.setExtraValue(PlaylistAction.EXTRA_PLAYLIST_ID, contentContainer.getExtraStringValue(Recipe.KEY_DATA_TYPE_TAG));
listRowAdapter.add(action);
}*/
rowsAdapter.add(new ListRow(header, listRowAdapter));
}
}
Aggregations