android.support.v17.leanback.widget.ListRow Java Examples
The following examples show how to use
android.support.v17.leanback.widget.ListRow.
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: 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 #2
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 #3
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 #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()); setOnItemViewSelectedListener(getDefaultItemSelectedListener()); bgHelper = new BackgroundHelper(getActivity()); bgHelper.prepareBackgroundManager(); }
Example #5
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 #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()); }
Example #8
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 #9
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 #10
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 #11
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 #12
Source File: CustomHeadersFragment.java From BuildingForAndroidTV with MIT License | 6 votes |
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); customSetBackground(R.color.fastlane_background); setHeaderAdapter(); setCustomPadding(); /** * The setOnItemSelectedListener has been not only deprecated, but brutally removed by * Google. To get around this limitation, I went to see how BaseRowFragment handled it. * Turns out it sets a listener to the GridView (which is a RecyclerView): there you go. */ VerticalGridView gridView = ((MainActivity) getActivity()).getVerticalGridView(this); gridView.setOnChildSelectedListener(new OnChildSelectedListener() { @Override public void onChildSelected(ViewGroup viewGroup, View view, int i, long l) { Object obj = ((ListRow) getAdapter().get(i)).getAdapter().get(0); getFragmentManager().beginTransaction().replace(R.id.rows_container, (Fragment) obj).commit(); ((MainActivity) getActivity()).updateCurrentFragment((Fragment) obj); } }); }
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 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 #15
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 #16
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 #17
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 #18
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 #19
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 #20
Source File: BrowseFragment.java From Amphitheatre with Apache License 2.0 | 5 votes |
private void reloadAdapters() { for (int i = 0; i < mAdapter.size(); i++) { ListRow listRow = (ListRow) mAdapter.get(i); ObjectAdapter objectAdapter = listRow.getAdapter(); if (objectAdapter instanceof ArrayObjectAdapter) { ArrayObjectAdapter arrayObjectAdapter = ((ArrayObjectAdapter) objectAdapter); arrayObjectAdapter.notifyArrayItemRangeChanged(0, arrayObjectAdapter.size()); } } }
Example #21
Source File: CustomHeadersFragment.java From BuildingForAndroidTV with MIT License | 5 votes |
private OnItemSelectedListener getDefaultItemSelectedListener() { return new OnItemSelectedListener() { @Override public void onItemSelected(Object o, Row row) { Object obj = ((ListRow) row).getAdapter().get(0); getFragmentManager().beginTransaction().replace(R.id.rows_container, (Fragment) obj).commit(); } }; }
Example #22
Source File: BaseRowSupportFragment.java From adt-leanback-support with Apache License 2.0 | 5 votes |
protected Object getItem(Row row, int position) { if (row instanceof ListRow) { return ((ListRow) row).getAdapter().get(position); } else { return null; } }
Example #23
Source File: BaseRowFragment.java From adt-leanback-support with Apache License 2.0 | 5 votes |
protected Object getItem(Row row, int position) { if (row instanceof ListRow) { return ((ListRow) row).getAdapter().get(position); } else { return null; } }
Example #24
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 #25
Source File: MainFragment.java From TuentiTV with Apache License 2.0 | 5 votes |
private void addImageInfoElementsToRowAdapter(int title, List<ImageInfo> elements, ArrayObjectAdapter rowsAdapter, Presenter presenter, int id) { ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(presenter); for (Object element : elements) { listRowAdapter.add(element); } HeaderItem header = new HeaderItem(id, getString(title), null); rowsAdapter.add(new ListRow(header, listRowAdapter)); }
Example #26
Source File: DetailFragment.java From TuentiTV with Apache License 2.0 | 5 votes |
@Override public void showCardInfo(final CardInfo cardInfo) { new AsyncTask<Void, Void, Bitmap>() { @Override protected Bitmap doInBackground(Void... params) { Bitmap detailImage = null; try { detailImage = Picasso.with(getActivity()) .load(cardInfo.getCardImageUrl()) .placeholder(R.drawable.icn_wink) .error(R.drawable.icn_wink) .resize(Util.convertDpToPixel(getActivity(), DETAIL_THUMB_WIDTH), Util.convertDpToPixel(getActivity(), DETAIL_THUMB_HEIGHT)) .centerCrop() .get(); } catch (IOException e) { //Empty } return detailImage; } @Override protected void onPostExecute(Bitmap bitmap) { DetailsOverviewRow detailRow = configureDetailsOverviewRow(cardInfo, bitmap); ClassPresenterSelector presenterSelector = new ClassPresenterSelector(); DetailsOverviewRowPresenter dorPresenter = new DetailsOverviewRowPresenter(new DetailsDescriptionPresenter()); dorPresenter.setBackgroundColor(getResources().getColor(R.color.primary_color)); dorPresenter.setStyleLarge(false); presenterSelector.addClassPresenter(DetailsOverviewRow.class, dorPresenter); presenterSelector.addClassPresenter(ListRow.class, new ListRowPresenter()); adapter = new ArrayObjectAdapter(presenterSelector); adapter.add(detailRow); setAdapter(adapter); } }.execute(); }
Example #27
Source File: MainFragment.java From TuentiTV with Apache License 2.0 | 5 votes |
private void addCardInfoElementsToRowsAdapter(int title, List<CardInfo> elements, ArrayObjectAdapter rowsAdapter, Presenter presenter, int id) { ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(presenter); for (Object element : elements) { listRowAdapter.add(element); } HeaderItem header = new HeaderItem(id, getString(title), null); rowsAdapter.add(new ListRow(header, listRowAdapter)); }
Example #28
Source File: TvSearchFragment.java From leanback-homescreen-channels with Apache License 2.0 | 5 votes |
@Override public void run() { // Search for query and collate results. mRowsAdapter.clear(); ArrayObjectAdapter searchRowAdapter = new ArrayObjectAdapter(new SearchPresenterSelector()); searchRowAdapter.add(new AddPlaylistButton()); searchRowAdapter.addAll(1, SampleClipApi.getSearchResults(mQuery)); HeaderItem header = new HeaderItem(0, getResources().getString(R.string.search_results)); mRowsAdapter.add(new ListRow(header, searchRowAdapter)); }
Example #29
Source File: MainFragment.java From TuentiTV with Apache License 2.0 | 5 votes |
private void addIconInfoElementsToRowAdapter(String title, List<IconInfo> preferences, ArrayObjectAdapter rowsAdapter, Presenter presenter, int id) { ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(presenter); for (IconInfo iconInfo : preferences) { listRowAdapter.add(iconInfo); } rowsAdapter.add(new ListRow(new HeaderItem(id, title, ""), listRowAdapter)); }
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)); }