androidx.leanback.widget.ArrayObjectAdapter Java Examples
The following examples show how to use
androidx.leanback.widget.ArrayObjectAdapter.
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: CustomBrowseFragment.java From jellyfin-androidtv with GNU General Public License v2.0 | 6 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View root = inflater.inflate(R.layout.fragment_custom_browse, container, false); // Inject the RowsSupportFragment in the results container if (getChildFragmentManager().findFragmentById(R.id.rows_area) == null) { mRowsFragment = new RowsSupportFragment(); getChildFragmentManager().beginTransaction() .replace(R.id.rows_area, mRowsFragment).commit(); } else { mRowsFragment = (RowsSupportFragment) getChildFragmentManager() .findFragmentById(R.id.rows_area); } mRowsAdapter = new ArrayObjectAdapter(new PositionableListRowPresenter()); mRowsFragment.setAdapter(mRowsAdapter); return root; }
Example #2
Source File: CardExampleFragment.java From tv-samples with Apache License 2.0 | 6 votes |
private Row createCardRow(final CardRow cardRow) { switch (cardRow.getType()) { case CardRow.TYPE_SECTION_HEADER: return new SectionRow(new HeaderItem(cardRow.getTitle())); case CardRow.TYPE_DIVIDER: return new DividerRow(); case CardRow.TYPE_DEFAULT: default: // Build main row using the ImageCardViewPresenter. PresenterSelector presenterSelector = new CardPresenterSelector(getActivity()); ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(presenterSelector); for (Card card : cardRow.getCards()) { listRowAdapter.add(card); } return new CardListRow(new HeaderItem(cardRow.getTitle()), listRowAdapter, cardRow); } }
Example #3
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 #4
Source File: BrowseFolderFragment.java From jellyfin-androidtv with GNU General Public License v2.0 | 6 votes |
@Override protected void addAdditionalRows(ArrayObjectAdapter rowAdapter) { super.addAdditionalRows(rowAdapter); if (showViews) { HeaderItem gridHeader = new HeaderItem(rowAdapter.size(), mApplication.getString(R.string.lbl_views)); GridButtonPresenter mGridPresenter = new GridButtonPresenter(); ArrayObjectAdapter gridRowAdapter = new ArrayObjectAdapter(mGridPresenter); gridRowAdapter.add(new GridButton(BY_LETTER, mApplication.getString(R.string.lbl_by_letter), R.drawable.tile_letters)); if (itemTypeString != null && itemTypeString.equals("Movie")) gridRowAdapter.add(new GridButton(SUGGESTED, mApplication.getString(R.string.lbl_suggested), R.drawable.tile_suggestions)); gridRowAdapter.add(new GridButton(GENRES, mApplication.getString(R.string.lbl_genres), R.drawable.tile_genres)); gridRowAdapter.add(new GridButton(PERSONS, mApplication.getString(R.string.lbl_performers), R.drawable.tile_actors)); rowAdapter.add(new ListRow(gridHeader, gridRowAdapter)); } }
Example #5
Source File: PageAndListRowFragment.java From tv-samples with Apache License 2.0 | 6 votes |
private void setupAdapter() { VerticalGridPresenter presenter = new VerticalGridPresenter(ZOOM_FACTOR); presenter.setNumberOfColumns(COLUMNS); setGridPresenter(presenter); CardPresenterSelector cardPresenter = new CardPresenterSelector(getActivity()); mAdapter = new ArrayObjectAdapter(cardPresenter); setAdapter(mAdapter); setOnItemViewClickedListener(new OnItemViewClickedListener() { @Override public void onItemClicked( Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) { Card card = (Card)item; Toast.makeText(getActivity(), "Clicked on "+card.getTitle(), Toast.LENGTH_SHORT).show(); } }); }
Example #6
Source File: PageAndListRowFragment.java From tv-samples with Apache License 2.0 | 6 votes |
public SampleFragmentB() { mRowsAdapter = new ArrayObjectAdapter(new ShadowRowPresenterSelector()); setAdapter(mRowsAdapter); setOnItemViewClickedListener(new OnItemViewClickedListener() { @Override public void onItemClicked( Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) { Toast.makeText(getActivity(), "Implement click handler", Toast.LENGTH_SHORT) .show(); } }); }
Example #7
Source File: VideoPlayerGlue.java From tv-samples with Apache License 2.0 | 6 votes |
private void dispatchAction(Action action) { // Primary actions are handled manually. if (action == mRewindAction) { rewind(); } else if (action == mFastForwardAction) { fastForward(); } else if (action instanceof PlaybackControlsRow.MultiAction) { PlaybackControlsRow.MultiAction multiAction = (PlaybackControlsRow.MultiAction) action; multiAction.nextIndex(); // Notify adapter of action changes to handle secondary actions, such as, thumbs up/down // and repeat. notifyActionChanged( multiAction, (ArrayObjectAdapter) getControlsRow().getSecondaryActionsAdapter()); } }
Example #8
Source File: MainFragment.java From tv-samples with Apache License 2.0 | 6 votes |
@Override public void onActivityCreated(Bundle savedInstanceState) { // Final initialization, modifying UI elements. super.onActivityCreated(savedInstanceState); // Prepare the manager that maintains the same background image between activities. prepareBackgroundManager(); setupUIElements(); setupEventListeners(); prepareEntranceTransition(); // Map category results from the database to ListRow objects. // This Adapter is used to render the MainFragment sidebar labels. mCategoryRowAdapter = new ArrayObjectAdapter(new ListRowPresenter()); setAdapter(mCategoryRowAdapter); updateRecommendations(); }
Example #9
Source File: PlaybackFragment.java From tv-samples with Apache License 2.0 | 6 votes |
private void initializePlayer() { BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(); TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter); mTrackSelector = new DefaultTrackSelector(videoTrackSelectionFactory); mPlayer = ExoPlayerFactory.newSimpleInstance(getActivity(), mTrackSelector); mPlayerAdapter = new LeanbackPlayerAdapter(getActivity(), mPlayer, UPDATE_DELAY); mPlaylistActionListener = new PlaylistActionListener(mPlaylist); mPlayerGlue = new VideoPlayerGlue(getActivity(), mPlayerAdapter, mPlaylistActionListener); mPlayerGlue.setHost(new VideoSupportFragmentGlueHost(this)); mPlayerGlue.playWhenPrepared(); play(mVideo); ArrayObjectAdapter mRowsAdapter = initializeRelatedVideosRow(); setAdapter(mRowsAdapter); }
Example #10
Source File: MainFragment.java From androidtv-Leanback with Apache License 2.0 | 6 votes |
@Override public void onActivityCreated(Bundle savedInstanceState) { // Final initialization, modifying UI elements. super.onActivityCreated(savedInstanceState); // Prepare the manager that maintains the same background image between activities. prepareBackgroundManager(); setupUIElements(); setupEventListeners(); prepareEntranceTransition(); // Map category results from the database to ListRow objects. // This Adapter is used to render the MainFragment sidebar labels. mCategoryRowAdapter = new ArrayObjectAdapter(new ListRowPresenter()); setAdapter(mCategoryRowAdapter); updateRecommendations(); }
Example #11
Source File: PlaybackFragment.java From androidtv-Leanback with Apache License 2.0 | 6 votes |
private void initializePlayer() { BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(); TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter); mTrackSelector = new DefaultTrackSelector(videoTrackSelectionFactory); mPlayer = ExoPlayerFactory.newSimpleInstance(getActivity(), mTrackSelector); mPlayerAdapter = new LeanbackPlayerAdapter(getActivity(), mPlayer, UPDATE_DELAY); mPlaylistActionListener = new PlaylistActionListener(mPlaylist); mPlayerGlue = new VideoPlayerGlue(getActivity(), mPlayerAdapter, mPlaylistActionListener); mPlayerGlue.setHost(new VideoSupportFragmentGlueHost(this)); mPlayerGlue.playWhenPrepared(); play(mVideo); ArrayObjectAdapter mRowsAdapter = initializeRelatedVideosRow(); setAdapter(mRowsAdapter); }
Example #12
Source File: FullDetailsActivity.java From jellyfin-androidtv with GNU General Public License v2.0 | 6 votes |
private void addInfoRows(ArrayObjectAdapter adapter) { if (TvApp.getApplication().getUserPreferences().get(UserPreferences.Companion.getDebuggingEnabled()) && mBaseItem.getMediaSources() != null) { for (MediaSourceInfo ms : mBaseItem.getMediaSources()) { if (ms.getMediaStreams() != null && ms.getMediaStreams().size() > 0) { HeaderItem header = new HeaderItem("Media Details"+(ms.getContainer() != null ? " (" +ms.getContainer()+")" : "")); ArrayObjectAdapter infoAdapter = new ArrayObjectAdapter(new InfoCardPresenter()); for (MediaStream stream : ms.getMediaStreams()) { infoAdapter.add(stream); } adapter.add(new ListRow(header, infoAdapter)); } } } }
Example #13
Source File: ItemRowAdapter.java From jellyfin-androidtv with GNU General Public License v2.0 | 6 votes |
public void removeRow() { if (mParent == null) { // just clear us clear(); return; } if (mParent.size() == 1) { // we will be removing the last row - show something and prevent the framework from crashing // because there is nowhere for focus to land ArrayObjectAdapter emptyRow = new ArrayObjectAdapter(new TextItemPresenter()); emptyRow.add(TvApp.getApplication().getString(R.string.lbl_no_items)); mParent.add(new ListRow(new HeaderItem(TvApp.getApplication().getString(R.string.lbl_empty)), emptyRow)); } mParent.remove(mRow); }
Example #14
Source File: SelectServerFragment.java From jellyfin-androidtv with GNU General Public License v2.0 | 6 votes |
@Override protected void addAdditionalRows(ArrayObjectAdapter rowAdapter) { super.addAdditionalRows(rowAdapter); HeaderItem serverHeader = new HeaderItem(rowAdapter.size(), mApplication.getString(R.string.lbl_select_server)); ItemRowAdapter serverAdapter = new ItemRowAdapter(mServers.toArray(new ServerInfo[0]), new CardPresenter(), rowAdapter); serverAdapter.Retrieve(); rowAdapter.add(new ListRow(serverHeader, serverAdapter)); HeaderItem gridHeader = new HeaderItem(rowAdapter.size(), mApplication.getString(R.string.lbl_other_options)); GridButtonPresenter mGridPresenter = new GridButtonPresenter(); ArrayObjectAdapter gridRowAdapter = new ArrayObjectAdapter(mGridPresenter); gridRowAdapter.add(new GridButton(ENTER_MANUALLY, mApplication.getString(R.string.lbl_enter_manually), R.drawable.tile_edit)); rowAdapter.add(new ListRow(gridHeader, gridRowAdapter)); }
Example #15
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 #16
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 #17
Source File: EnhancedBrowseFragment.java From jellyfin-androidtv with GNU General Public License v2.0 | 6 votes |
protected void addAdditionalRows(ArrayObjectAdapter rowAdapter) { if (showViews) { HeaderItem gridHeader = new HeaderItem(rowAdapter.size(), mApplication.getString(R.string.lbl_views)); GridButtonPresenter mGridPresenter = new GridButtonPresenter(); ArrayObjectAdapter gridRowAdapter = new ArrayObjectAdapter(mGridPresenter); switch (itemTypeString) { case "Movie": gridRowAdapter.add(new GridButton(SUGGESTED, mApplication.getString(R.string.lbl_suggested), R.drawable.tile_suggestions)); addStandardViewButtons(gridRowAdapter); break; case "MusicAlbum": gridRowAdapter.add(new GridButton(ALBUMS, TvApp.getApplication().getString(R.string.lbl_albums), R.drawable.tile_audio)); gridRowAdapter.add(new GridButton(ARTISTS, TvApp.getApplication().getString(R.string.lbl_artists), R.drawable.tile_artists)); gridRowAdapter.add(new GridButton(GENRES, mApplication.getString(R.string.lbl_genres), R.drawable.tile_genres)); gridRowAdapter.add(new GridButton(SEARCH, mApplication.getString(R.string.lbl_search), R.drawable.tile_search)); break; default: addStandardViewButtons(gridRowAdapter); break; } rowAdapter.add(new ListRow(gridHeader, gridRowAdapter)); } }
Example #18
Source File: GridExampleFragment.java From tv-samples with Apache License 2.0 | 6 votes |
private void setupRowAdapter() { VerticalGridPresenter gridPresenter = new VerticalGridPresenter(ZOOM_FACTOR); gridPresenter.setNumberOfColumns(COLUMNS); setGridPresenter(gridPresenter); PresenterSelector cardPresenterSelector = new CardPresenterSelector(getActivity()); mAdapter = new ArrayObjectAdapter(cardPresenterSelector); setAdapter(mAdapter); prepareEntranceTransition(); new Handler().postDelayed(new Runnable() { @Override public void run() { createRows(); startEntranceTransition(); } }, 1000); }
Example #19
Source File: ItemRowAdapter.java From jellyfin-androidtv with GNU General Public License v2.0 | 5 votes |
public ItemRowAdapter(SeriesTimerQuery query, Presenter presenter, ArrayObjectAdapter parent) { super(presenter); mParent = parent; mSeriesTimerQuery = query; queryType = QueryType.SeriesTimer; add(new BaseRowItem(new GridButton(0, TvApp.getApplication().getString(R.string.lbl_loading_elipses), R.drawable.loading))); }
Example #20
Source File: ProviderSettingsTvFragment.java From xipl with Apache License 2.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter()); mRowsAdapter.add(new ListRow(getSettingsObjectAdapter())); setAdapter(mRowsAdapter); setOnItemViewClickedListener(new SettingsItemClickListener()); }
Example #21
Source File: ItemRowAdapter.java From jellyfin-androidtv with GNU General Public License v2.0 | 5 votes |
public ItemRowAdapter(ArtistsQuery query, int chunkSize, Presenter presenter, ArrayObjectAdapter parent) { super(presenter); mParent = parent; mArtistsQuery = query; mArtistsQuery.setUserId(TvApp.getApplication().getCurrentUser().getId()); staticHeight = true; this.chunkSize = chunkSize; if (chunkSize > 0) { mArtistsQuery.setLimit(chunkSize); } queryType = QueryType.AlbumArtists; add(new BaseRowItem(new GridButton(0, TvApp.getApplication().getString(R.string.lbl_loading_elipses), R.drawable.loading))); }
Example #22
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 #23
Source File: ItemRowAdapter.java From jellyfin-androidtv with GNU General Public License v2.0 | 5 votes |
public ItemRowAdapter(ItemQuery query, int chunkSize, boolean preferParentThumb, boolean staticHeight, Presenter presenter, ArrayObjectAdapter parent, QueryType queryType) { super(presenter); mParent = parent; mQuery = query; mQuery.setUserId(TvApp.getApplication().getCurrentUser().getId()); this.chunkSize = chunkSize; this.preferParentThumb = preferParentThumb; this.staticHeight = staticHeight; if (chunkSize > 0) { mQuery.setLimit(chunkSize); } this.queryType = queryType; add(new BaseRowItem(new GridButton(0, TvApp.getApplication().getString(R.string.lbl_loading_elipses), R.drawable.loading))); }
Example #24
Source File: ItemRowAdapter.java From jellyfin-androidtv with GNU General Public License v2.0 | 5 votes |
public ItemRowAdapter(NextUpQuery query, boolean preferParentThumb, Presenter presenter, ArrayObjectAdapter parent) { super(presenter); mParent = parent; mNextUpQuery = query; mNextUpQuery.setUserId(TvApp.getApplication().getCurrentUser().getId()); queryType = QueryType.NextUp; this.preferParentThumb = preferParentThumb; this.staticHeight = true; add(new BaseRowItem(new GridButton(0, TvApp.getApplication().getString(R.string.lbl_loading_elipses), R.drawable.loading))); }
Example #25
Source File: ItemRowAdapter.java From jellyfin-androidtv with GNU General Public License v2.0 | 5 votes |
public ItemRowAdapter(List<ChapterItemInfo> chapters, Presenter presenter, ArrayObjectAdapter parent) { super(presenter); mParent = parent; mChapters = chapters; staticHeight = true; queryType = QueryType.StaticChapters; }
Example #26
Source File: FullDetailsActivity.java From jellyfin-androidtv with GNU General Public License v2.0 | 5 votes |
protected void addItemRow(ArrayObjectAdapter parent, ItemRowAdapter row, int index, String headerText) { HeaderItem header = new HeaderItem(index, headerText); ListRow listRow = new ListRow(header, row); parent.add(listRow); row.setRow(listRow); row.Retrieve(); }
Example #27
Source File: ItemRowAdapter.java From jellyfin-androidtv with GNU General Public License v2.0 | 5 votes |
public ItemRowAdapter(SpecialsQuery query, Presenter presenter, ArrayObjectAdapter parent) { super(presenter); mParent = parent; mSpecialsQuery = query; queryType = QueryType.Specials; add(new BaseRowItem(new GridButton(0, TvApp.getApplication().getString(R.string.lbl_loading_elipses), R.drawable.loading))); }
Example #28
Source File: ItemRowAdapter.java From jellyfin-androidtv with GNU General Public License v2.0 | 5 votes |
public ItemRowAdapter(TrailersQuery query, Presenter presenter, ArrayObjectAdapter parent) { super(presenter); mParent = parent; mTrailersQuery = query; queryType = QueryType.Trailers; add(new BaseRowItem(new GridButton(0, TvApp.getApplication().getString(R.string.lbl_loading_elipses), R.drawable.loading))); }
Example #29
Source File: ItemRowAdapter.java From jellyfin-androidtv with GNU General Public License v2.0 | 5 votes |
public ItemRowAdapter(LiveTvChannelQuery query, int chunkSize, Presenter presenter, ArrayObjectAdapter parent) { super(presenter); mParent = parent; mTvChannelQuery = query; this.chunkSize = chunkSize; if (chunkSize > 0) { mTvChannelQuery.setLimit(chunkSize); } queryType = QueryType.LiveTvChannel; add(new BaseRowItem(new GridButton(0, TvApp.getApplication().getString(R.string.lbl_loading_elipses), R.drawable.loading))); }
Example #30
Source File: ItemRowAdapter.java From jellyfin-androidtv with GNU General Public License v2.0 | 5 votes |
public ItemRowAdapter(LatestItemsQuery query, boolean preferParentThumb, Presenter presenter, ArrayObjectAdapter parent) { super(presenter); mParent = parent; mLatestQuery = query; mLatestQuery.setUserId(TvApp.getApplication().getCurrentUser().getId()); queryType = QueryType.LatestItems; this.preferParentThumb = preferParentThumb; add(new BaseRowItem(new GridButton(0, TvApp.getApplication().getString(R.string.lbl_loading_elipses), R.drawable.loading))); }