Search in sources :

Example 1 with MediaCardPresenter

use of butter.droid.tv.presenters.MediaCardPresenter in project butter-android by butterproject.

the class TVSearchFragment method createLoadingRow.

private ListRow createLoadingRow() {
    final HeaderItem loadingHeader = new HeaderItem(getString(R.string.search_results));
    ClassPresenterSelector presenterSelector = new ClassPresenterSelector();
    presenterSelector.addClassPresenter(MediaCardItem.class, new MediaCardPresenter(getActivity(), picasso));
    presenterSelector.addClassPresenter(LoadingCardItem.class, new LoadingCardPresenter(getActivity()));
    ArrayObjectAdapter loadingRowAdapter = new ArrayObjectAdapter(presenterSelector);
    loadingRowAdapter.add(new LoadingCardItem());
    return new ListRow(loadingHeader, loadingRowAdapter);
}
Also used : LoadingCardPresenter(butter.droid.tv.presenters.LoadingCardPresenter) HeaderItem(android.support.v17.leanback.widget.HeaderItem) ArrayObjectAdapter(android.support.v17.leanback.widget.ArrayObjectAdapter) LoadingCardItem(butter.droid.tv.presenters.LoadingCardPresenter.LoadingCardItem) ClassPresenterSelector(android.support.v17.leanback.widget.ClassPresenterSelector) MediaCardPresenter(butter.droid.tv.presenters.MediaCardPresenter) ListRow(android.support.v17.leanback.widget.ListRow)

Example 2 with MediaCardPresenter

use of butter.droid.tv.presenters.MediaCardPresenter in project butter-android by butterproject.

the class TVSearchFragment method replaceRow.

@Override
public void replaceRow(int index, @StringRes int title, List<MediaCardItem> items) {
    rowsAdapter.remove(loadingRow);
    HeaderItem header = new HeaderItem(getString(title));
    ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(new MediaCardPresenter(getActivity(), picasso));
    listRowAdapter.addAll(0, items);
    ListRow row = new ListRow(header, listRowAdapter);
    if (rowsAdapter.size() > index) {
        rowsAdapter.replace(index, row);
    } else {
        rowsAdapter.add(index, row);
    }
}
Also used : HeaderItem(android.support.v17.leanback.widget.HeaderItem) ArrayObjectAdapter(android.support.v17.leanback.widget.ArrayObjectAdapter) MediaCardPresenter(butter.droid.tv.presenters.MediaCardPresenter) ListRow(android.support.v17.leanback.widget.ListRow)

Example 3 with MediaCardPresenter

use of butter.droid.tv.presenters.MediaCardPresenter in project butter-android by butterproject.

the class TVMediaGridFragment method setupUi.

private void setupUi() {
    VerticalGridPresenter gridPresenter = new VerticalGridPresenter();
    gridPresenter.setNumberOfColumns(NUM_COLUMNS);
    setGridPresenter(gridPresenter);
    ClassPresenterSelector presenterSelector = new ClassPresenterSelector();
    presenterSelector.addClassPresenter(MediaCardItem.class, new MediaCardPresenter(getActivity(), picasso));
    presenterSelector.addClassPresenter(LoadingCardItem.class, new LoadingCardPresenter(getActivity()));
    adapter = new GridPagingAdapter(presenterSelector);
    setAdapter(adapter);
    pagingManager = new GridPagingManager<>();
    pagingManager.init(NUM_COLUMNS, adapter, this);
    setOnItemViewClickedListener(this);
    setOnItemViewSelectedListener(this);
}
Also used : GridPagingAdapter(butter.droid.tv.manager.internal.paging.GridPagingAdapter) VerticalGridPresenter(android.support.v17.leanback.widget.VerticalGridPresenter) LoadingCardPresenter(butter.droid.tv.presenters.LoadingCardPresenter) ClassPresenterSelector(android.support.v17.leanback.widget.ClassPresenterSelector) MediaCardPresenter(butter.droid.tv.presenters.MediaCardPresenter)

Example 4 with MediaCardPresenter

use of butter.droid.tv.presenters.MediaCardPresenter in project butter-android by butterproject.

the class TVOverviewFragment method addNewMediaListAdapter.

private ArrayObjectAdapter addNewMediaListAdapter() {
    Context context = requireContext();
    ClassPresenterSelector presenterSelector = new ClassPresenterSelector();
    presenterSelector.addClassPresenter(MediaCardItem.class, new MediaCardPresenter(context, picasso));
    presenterSelector.addClassPresenter(LoadingCardItem.class, new LoadingCardPresenter(context));
    ArrayObjectAdapter mediaAdapter = new ArrayObjectAdapter(presenterSelector);
    mediaAdapter.add(new LoadingCardItem());
    // TODO: 6/17/17 Define title
    HeaderItem moviesHeader = new HeaderItem(getString(R.string.top_movies));
    rowsAdapter.add(new ListRow(moviesHeader, mediaAdapter));
    return mediaAdapter;
}
Also used : Context(android.content.Context) LoadingCardPresenter(butter.droid.tv.presenters.LoadingCardPresenter) ArrayObjectAdapter(android.support.v17.leanback.widget.ArrayObjectAdapter) LoadingCardItem(butter.droid.tv.presenters.LoadingCardPresenter.LoadingCardItem) HeaderItem(android.support.v17.leanback.widget.HeaderItem) ClassPresenterSelector(android.support.v17.leanback.widget.ClassPresenterSelector) MediaCardPresenter(butter.droid.tv.presenters.MediaCardPresenter) ListRow(android.support.v17.leanback.widget.ListRow)

Aggregations

MediaCardPresenter (butter.droid.tv.presenters.MediaCardPresenter)4 ArrayObjectAdapter (android.support.v17.leanback.widget.ArrayObjectAdapter)3 ClassPresenterSelector (android.support.v17.leanback.widget.ClassPresenterSelector)3 HeaderItem (android.support.v17.leanback.widget.HeaderItem)3 ListRow (android.support.v17.leanback.widget.ListRow)3 LoadingCardPresenter (butter.droid.tv.presenters.LoadingCardPresenter)3 LoadingCardItem (butter.droid.tv.presenters.LoadingCardPresenter.LoadingCardItem)2 Context (android.content.Context)1 VerticalGridPresenter (android.support.v17.leanback.widget.VerticalGridPresenter)1 GridPagingAdapter (butter.droid.tv.manager.internal.paging.GridPagingAdapter)1