androidx.leanback.widget.ClassPresenterSelector Java Examples
The following examples show how to use
androidx.leanback.widget.ClassPresenterSelector.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PlaybackFragment.java From tv-samples with Apache License 2.0 | 6 votes |
private ArrayObjectAdapter initializeRelatedVideosRow() { /* * To add a new row to the mPlayerAdapter and not lose the controls row that is provided by the * glue, we need to compose a new row with the controls row and our related videos row. * * We start by creating a new {@link ClassPresenterSelector}. Then add the controls row from * the media player glue, then add the related videos row. */ ClassPresenterSelector presenterSelector = new ClassPresenterSelector(); presenterSelector.addClassPresenter( mPlayerGlue.getControlsRow().getClass(), mPlayerGlue.getPlaybackRowPresenter()); presenterSelector.addClassPresenter(ListRow.class, new ListRowPresenter()); ArrayObjectAdapter rowsAdapter = new ArrayObjectAdapter(presenterSelector); rowsAdapter.add(mPlayerGlue.getControlsRow()); HeaderItem header = new HeaderItem(getString(R.string.related_movies)); ListRow row = new ListRow(header, mVideoCursorAdapter); rowsAdapter.add(row); setOnItemViewClickedListener(new ItemViewClickedListener()); return rowsAdapter; }
Example #2
Source File: FullDetailsActivity.java From jellyfin-androidtv with GNU General Public License v2.0 | 6 votes |
@Override protected void onPostExecute(MyDetailsOverviewRow detailsOverviewRow) { super.onPostExecute(detailsOverviewRow); if (isFinishing()) return; ClassPresenterSelector ps = new ClassPresenterSelector(); ps.addClassPresenter(MyDetailsOverviewRow.class, mDorPresenter); mListRowPresenter = new CustomListRowPresenter(getDrawable(R.color.black_transparent_light), Utils.convertDpToPixel(mActivity, 10)); ps.addClassPresenter(ListRow.class, mListRowPresenter); mRowsAdapter = new ArrayObjectAdapter(ps); mRowsFragment.setAdapter(mRowsAdapter); mRowsAdapter.add(detailsOverviewRow); updateInfo(detailsOverviewRow.getItem()); addAdditionalRows(mRowsAdapter); }
Example #3
Source File: PlaybackFragment.java From androidtv-Leanback with Apache License 2.0 | 6 votes |
private ArrayObjectAdapter initializeRelatedVideosRow() { /* * To add a new row to the mPlayerAdapter and not lose the controls row that is provided by the * glue, we need to compose a new row with the controls row and our related videos row. * * We start by creating a new {@link ClassPresenterSelector}. Then add the controls row from * the media player glue, then add the related videos row. */ ClassPresenterSelector presenterSelector = new ClassPresenterSelector(); presenterSelector.addClassPresenter( mPlayerGlue.getControlsRow().getClass(), mPlayerGlue.getPlaybackRowPresenter()); presenterSelector.addClassPresenter(ListRow.class, new ListRowPresenter()); ArrayObjectAdapter rowsAdapter = new ArrayObjectAdapter(presenterSelector); rowsAdapter.add(mPlayerGlue.getControlsRow()); HeaderItem header = new HeaderItem(getString(R.string.related_movies)); ListRow row = new ListRow(header, mVideoCursorAdapter); rowsAdapter.add(row); setOnItemViewClickedListener(new ItemViewClickedListener()); return rowsAdapter; }
Example #4
Source File: VideoDetailsFragment.java From tv-samples with Apache License 2.0 | 5 votes |
private void setupAdapter() { // Set detail background and style. FullWidthDetailsOverviewRowPresenter detailsPresenter = new FullWidthDetailsOverviewRowPresenter(new DetailsDescriptionPresenter(), new MovieDetailsOverviewLogoPresenter()); detailsPresenter.setBackgroundColor( ContextCompat.getColor(getActivity(), R.color.selected_background)); detailsPresenter.setInitialState(FullWidthDetailsOverviewRowPresenter.STATE_HALF); // Hook up transition element. mHelper = new FullWidthDetailsOverviewSharedElementHelper(); mHelper.setSharedElementEnterTransition(getActivity(), VideoDetailsActivity.SHARED_ELEMENT_NAME); detailsPresenter.setListener(mHelper); detailsPresenter.setParticipatingEntranceTransition(false); prepareEntranceTransition(); detailsPresenter.setOnActionClickedListener(new OnActionClickedListener() { @Override public void onActionClicked(Action action) { if (action.getId() == ACTION_WATCH_TRAILER) { Intent intent = new Intent(getActivity(), PlaybackActivity.class); intent.putExtra(VideoDetailsActivity.VIDEO, mSelectedVideo); startActivity(intent); } else { Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show(); } } }); mPresenterSelector = new ClassPresenterSelector(); mPresenterSelector.addClassPresenter(DetailsOverviewRow.class, detailsPresenter); mPresenterSelector.addClassPresenter(ListRow.class, new ListRowPresenter()); mAdapter = new ArrayObjectAdapter(mPresenterSelector); setAdapter(mAdapter); }
Example #5
Source File: VideoDetailsFragment.java From androidtv-Leanback with Apache License 2.0 | 5 votes |
private void setupAdapter() { // Set detail background and style. FullWidthDetailsOverviewRowPresenter detailsPresenter = new FullWidthDetailsOverviewRowPresenter(new DetailsDescriptionPresenter(), new MovieDetailsOverviewLogoPresenter()); detailsPresenter.setBackgroundColor( ContextCompat.getColor(getActivity(), R.color.selected_background)); detailsPresenter.setInitialState(FullWidthDetailsOverviewRowPresenter.STATE_HALF); // Hook up transition element. mHelper = new FullWidthDetailsOverviewSharedElementHelper(); mHelper.setSharedElementEnterTransition(getActivity(), VideoDetailsActivity.SHARED_ELEMENT_NAME); detailsPresenter.setListener(mHelper); detailsPresenter.setParticipatingEntranceTransition(false); prepareEntranceTransition(); detailsPresenter.setOnActionClickedListener(new OnActionClickedListener() { @Override public void onActionClicked(Action action) { if (action.getId() == ACTION_WATCH_TRAILER) { Intent intent = new Intent(getActivity(), PlaybackActivity.class); intent.putExtra(VideoDetailsActivity.VIDEO, mSelectedVideo); startActivity(intent); } else { Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show(); } } }); mPresenterSelector = new ClassPresenterSelector(); mPresenterSelector.addClassPresenter(DetailsOverviewRow.class, detailsPresenter); mPresenterSelector.addClassPresenter(ListRow.class, new ListRowPresenter()); mAdapter = new ArrayObjectAdapter(mPresenterSelector); setAdapter(mAdapter); }
Example #6
Source File: EnhancedBrowseFragment.java From jellyfin-androidtv with GNU General Public License v2.0 | 4 votes |
public void loadRows(List<BrowseRowDef> rows) { mRowsAdapter = new ArrayObjectAdapter(new PositionableListRowPresenter()); mCardPresenter = new CardPresenter(false, 280); ClassPresenterSelector ps = new ClassPresenterSelector(); ps.addClassPresenter(BaseRowItem.class, mCardPresenter); ps.addClassPresenter(GridButton.class, new GridButtonPresenter(false, 310, 280)); for (BrowseRowDef def : rows) { HeaderItem header = new HeaderItem(def.getHeaderText()); ItemRowAdapter rowAdapter; switch (def.getQueryType()) { case NextUp: rowAdapter = new ItemRowAdapter(def.getNextUpQuery(), true, mCardPresenter, mRowsAdapter); break; case LatestItems: rowAdapter = new ItemRowAdapter(def.getLatestItemsQuery(), true, mCardPresenter, mRowsAdapter); break; case Season: rowAdapter = new ItemRowAdapter(def.getSeasonQuery(), mCardPresenter, mRowsAdapter); break; case Upcoming: rowAdapter = new ItemRowAdapter(def.getUpcomingQuery(), mCardPresenter, mRowsAdapter); break; case Views: rowAdapter = new ItemRowAdapter(new ViewQuery(), mCardPresenter, mRowsAdapter); break; case SimilarSeries: rowAdapter = new ItemRowAdapter(def.getSimilarQuery(), QueryType.SimilarSeries, mCardPresenter, mRowsAdapter); break; case SimilarMovies: rowAdapter = new ItemRowAdapter(def.getSimilarQuery(), QueryType.SimilarMovies, mCardPresenter, mRowsAdapter); break; case Persons: rowAdapter = new ItemRowAdapter(def.getPersonsQuery(), def.getChunkSize(), mCardPresenter, mRowsAdapter); break; case LiveTvChannel: rowAdapter = new ItemRowAdapter(def.getTvChannelQuery(), 40, mCardPresenter, mRowsAdapter); break; case LiveTvProgram: rowAdapter = new ItemRowAdapter(def.getProgramQuery(), mCardPresenter, mRowsAdapter); break; case LiveTvRecording: rowAdapter = new ItemRowAdapter(def.getRecordingQuery(), def.getChunkSize(), mCardPresenter, mRowsAdapter); break; case LiveTvRecordingGroup: rowAdapter = new ItemRowAdapter(def.getRecordingGroupQuery(), mCardPresenter, mRowsAdapter); break; case Premieres: rowAdapter = new ItemRowAdapter(def.getQuery(), def.getChunkSize(), def.getPreferParentThumb(), def.isStaticHeight(), mCardPresenter, mRowsAdapter, def.getQueryType()); break; case SeriesTimer: rowAdapter = new ItemRowAdapter(def.getSeriesTimerQuery(), mCardPresenter, mRowsAdapter); break; default: rowAdapter = new ItemRowAdapter(def.getQuery(), def.getChunkSize(), def.getPreferParentThumb(), def.isStaticHeight(), ps, mRowsAdapter, def.getQueryType()); break; } rowAdapter.setReRetrieveTriggers(def.getChangeTriggers()); ListRow row = new ListRow(header, rowAdapter); mRowsAdapter.add(row); rowAdapter.setRow(row); rowAdapter.Retrieve(); } addAdditionalRows(mRowsAdapter); mRowsFragment.setAdapter(mRowsAdapter); }