android.support.v17.leanback.widget.HeaderItem Java Examples
The following examples show how to use
android.support.v17.leanback.widget.HeaderItem.
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: LeanbackBrowseFragment.java From android-tv-leanback with Apache License 2.0 | 6 votes |
public void init() { mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter()); setAdapter(mRowsAdapter); setBrandColor(ContextCompat.getColor(getContext(), R.color.primary)); setBadgeDrawable(ContextCompat.getDrawable(getContext(), R.drawable.filmi)); for (int position = 0; position < HEADERS.length; position++) { ObjectAdapter rowContents = new CursorObjectAdapter((new SinglePresenterSelector(new CardPresenter()))); VideoDataManager manager = new VideoDataManager(getActivity(), getLoaderManager(), VideoItemContract.VideoItem.buildDirUri(), rowContents); manager.startDataLoading(); HeaderItem headerItem = new HeaderItem(position, HEADERS[position]); mRowsAdapter.add(new ListRow(headerItem, manager.getItemList())); } }
Example #2
Source File: LeanbackBrowseFragment.java From android-tv-leanback with Apache License 2.0 | 6 votes |
public void init() { mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter()); setAdapter(mRowsAdapter); setBrandColor(ContextCompat.getColor(getContext(), R.color.primary)); setBadgeDrawable(ContextCompat.getDrawable(getContext(), R.drawable.filmi)); for (int position = 0; position < HEADERS.length; position++) { ObjectAdapter rowContents = new CursorObjectAdapter((new SinglePresenterSelector(new CardPresenter()))); VideoDataManager manager = new VideoDataManager(getActivity(), getLoaderManager(), VideoItemContract.VideoItem.buildDirUri(), rowContents); manager.startDataLoading(); HeaderItem headerItem = new HeaderItem(position, HEADERS[position]); mRowsAdapter.add(new ListRow(headerItem, manager.getItemList())); } setOnItemViewClickedListener(getDefaultItemViewClickedListener()); setOnItemViewSelectedListener(getDefaultItemSelectedListener()); bgHelper = new BackgroundHelper(getActivity()); bgHelper.prepareBackgroundManager(); }
Example #3
Source File: LeanbackBrowseFragment.java From android-tv-leanback with Apache License 2.0 | 6 votes |
public void init() { mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter()); setAdapter(mRowsAdapter); setBrandColor(ContextCompat.getColor(getContext(), R.color.primary)); setBadgeDrawable(ContextCompat.getDrawable(getContext(), R.drawable.filmi)); for (int position = 0; position < HEADERS.length; position++) { ObjectAdapter rowContents = new CursorObjectAdapter((new SinglePresenterSelector(new CardPresenter()))); VideoDataManager manager = new VideoDataManager(getActivity(), getLoaderManager(), VideoItemContract.VideoItem.buildDirUri(), rowContents); manager.startDataLoading(); HeaderItem headerItem = new HeaderItem(position, HEADERS[position]); mRowsAdapter.add(new ListRow(headerItem, manager.getItemList())); } setOnItemViewClickedListener(getDefaultItemViewClickedListener()); }
Example #4
Source File: LeanbackBrowseFragment.java From android-tv-leanback with Apache License 2.0 | 6 votes |
public void init() { mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter()); setAdapter(mRowsAdapter); setBrandColor(ContextCompat.getColor(getContext(), R.color.primary)); setBadgeDrawable(ContextCompat.getDrawable(getContext(), R.drawable.filmi)); for (int position = 0; position < HEADERS.length; position++) { ObjectAdapter rowContents = new CursorObjectAdapter((new SinglePresenterSelector(new CardPresenter()))); VideoDataManager manager = new VideoDataManager(getActivity(), getLoaderManager(), VideoItemContract.VideoItem.buildDirUri(), rowContents); manager.startDataLoading(); HeaderItem headerItem = new HeaderItem(position, HEADERS[position]); mRowsAdapter.add(new ListRow(headerItem, manager.getItemList())); } setOnItemViewClickedListener(getDefaultItemViewClickedListener()); }
Example #5
Source File: CustomRowsFragment.java From BuildingForAndroidTV with MIT License | 6 votes |
private void loadRows() { rowsAdapter = new ArrayObjectAdapter(new ListRowPresenter()); cardPresenter = new CardPresenter(); List<Movie> list = MovieList.setupMovies(); int i; for (i = 0; i < NUM_ROWS; i++) { if (i != 0) { Collections.shuffle(list); } ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(cardPresenter); for (int j = 0; j < NUM_COLS; j++) { listRowAdapter.add(list.get(j % 5)); } HeaderItem header = new HeaderItem(i, MovieList.MOVIE_CATEGORY[i], null); rowsAdapter.add(new ListRow(header, listRowAdapter)); } setAdapter(rowsAdapter); }
Example #6
Source File: CustomHeadersFragment.java From BuildingForAndroidTV with MIT License | 6 votes |
private void setHeaderAdapter() { adapter = new ArrayObjectAdapter(); LinkedHashMap<Integer, CustomRowsFragment> fragments = ((TVDemoActivity) getActivity()).getFragments(); int id = 0; for (int i = 0; i < fragments.size(); i++) { HeaderItem header = new HeaderItem(id, "Category " + i, null); ArrayObjectAdapter innerAdapter = new ArrayObjectAdapter(); innerAdapter.add(fragments.get(i)); adapter.add(id, new ListRow(header, innerAdapter)); id++; } setAdapter(adapter); }
Example #7
Source File: LeanbackBrowseFragment.java From android-tv-leanback with Apache License 2.0 | 6 votes |
public void init() { mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter()); setAdapter(mRowsAdapter); setBrandColor(ContextCompat.getColor(getContext(), R.color.primary)); setBadgeDrawable(ContextCompat.getDrawable(getContext(), R.drawable.filmi)); for (int position = 0; position < HEADERS.length; position++) { ObjectAdapter rowContents = new CursorObjectAdapter((new SinglePresenterSelector(new CardPresenter()))); VideoDataManager manager = new VideoDataManager(getActivity(), getLoaderManager(), VideoItemContract.VideoItem.buildDirUri(), rowContents); manager.startDataLoading(); HeaderItem headerItem = new HeaderItem(position, HEADERS[position]); mRowsAdapter.add(new ListRow(headerItem, manager.getItemList())); } setOnItemViewClickedListener(getDefaultItemViewClickedListener()); setOnItemViewSelectedListener(getDefaultItemSelectedListener()); bgHelper = new BackgroundHelper(getActivity()); bgHelper.prepareBackgroundManager(); }
Example #8
Source File: MainFragment.java From AndroidDemoProjects with Apache License 2.0 | 6 votes |
private void loadRows() { ArrayObjectAdapter rowsAdapter = new ArrayObjectAdapter( new ListRowPresenter() ); CardPresenter cardPresenter = new CardPresenter(); List<String> categories = getCategories(); if( categories == null || categories.isEmpty() ) return; for( String category : categories ) { ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter( cardPresenter ); for( Movie movie : mMovies ) { if( category.equalsIgnoreCase( movie.getCategory() ) ) listRowAdapter.add( movie ); } if( listRowAdapter.size() > 0 ) { HeaderItem header = new HeaderItem( rowsAdapter.size() - 1, category, null ); rowsAdapter.add( new ListRow( header, listRowAdapter ) ); } } setupPreferences( rowsAdapter ); setAdapter( rowsAdapter ); }
Example #9
Source File: SearchFragment.java From Amphitheatre with Apache License 2.0 | 6 votes |
private void loadRows(String query) { mListRowAdapter.clear(); Map<String, Video> searchMap = new HashMap<String, Video>(); for (Video video : allVideos) { if (video == null || video.getName() == null) { continue; } if (video.getName().toLowerCase().contains(query.toLowerCase())) { if (!searchMap.containsKey(video.getName())) { searchMap.put(video.getName(), video); } } } mListRowAdapter.addAll(0, searchMap.values()); HeaderItem header = new HeaderItem(0, getResources().getString(R.string.search_results), null); mRowsAdapter.add(new ListRow(header, mListRowAdapter)); }
Example #10
Source File: PageAndListRowFragment.java From leanback-showcase with Apache License 2.0 | 6 votes |
private void createRows() { HeaderItem headerItem1 = new HeaderItem(HEADER_ID_1, HEADER_NAME_1); PageRow pageRow1 = new PageRow(headerItem1); mRowsAdapter.add(pageRow1); HeaderItem headerItem2 = new HeaderItem(HEADER_ID_2, HEADER_NAME_2); PageRow pageRow2 = new PageRow(headerItem2); mRowsAdapter.add(pageRow2); HeaderItem headerItem3 = new HeaderItem(HEADER_ID_3, HEADER_NAME_3); PageRow pageRow3 = new PageRow(headerItem3); mRowsAdapter.add(pageRow3); HeaderItem headerItem4 = new HeaderItem(HEADER_ID_4, HEADER_NAME_4); PageRow pageRow4 = new PageRow(headerItem4); mRowsAdapter.add(pageRow4); }
Example #11
Source File: CustomRowsFragment.java From BuildingForAndroidTV with MIT License | 6 votes |
private void loadRows() { rowsAdapter = new ArrayObjectAdapter(new ListRowPresenter()); cardPresenter = new CardPresenter(); List<Movie> list = MovieList.setupMovies(); int i; for (i = 0; i < NUM_ROWS; i++) { if (i != 0) { Collections.shuffle(list); } ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(cardPresenter); for (int j = 0; j < NUM_COLS; j++) { listRowAdapter.add(list.get(j % 5)); } HeaderItem header = new HeaderItem(i, MovieList.MOVIE_CATEGORY[i], null); rowsAdapter.add(new ListRow(header, listRowAdapter)); } setAdapter(rowsAdapter); }
Example #12
Source File: CardExampleFragment.java From leanback-showcase 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 #13
Source File: CustomHeadersFragment.java From BuildingForAndroidTV with MIT License | 6 votes |
private void setHeaderAdapter() { adapter = new ArrayObjectAdapter(); LinkedHashMap<Integer, CustomRowsFragment> fragments = ((TVDemoActivity) getActivity()).getFragments(); int id = 0; for (int i = 0; i < fragments.size(); i++) { HeaderItem header = new HeaderItem(id, "Category " + i, null); ArrayObjectAdapter innerAdapter = new ArrayObjectAdapter(); innerAdapter.add(fragments.get(i)); adapter.add(id, new ListRow(header, innerAdapter)); id++; } setAdapter(adapter); }
Example #14
Source File: MainFragment.java From TvAppRepo with Apache License 2.0 | 6 votes |
private void loadRows() { mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter()); mApkDownloadHelper = new ApkDownloadHelper(getActivity()); // Setup the package installer for the session mApkDownloadHelper.addListener(mDownloadListener); HeaderItem header = null; if (getResources().getBoolean(R.bool.ENABLE_APP_REPO)) { createRowApkDownloads(); } if (getResources().getBoolean(R.bool.ENABLE_DOWNLOADS_ROW)) { createRowDownloadedApks(); } createRowShortcutGenerator(); createRowCustomShortcuts(); createRowMisc(); setAdapter(mRowsAdapter); }
Example #15
Source File: BrowseFragment.java From Amphitheatre with Apache License 2.0 | 6 votes |
private void addRecentlyAddedMovies(List<Video> movies, ListRow unMatchedRow) { if (!movies.isEmpty()) { ListRow row = findListRow(getString(R.string.recently_added_movies)); if (row != null) { ((ArrayObjectAdapter) row.getAdapter()).clear(); ((ArrayObjectAdapter) row.getAdapter()).addAll(0, movies); } else { ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(mCardPresenter); listRowAdapter.addAll(0, movies); HeaderItem header = new HeaderItem(0, getString(R.string.recently_added_movies), null); int index = mAdapter.size() > 1 ? mAdapter.size() - 1 : 0; if (unMatchedRow != null) index -= 1; mAdapter.add(index, new ListRow(header, listRowAdapter)); } } }
Example #16
Source File: DetailsFragment.java From iview-android-tv with MIT License | 6 votes |
private void updateRelatedEpisodes(Map<String, List<EpisodeBaseModel>> others) { boolean updated = false; ArrayObjectAdapter adapter = (ArrayObjectAdapter) getAdapter(); for (Map.Entry<String, List<EpisodeBaseModel>> list : others.entrySet()) { String title = list.getKey(); Log.d(TAG, "More: " + title); if (ContentManagerBase.OTHER_EPISODES.equals(title)) { otherEpisodes.addAll(otherEpisodes.size(), list.getValue()); } else { ArrayObjectAdapter more = new ArrayObjectAdapter(new CardSelector()); more.addAll(0, list.getValue()); adapter.add(new ListRow(new HeaderItem(0, title), more)); } updated = true; } if (updated) { adapter.notifyArrayItemRangeChanged(0, adapter.size()); } }
Example #17
Source File: MoreSamplesFragment.java From BuildingForAndroidTV with MIT License | 6 votes |
private void loadRows() { rowsAdapter = new ArrayObjectAdapter(new ListRowPresenter()); HeaderItem gridHeader = new HeaderItem(1, getString(R.string.more_samples)); GridItemPresenter gridPresenter = new GridItemPresenter(this); ArrayObjectAdapter gridRowAdapter = new ArrayObjectAdapter(gridPresenter); gridRowAdapter.add(getString(R.string.grid_view)); gridRowAdapter.add(getString(R.string.guidedstep_first_title)); gridRowAdapter.add(getString(R.string.error_fragment)); gridRowAdapter.add(getString(R.string.personal_settings)); rowsAdapter.add(new ListRow(gridHeader, gridRowAdapter)); setAdapter(rowsAdapter); }
Example #18
Source File: BrowseFragment.java From Amphitheatre with Apache License 2.0 | 6 votes |
private void addRecentlyAddedTvShows(List<Video> tvShows, ListRow unMatchedRow) { if (!tvShows.isEmpty()) { ListRow row = findListRow(getString(R.string.recently_added_tv_episodes)); if (row != null) { ((ArrayObjectAdapter) row.getAdapter()).clear(); ((ArrayObjectAdapter) row.getAdapter()).addAll(0, tvShows); } else { ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(mTvShowsCardPresenter); listRowAdapter.addAll(0, tvShows); HeaderItem header = new HeaderItem(0, getString(R.string.recently_added_tv_episodes), null); int index = mAdapter.size() > 1 ? mAdapter.size() - 1 : 0; if (unMatchedRow != null) index -= 1; mAdapter.add(index, new ListRow(header, listRowAdapter)); } } }
Example #19
Source File: CustomRowsFragment.java From BuildingForAndroidTV with MIT License | 6 votes |
@Override public void onLoadFinished(Loader<HashMap<String, List<Movie>>> arg0, HashMap<String, List<Movie>> data) { rowsAdapter = new ArrayObjectAdapter(new ListRowPresenter()); CardPresenter cardPresenter = new CardPresenter(); int i = 0; for (Map.Entry<String, List<Movie>> entry : data.entrySet()) { ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(cardPresenter); List<Movie> list = entry.getValue(); for (int j = 0; j < list.size(); j++) { listRowAdapter.add(list.get(j)); } HeaderItem header = new HeaderItem(i, entry.getKey()); i++; rowsAdapter.add(new ListRow(header, listRowAdapter)); } setAdapter(rowsAdapter); updateRecommendations(); }
Example #20
Source File: TvMainActivity.java From citra_android with GNU General Public License v3.0 | 6 votes |
private ListRow buildSettingsRow() { ArrayObjectAdapter rowItems = new ArrayObjectAdapter(new SettingsRowPresenter()); rowItems.add(new TvSettingsItem(R.id.menu_settings_core, R.drawable.ic_settings_core_tv, R.string.grid_menu_core_settings)); rowItems.add(new TvSettingsItem(R.id.button_add_directory, R.drawable.ic_add_tv, R.string.add_directory_title)); rowItems.add(new TvSettingsItem(R.id.menu_refresh, R.drawable.ic_refresh_tv, R.string.grid_menu_refresh)); // Create a header for this row. HeaderItem header = new HeaderItem(R.string.preferences_settings, getString(R.string.preferences_settings)); return new ListRow(header, rowItems); }
Example #21
Source File: MovieDetailsFragment.java From BuildingForAndroidTV with MIT License | 6 votes |
private void setupMovieListRow() { String subcategories[] = {getString(R.string.related_movies)}; HashMap<String, List<Movie>> movies = VideoProvider.getMovieList(); ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(new CardPresenter()); for (Map.Entry<String, List<Movie>> entry : movies.entrySet()) { if (mSelectedMovie.getCategory().indexOf(entry.getKey()) >= 0) { List<Movie> list = entry.getValue(); for (int j = 0; j < list.size(); j++) { listRowAdapter.add(list.get(j)); } } } HeaderItem header = new HeaderItem(0, subcategories[0]); mAdapter.add(new ListRow(header, listRowAdapter)); }
Example #22
Source File: CustomHeadersFragment.java From BuildingForAndroidTV with MIT License | 6 votes |
private void setHeaderAdapter() { adapter = new ArrayObjectAdapter(); LinkedHashMap<Integer, Fragment> fragments = ((MainActivity) getActivity()).getFragments(); int id = 0; for (int i = 0; i < fragments.size(); i++) { HeaderItem header = new HeaderItem(id, "Category " + i); ArrayObjectAdapter innerAdapter = new ArrayObjectAdapter(); innerAdapter.add(fragments.get(i)); adapter.add(id, new ListRow(header, innerAdapter)); id++; } setAdapter(adapter); }
Example #23
Source File: MainFragment.java From BuildingForAndroidTV with MIT License | 5 votes |
@Override public void onLoadFinished(Loader<HashMap<String, List<Movie>>> arg0, HashMap<String, List<Movie>> data) { mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter()); CardPresenter cardPresenter = new CardPresenter(); int i = 0; for (Map.Entry<String, List<Movie>> entry : data.entrySet()) { ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(cardPresenter); List<Movie> list = entry.getValue(); for (int j = 0; j < list.size(); j++) { listRowAdapter.add(list.get(j)); } HeaderItem header = new HeaderItem(i, entry.getKey()); i++; mRowsAdapter.add(new ListRow(header, listRowAdapter)); } HeaderItem gridHeader = new HeaderItem(i, getString(R.string.more_samples)); GridItemPresenter gridPresenter = new GridItemPresenter(this); ArrayObjectAdapter gridRowAdapter = new ArrayObjectAdapter(gridPresenter); gridRowAdapter.add(getString(R.string.grid_view)); gridRowAdapter.add(getString(R.string.guidedstep_first_title)); gridRowAdapter.add(getString(R.string.error_fragment)); gridRowAdapter.add(getString(R.string.personal_settings)); mRowsAdapter.add(new ListRow(gridHeader, gridRowAdapter)); setAdapter(mRowsAdapter); updateRecommendations(); }
Example #24
Source File: PlaybackOverlayFragment.java From BuildingForAndroidTV with MIT License | 5 votes |
private void addOtherRows() { ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(new CardPresenter()); for (Movie movie : mItems) { listRowAdapter.add(movie); } HeaderItem header = new HeaderItem(0, getString(R.string.related_movies)); mRowsAdapter.add(new ListRow(header, listRowAdapter)); }
Example #25
Source File: TVSearchFragment.java From BuildingForAndroidTV with MIT License | 5 votes |
@Override public void run() { // you should fetch your data here and update the adapter // accordingly mRowsAdapter.clear(); ArrayObjectAdapter adapter = new ArrayObjectAdapter(new CardPresenter()); adapter.addAll(0, MovieList.list); HeaderItem header = new HeaderItem(0, getResources().getString(R.string.search_results), null); mRowsAdapter.add(new ListRow(header, adapter)); }
Example #26
Source File: TVSearchFragment.java From BuildingForAndroidTV with MIT License | 5 votes |
@Override public void run() { // you should fetch your data here and update the adapter // accordingly mRowsAdapter.clear(); ArrayObjectAdapter adapter = new ArrayObjectAdapter(new CardPresenter()); adapter.addAll(0, MovieList.list); HeaderItem header = new HeaderItem(0, getResources().getString(R.string.search_results), null); mRowsAdapter.add(new ListRow(header, adapter)); }
Example #27
Source File: BrowseFragment.java From Amphitheatre with Apache License 2.0 | 5 votes |
private void addSettingsHeader() { HeaderItem gridHeader = new HeaderItem(0, getString(R.string.settings), null); ArrayObjectAdapter gridRowAdapter = new ArrayObjectAdapter(new GridItemPresenter(getActivity())); gridRowAdapter.add(getString(R.string.add_source)); gridRowAdapter.add(getString(R.string.customization)); mAdapter.add(new ListRow(gridHeader, gridRowAdapter)); }
Example #28
Source File: SimpleClockDreamSettingsFragment.java From androidtv-daydream with Apache License 2.0 | 5 votes |
private void loadRows() { GridItemPresenter mGridPresenter = new GridItemPresenter(); mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter()); HeaderItem gridHeader = new HeaderItem(0, getString(R.string.setting_header)); ArrayObjectAdapter gridRowAdapter = new ArrayObjectAdapter(mGridPresenter); gridRowAdapter.add(getString(R.string.setting_12hour)); gridRowAdapter.add(getString(R.string.setting_24hour)); mRowsAdapter.add(new ListRow(gridHeader, gridRowAdapter)); setAdapter(mRowsAdapter); }
Example #29
Source File: SearchFragment.java From TuentiTV with Apache License 2.0 | 5 votes |
@Override public void showSearchResultContacts(String query, List<Contact> contacts) { ArrayObjectAdapter arrayObjectAdapter = new ArrayObjectAdapter(new CardPresenter()); for (Contact contact : contacts) { arrayObjectAdapter.add(contact); } String resultSearchTitle = getString(R.string.search_result, query); HeaderItem headerItem = new HeaderItem(resultSearchTitle, ""); rowsAdapter.add(new ListRow(headerItem, arrayObjectAdapter)); }
Example #30
Source File: SearchFragment.java From TuentiTV with Apache License 2.0 | 5 votes |
@Override public void showAllContacts(List<Contact> contacts) { ArrayObjectAdapter arrayObjectAdapter = new ArrayObjectAdapter(new CardPresenter()); for (Contact contact : contacts) { arrayObjectAdapter.add(contact); } HeaderItem headerItem = new HeaderItem(getString(R.string.contacts_item_title), ""); rowsAdapter.add(new ListRow(headerItem, arrayObjectAdapter)); }