Search in sources :

Example 31 with Content

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

the class ContentDetailsFragment method checkGlobalSearchIntent.

/**
 * Check if there is a global search intent.
 */
private boolean checkGlobalSearchIntent() {
    Log.v(TAG, "checkGlobalSearchIntent called.");
    Intent intent = getActivity().getIntent();
    String intentAction = intent.getAction();
    String globalSearch = getString(R.string.global_search);
    if (globalSearch.equalsIgnoreCase(intentAction)) {
        Uri intentData = intent.getData();
        Log.d(TAG, "action: " + intentAction + " intentData:" + intentData);
        int selectedIndex = Integer.parseInt(intentData.getLastPathSegment());
        ContentContainer contentContainer = ContentBrowser.getInstance(getActivity()).getRootContentContainer();
        int contentTally = 0;
        if (contentContainer == null) {
            return false;
        }
        for (Content content : contentContainer) {
            ++contentTally;
            if (selectedIndex == contentTally) {
                mSelectedContent = content;
                return true;
            }
        }
    }
    return false;
}
Also used : Content(com.amazon.android.model.content.Content) ContentContainer(com.amazon.android.model.content.ContentContainer) Intent(android.content.Intent) Uri(android.net.Uri)

Example 32 with Content

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

the class ZypeContentDetailsPlaylistFragment method onContentUpdateEvent.

@Subscribe
public void onContentUpdateEvent(ContentUpdateEvent event) {
    ArrayObjectAdapter rowAdapter = (ArrayObjectAdapter) ((ListRow) mRowsAdapter.get(0)).getAdapter();
    for (int i = 0; i < rowAdapter.size(); i++) {
        Content content = (Content) rowAdapter.get(i);
        if (content.getId().equals(event.videoId)) {
            content.setExtraValue(Content.EXTRA_PLAYBACK_POSITION_PERCENTAGE, ContentBrowser.getInstance(getActivity()).getContentLoader().getContentPlaybackPositionPercentage(content));
            rowAdapter.notifyArrayItemRangeChanged(i, i + 1);
        }
    }
}
Also used : Content(com.amazon.android.model.content.Content) ArrayObjectAdapter(androidx.leanback.widget.ArrayObjectAdapter) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 33 with Content

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

the class ZypeContentDetailsPlaylistFragment method getVideoPositionInPlaylist.

private int getVideoPositionInPlaylist() {
    Content video = ContentBrowser.getInstance(getActivity()).getLastSelectedContent();
    String playlistId = video.getExtraValueAsString(Content.EXTRA_PLAYLIST_ID);
    ContentContainer playlist = ContentBrowser.getInstance(getActivity()).getPlayList(playlistId);
    if (playlist == null) {
        return -1;
    } else {
        return playlist.getContents().indexOf(video);
    }
}
Also used : Content(com.amazon.android.model.content.Content) ContentContainer(com.amazon.android.model.content.ContentContainer)

Example 34 with Content

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

the class ZypeContentDetailsPlaylistFragment method updateContents.

public void updateContents() {
    Log.d(TAG, "updateContents()");
    ArrayObjectAdapter rowsAdapter = mRowsAdapter;
    Content video = ContentBrowser.getInstance(getActivity()).getLastSelectedContent();
    String playlistId = video.getExtraValueAsString(Content.EXTRA_PLAYLIST_ID);
    ContentContainer playlist = ContentBrowser.getInstance(getActivity()).getPlayList(playlistId);
    if (playlist == null) {
        return;
    }
    int index = 0;
    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));
    }
    if (listRowAdapter.size() > 0 && listRowAdapter.get(listRowAdapter.size() - 1) instanceof Content) {
        Content content = (Content) listRowAdapter.get(listRowAdapter.size() - 1);
        content.setExtraValue(ContentBrowser.NEXT_PAGE, false);
    }
    // Add new contents
    if (playlist.getContentCount() > listRowAdapter.size()) {
        for (int i = listRowAdapter.size(); i < playlist.getContentCount(); i++) {
            Content content = playlist.getContents().get(i);
            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);
        }
    }
}
Also used : PlaylistAction(com.amazon.android.model.PlaylistAction) Content(com.amazon.android.model.content.Content) ContentContainer(com.amazon.android.model.content.ContentContainer) ArrayObjectAdapter(androidx.leanback.widget.ArrayObjectAdapter) ListRow(androidx.leanback.widget.ListRow)

Example 35 with Content

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

the class ZypePlaylistContentBrowseFragment method onContentUpdateEvent.

@Subscribe
public void onContentUpdateEvent(ContentUpdateEvent event) {
    for (int rowIndex = 0; rowIndex < mRowsAdapter.size(); rowIndex++) {
        ArrayObjectAdapter rowAdapter = (ArrayObjectAdapter) ((ListRow) mRowsAdapter.get(rowIndex)).getAdapter();
        for (int i = 0; i < rowAdapter.size(); i++) {
            Content content = (Content) rowAdapter.get(i);
            if (content.getId().equals(event.videoId)) {
                content.setExtraValue(Content.EXTRA_PLAYBACK_POSITION_PERCENTAGE, ContentBrowser.getInstance(getActivity()).getContentLoader().getContentPlaybackPositionPercentage(content));
            }
            rowAdapter.notifyArrayItemRangeChanged(i, i + 1);
        }
    }
}
Also used : Content(com.amazon.android.model.content.Content) ArrayObjectAdapter(androidx.leanback.widget.ArrayObjectAdapter) Subscribe(org.greenrobot.eventbus.Subscribe)

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