Search in sources :

Example 1 with SettingsCardPresenter

use of com.amazon.android.tv.tenfoot.presenter.SettingsCardPresenter in project zype-firebuilder by zype.

the class BrowseHelper method addSettingsActionsToRowAdapter.

/**
 * Adds the settings actions to an adapter and adds the adapter to the row adapter.
 *
 * @param activity   The activity.
 * @param rowAdapter The row adapter.
 */
public static ArrayObjectAdapter addSettingsActionsToRowAdapter(Activity activity, ArrayObjectAdapter rowAdapter) {
    List<Action> settings = ContentBrowser.getInstance(activity).getSettingsHomeActions();
    if (settings == null || settings.isEmpty()) {
        Log.d(TAG, "No settings were found");
        return null;
    }
    SettingsCardPresenter cardPresenter = new SettingsCardPresenter();
    ArrayObjectAdapter settingsAdapter = new ArrayObjectAdapter(cardPresenter);
    for (Action item : settings) {
        settingsAdapter.add(item);
    }
    // Create settings header and row.
    HeaderItem header = new HeaderItem(0, activity.getResources().getString(R.string.settings_title));
    rowAdapter.add(new ListRow(header, settingsAdapter));
    return settingsAdapter;
}
Also used : PlaylistAction(com.amazon.android.model.PlaylistAction) Action(com.amazon.android.model.Action) SettingsCardPresenter(com.amazon.android.tv.tenfoot.presenter.SettingsCardPresenter) ArrayObjectAdapter(androidx.leanback.widget.ArrayObjectAdapter) HeaderItem(androidx.leanback.widget.HeaderItem) ListRow(androidx.leanback.widget.ListRow)

Example 2 with SettingsCardPresenter

use of com.amazon.android.tv.tenfoot.presenter.SettingsCardPresenter in project zype-firebuilder by zype.

the class ZypePlaylistContentBrowseFragment method addSettingsActionsToRowAdapter.

private void addSettingsActionsToRowAdapter(ArrayObjectAdapter arrayObjectAdapter) {
    List<Action> settings = ContentBrowser.getInstance(getActivity()).getSettingsActions();
    if (settings != null && !settings.isEmpty()) {
        SettingsCardPresenter cardPresenter = new SettingsCardPresenter();
        settingsAdapter = new ArrayObjectAdapter(cardPresenter);
    // for (Action item : settings) {
    // settingsAdapter.add(item);
    // }
    } else {
        Log.d(TAG, "No settings were found");
    }
    if (settingsAdapter != null) {
        // Create settings header and row
        // HeaderItem header = new HeaderItem(0, getString(R.string.settings_title));
        HeaderItem header = new HeaderItem(" ");
        arrayObjectAdapter.add(new ListRow(header, settingsAdapter));
    }
}
Also used : PlaylistAction(com.amazon.android.model.PlaylistAction) Action(com.amazon.android.model.Action) SettingsCardPresenter(com.amazon.android.tv.tenfoot.presenter.SettingsCardPresenter) ArrayObjectAdapter(androidx.leanback.widget.ArrayObjectAdapter) HeaderItem(androidx.leanback.widget.HeaderItem) ListRow(androidx.leanback.widget.ListRow)

Aggregations

ArrayObjectAdapter (androidx.leanback.widget.ArrayObjectAdapter)2 HeaderItem (androidx.leanback.widget.HeaderItem)2 ListRow (androidx.leanback.widget.ListRow)2 Action (com.amazon.android.model.Action)2 PlaylistAction (com.amazon.android.model.PlaylistAction)2 SettingsCardPresenter (com.amazon.android.tv.tenfoot.presenter.SettingsCardPresenter)2