Search in sources :

Example 1 with HeaderItem

use of android.support.v17.leanback.widget.HeaderItem 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 HeaderItem

use of android.support.v17.leanback.widget.HeaderItem 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 = MediaControllerCompat.getMediaController(getActivity());
        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 HeaderItem

use of android.support.v17.leanback.widget.HeaderItem in project vlc-android by videolan.

the class SearchFragment method loadRows.

private void loadRows(String query) {
    final SearchAggregate searchAggregate = VLCApplication.getMLInstance().search(query);
    CardPresenter cp = new CardPresenter(mActivity);
    final ArrayObjectAdapter videoAdapter = new ArrayObjectAdapter(cp);
    videoAdapter.addAll(0, Arrays.asList(searchAggregate.getMediaSearchAggregate().getOthers()));
    final ArrayObjectAdapter episodesAdapter = new ArrayObjectAdapter(cp);
    episodesAdapter.addAll(0, Arrays.asList(searchAggregate.getMediaSearchAggregate().getEpisodes()));
    final ArrayObjectAdapter moviesAdapter = new ArrayObjectAdapter(cp);
    moviesAdapter.addAll(0, Arrays.asList(searchAggregate.getMediaSearchAggregate().getMovies()));
    final ArrayObjectAdapter songsAdapter = new ArrayObjectAdapter(cp);
    songsAdapter.addAll(0, Arrays.asList(searchAggregate.getMediaSearchAggregate().getTracks()));
    final ArrayObjectAdapter artistsAdapter = new ArrayObjectAdapter(cp);
    artistsAdapter.addAll(0, Arrays.asList(searchAggregate.getArtists()));
    final ArrayObjectAdapter albumsAdapter = new ArrayObjectAdapter(cp);
    albumsAdapter.addAll(0, Arrays.asList(searchAggregate.getAlbums()));
    final ArrayObjectAdapter genresAdapter = new ArrayObjectAdapter(cp);
    genresAdapter.addAll(0, Arrays.asList(searchAggregate.getGenres()));
    mHandler.post(new Runnable() {

        @Override
        public void run() {
            if (videoAdapter.size() > 0)
                mRowsAdapter.add(new ListRow(new HeaderItem(0, getResources().getString(R.string.videos)), videoAdapter));
            if (episodesAdapter.size() > 0)
                mRowsAdapter.add(new ListRow(new HeaderItem(0, getResources().getString(R.string.episodes)), episodesAdapter));
            if (moviesAdapter.size() > 0)
                mRowsAdapter.add(new ListRow(new HeaderItem(0, getResources().getString(R.string.movies)), moviesAdapter));
            if (songsAdapter.size() > 0)
                mRowsAdapter.add(new ListRow(new HeaderItem(0, getResources().getString(R.string.songs)), songsAdapter));
            if (artistsAdapter.size() > 0)
                mRowsAdapter.add(new ListRow(new HeaderItem(0, getResources().getString(R.string.artists)), artistsAdapter));
            if (albumsAdapter.size() > 0)
                mRowsAdapter.add(new ListRow(new HeaderItem(0, getResources().getString(R.string.albums)), albumsAdapter));
            if (genresAdapter.size() > 0)
                mRowsAdapter.add(new ListRow(new HeaderItem(0, getResources().getString(R.string.genres)), genresAdapter));
        }
    });
}
Also used : SearchAggregate(org.videolan.medialibrary.media.SearchAggregate) ArrayObjectAdapter(android.support.v17.leanback.widget.ArrayObjectAdapter) HeaderItem(android.support.v17.leanback.widget.HeaderItem) ListRow(android.support.v17.leanback.widget.ListRow)

Example 4 with HeaderItem

use of android.support.v17.leanback.widget.HeaderItem in project vlc-android by videolan.

the class SortedBrowserFragment method updateList.

