Search in sources :

Example 1 with ListRowPresenter

use of android.support.v17.leanback.widget.ListRowPresenter in project cw-omnibus by commonsguy.

the class RosterFragment method onRosterLoaded.

@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
public void onRosterLoaded(RosterLoadedEvent event) {
    setHeadersState(BrowseFragment.HEADERS_ENABLED);
    setTitle(getString(R.string.app_name));
    ArrayObjectAdapter rows = new ArrayObjectAdapter(new ListRowPresenter());
    PresoRoster roster = PresoRoster.getInstance();
    ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(new PresoPresenter());
    for (int i = 0; i < roster.getPresoCount(); ++i) {
        listRowAdapter.add(roster.getPreso(i));
    }
    HeaderItem header = new HeaderItem(0, "Presentations");
    rows.add(new ListRow(header, listRowAdapter));
    setAdapter(rows);
}
Also used : ListRowPresenter(android.support.v17.leanback.widget.ListRowPresenter) ArrayObjectAdapter(android.support.v17.leanback.widget.ArrayObjectAdapter) HeaderItem(android.support.v17.leanback.widget.HeaderItem) ListRow(android.support.v17.leanback.widget.ListRow) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 2 with ListRowPresenter

use of android.support.v17.leanback.widget.ListRowPresenter in project android-UniversalMusicPlayer by googlesamples.

the class TvPlaybackFragment method updatePlayListRow.

protected void updatePlayListRow(List<MediaSessionCompat.QueueItem> playlistQueue) {
    if (QueueHelper.equals(mPlaylistQueue, playlistQueue)) {
        // if the playlist queue hasn't changed, we don't need to update it
        return;
    }
    LogHelper.d(TAG, "Updating playlist queue ('now playing')");
    mPlaylistQueue = playlistQueue;
    if (playlistQueue == null || playlistQueue.isEmpty()) {
        // Remove the playlist row if no items are in the playlist
        mRowsAdapter.remove(mListRow);
        mListRow = null;
        return;
    }
    mListRowAdapter.clear();
    for (int i = 0; i < playlistQueue.size(); i++) {
        MediaSessionCompat.QueueItem item = playlistQueue.get(i);
        mListRowAdapter.add(item);
    }
    if (mListRow == null) {
        int queueSize = 0;
        MediaControllerCompat controller = getActivity().getSupportMediaController();
        if (controller != null && controller.getQueue() != null) {
            queueSize = controller.getQueue().size();
        }
        HeaderItem header = new HeaderItem(0, queueSize + " song(s) in this playlist");
        mPresenterSelector.addClassPresenter(ListRow.class, new ListRowPresenter());
        mListRow = new ListRow(header, mListRowAdapter);
        mRowsAdapter.add(mListRow);
    } else {
        mRowsAdapter.notifyArrayItemRangeChanged(mRowsAdapter.indexOf(mListRow), 1);
    }
}
Also used : ListRowPresenter(android.support.v17.leanback.widget.ListRowPresenter) MediaControllerCompat(android.support.v4.media.session.MediaControllerCompat) HeaderItem(android.support.v17.leanback.widget.HeaderItem) ListRow(android.support.v17.leanback.widget.ListRow) MediaSessionCompat(android.support.v4.media.session.MediaSessionCompat)

Example 3 with ListRowPresenter

use of android.support.v17.leanback.widget.ListRowPresenter in project cw-omnibus by commonsguy.

the class VideosFragment method onLoadFinished.

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor c) {
    mapCursorToModels(c);
    setHeadersState(BrowseFragment.HEADERS_ENABLED);
    setTitle(getString(R.string.app_name));
    ArrayObjectAdapter rows = new ArrayObjectAdapter(new ListRowPresenter());
    ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(new VideoPresenter(getActivity()));
    for (Video v : videos) {
        listRowAdapter.add(v);
    }
    HeaderItem header = new HeaderItem(0, "Videos", null);
    rows.add(new ListRow(header, listRowAdapter));
    setAdapter(rows);
}
Also used : ListRowPresenter(android.support.v17.leanback.widget.ListRowPresenter) ArrayObjectAdapter(android.support.v17.leanback.widget.ArrayObjectAdapter) HeaderItem(android.support.v17.leanback.widget.HeaderItem) ListRow(android.support.v17.leanback.widget.ListRow)

Example 4 with ListRowPresenter

use of android.support.v17.leanback.widget.ListRowPresenter in project android-UniversalMusicPlayer by googlesamples.

the class TvBrowseFragment method loadRows.

private void loadRows() {
    mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
    setAdapter(mRowsAdapter);
}
Also used : ListRowPresenter(android.support.v17.leanback.widget.ListRowPresenter) ArrayObjectAdapter(android.support.v17.leanback.widget.ArrayObjectAdapter)

Aggregations

ListRowPresenter (android.support.v17.leanback.widget.ListRowPresenter)4 ArrayObjectAdapter (android.support.v17.leanback.widget.ArrayObjectAdapter)3 HeaderItem (android.support.v17.leanback.widget.HeaderItem)3 ListRow (android.support.v17.leanback.widget.ListRow)3 MediaControllerCompat (android.support.v4.media.session.MediaControllerCompat)1 MediaSessionCompat (android.support.v4.media.session.MediaSessionCompat)1 Subscribe (org.greenrobot.eventbus.Subscribe)1