Search in sources :

Example 6 with PlaylistAction

use of com.amazon.android.model.PlaylistAction 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);
}
Also used : PlaylistAction(com.amazon.android.model.PlaylistAction) Content(com.amazon.android.model.content.Content) PosterCardPresenter(com.amazon.android.tv.tenfoot.presenter.PosterCardPresenter) CardPresenter(com.amazon.android.tv.tenfoot.presenter.CardPresenter) SettingsCardPresenter(com.amazon.android.tv.tenfoot.presenter.SettingsCardPresenter) PosterCardPresenter(com.amazon.android.tv.tenfoot.presenter.PosterCardPresenter) ContentContainer(com.amazon.android.model.content.ContentContainer) HeaderItem(androidx.leanback.widget.HeaderItem) ArrayObjectAdapter(androidx.leanback.widget.ArrayObjectAdapter) ListRow(androidx.leanback.widget.ListRow)

Aggregations

ArrayObjectAdapter (androidx.leanback.widget.ArrayObjectAdapter)6 ListRow (androidx.leanback.widget.ListRow)6 PlaylistAction (com.amazon.android.model.PlaylistAction)6 ContentContainer (com.amazon.android.model.content.ContentContainer)6 Content (com.amazon.android.model.content.Content)4 HeaderItem (androidx.leanback.widget.HeaderItem)3 CardPresenter (com.amazon.android.tv.tenfoot.presenter.CardPresenter)3 SparseArrayObjectAdapter (androidx.leanback.widget.SparseArrayObjectAdapter)2 PosterCardPresenter (com.amazon.android.tv.tenfoot.presenter.PosterCardPresenter)2 SettingsCardPresenter (com.amazon.android.tv.tenfoot.presenter.SettingsCardPresenter)2