@Override
public void updateList() {
    Activity activity = getActivity();
    if (activity == null)
        return;
    mAdapter = new ArrayObjectAdapter(new ListRowPresenter());
    setAdapter(mAdapter);
    ArrayObjectAdapter adapter;
    HeaderItem header;
    synchronized (mMediaItemMap) {
        if (mTempMap != null)
            mMediaItemMap = mTempMap;
    }
    for (ListItem item : mMediaItemMap.values()) {
        adapter = new ArrayObjectAdapter(new CardPresenter(activity));
        header = new HeaderItem(0, item.Letter);
        adapter.addAll(0, item.mediaList);
        mAdapter.add(new ListRow(header, adapter));
    }
    mHandler.sendEmptyMessageDelayed(HIDE_LOADING, 3000);
}
Also used : ListRowPresenter(android.support.v17.leanback.widget.ListRowPresenter) CardPresenter(org.videolan.vlc.gui.tv.CardPresenter) MainTvActivity(org.videolan.vlc.gui.tv.MainTvActivity) DetailsActivity(org.videolan.vlc.gui.tv.DetailsActivity) Activity(android.app.Activity) ArrayObjectAdapter(android.support.v17.leanback.widget.ArrayObjectAdapter) HeaderItem(android.support.v17.leanback.widget.HeaderItem) ListRow(android.support.v17.leanback.widget.ListRow)

Example 5 with HeaderItem

use of android.support.v17.leanback.widget.HeaderItem in project vlc-android by videolan.

the class MainTvActivity method updateHistory.

@MainThread
private synchronized void updateHistory(MediaWrapper[] history) {
    if (history == null || mRowsAdapter == null)
        return;
    final boolean createAdapter = mHistoryAdapter == null;
    if (createAdapter)
        mHistoryAdapter = new ArrayObjectAdapter(new CardPresenter(mContext));
    else
        mHistoryAdapter.clear();
    if (!mSettings.getBoolean(PreferencesFragment.PLAYBACK_HISTORY, true))
        return;
    for (int i = 0; i < history.length; ++i) {
        final MediaWrapper item = history[i];
        mHistoryAdapter.add(item);
        mHistoryIndex.put(item.getLocation(), i);
    }
    if (createAdapter) {
        final HeaderItem historyHeader = new HeaderItem(HEADER_HISTORY, getString(R.string.history));
        mRowsAdapter.add(Math.min(2, mRowsAdapter.size()), new ListRow(historyHeader, mHistoryAdapter));
    }
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) ArrayObjectAdapter(android.support.v17.leanback.widget.ArrayObjectAdapter) HeaderItem(android.support.v17.leanback.widget.HeaderItem) ListRow(android.support.v17.leanback.widget.ListRow) MainThread(android.support.annotation.MainThread)

Aggregations

HeaderItem (android.support.v17.leanback.widget.HeaderItem)17 ArrayObjectAdapter (android.support.v17.leanback.widget.ArrayObjectAdapter)16 ListRow (android.support.v17.leanback.widget.ListRow)14 ListRowPresenter (android.support.v17.leanback.widget.ListRowPresenter)4 CardPresenterSelector (cx.ring.tv.cards.CardPresenterSelector)4 ContactCard (cx.ring.tv.cards.contacts.ContactCard)4 MediaCardPresenter (butter.droid.tv.presenters.MediaCardPresenter)3 Card (cx.ring.tv.cards.Card)3 CardListRow (cx.ring.tv.cards.CardListRow)3 CardRow (cx.ring.tv.cards.CardRow)3 ContactRequestCard (cx.ring.tv.cards.contactrequests.ContactRequestCard)3 IconCard (cx.ring.tv.cards.iconcards.IconCard)3 VCard (ezvcard.VCard)3 ClassPresenterSelector (android.support.v17.leanback.widget.ClassPresenterSelector)2 LoadingCardPresenter (butter.droid.tv.presenters.LoadingCardPresenter)2 LoadingCardItem (butter.droid.tv.presenters.LoadingCardPresenter.LoadingCardItem)2 MorePresenter (butter.droid.tv.presenters.MorePresenter)2 ShadowRowPresenterSelector (cx.ring.tv.cards.ShadowRowPresenterSelector)2 ArrayList (java.util.ArrayList)2 SearchAggregate (org.videolan.medialibrary.media.SearchAggregate)2