Search in sources :

Example 16 with HeaderItem

use of android.support.v17.leanback.widget.HeaderItem in project butter-android by butterproject.

the class TVShowDetailsFragment method showSeasons.

@Override
public void showSeasons(final Season[] seasons) {
    ArrayObjectAdapter objectAdapter = getObjectArrayAdapter();
    for (int i = 0; i < seasons.length; i++) {
        Season season = seasons[i];
        HeaderItem header = new HeaderItem(i, season.getTitle());
        EpisodeCardPresenter presenter = new EpisodeCardPresenter(getActivity());
        presenter.setOnClickListener(this);
        ArrayObjectAdapter episodes = new ArrayObjectAdapter(presenter);
        for (final Episode episode : season.getEpisodes()) {
            episodes.add(episode);
        }
        objectAdapter.add(new ListRow(header, episodes));
    }
    objectAdapter.notifyArrayItemRangeChanged(1, objectAdapter.size());
}
Also used : Episode(butter.droid.provider.base.model.Episode) ArrayObjectAdapter(android.support.v17.leanback.widget.ArrayObjectAdapter) HeaderItem(android.support.v17.leanback.widget.HeaderItem) Season(butter.droid.provider.base.model.Season) ListRow(android.support.v17.leanback.widget.ListRow) EpisodeCardPresenter(butter.droid.tv.ui.detail.show.presenter.EpisodeCardPresenter)

Example 17 with HeaderItem

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

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)

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