Java Code Examples for android.support.v17.leanback.widget.ArrayObjectAdapter#add()
The following examples show how to use
android.support.v17.leanback.widget.ArrayObjectAdapter#add() .
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: 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 2
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 3
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 4
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 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: 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 7
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 8
Source File: VideoMediaPlayerGlue.java From leanback-showcase with Apache License 2.0 | 5 votes |
@Override protected void onCreateSecondaryActions(ArrayObjectAdapter adapter) { adapter.add(mThumbsUpAction); adapter.add(mThumbsDownAction); if (android.os.Build.VERSION.SDK_INT > 23) { adapter.add(mPipAction); } }
Example 9
Source File: MainFragment.java From AndroidDemoProjects with Apache License 2.0 | 5 votes |
private void setupPreferences( ArrayObjectAdapter adapter ) { HeaderItem gridHeader = new HeaderItem( adapter.size(), "Preferences", null ); PreferenceCardPresenter mGridPresenter = new PreferenceCardPresenter(); ArrayObjectAdapter gridRowAdapter = new ArrayObjectAdapter( mGridPresenter ); gridRowAdapter.add( getResources().getString( R.string.sloth ) ); adapter.add( new ListRow( gridHeader, gridRowAdapter ) ); }
Example 10
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 11
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 12
Source File: MainActivity.java From AndroidTVLauncher with GNU General Public License v3.0 | 5 votes |
private void addAppRow() { String headerName = getResources().getString(R.string.app_header_app_name); ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(new AppCardPresenter()); ArrayList<AppModel> appDataList = new AppDataManage(mContext).getLaunchAppList(); int cardCount = appDataList.size(); for (int i = 0; i < cardCount; i++) { listRowAdapter.add(appDataList.get(i)); } HeaderItem header = new HeaderItem(0, headerName); rowsAdapter.add(new ListRow(header, listRowAdapter)); }
Example 13
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 14
Source File: MainFragment.java From leanback-extensions with Apache License 2.0 | 5 votes |
private void loadRows() { List<Movie> list = MovieList.setupMovies(); mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter()); CardPresenterSelector cardPresenterSelector = new CardPresenterSelector(); int i; for (i = 0; i < NUM_ROWS; i++) { if (i != 0) { Collections.shuffle(list); } ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(cardPresenterSelector); for (int j = 0; j < NUM_COLS; j++) { listRowAdapter.add(list.get(j % 4)); } HeaderItem header = new HeaderItem(i, MovieList.MOVIE_CATEGORY[i]); mRowsAdapter.add(new ListRow(header, listRowAdapter)); } HeaderItem gridHeader = new HeaderItem(i, "Misc"); GridItemPresenter mGridPresenter = new GridItemPresenter(); ArrayObjectAdapter gridRowAdapter = new ArrayObjectAdapter(mGridPresenter); gridRowAdapter.add(getResources().getString(R.string.justified_vertical_grid_view)); gridRowAdapter.add(getString(R.string.loading_fragment)); mRowsAdapter.add(new ListRow(gridHeader, gridRowAdapter)); setAdapter(mRowsAdapter); }
Example 15
Source File: TVDemoFragment.java From BuildingForAndroidTV with MIT License | 5 votes |
private void loadRows() { List<Movie> list = MovieList.setupMovies(); mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter()); mCardPresenter = new CardPresenter(); int i; for (i = 0; i < NUM_ROWS; i++) { if (i != 0) { Collections.shuffle(list); } ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(mCardPresenter); for (int j = 0; j < NUM_COLS; j++) { listRowAdapter.add(list.get(j % 5)); } HeaderItem header = new HeaderItem(i, MovieList.MOVIE_CATEGORY[i], null); mRowsAdapter.add(new ListRow(header, listRowAdapter)); } HeaderItem gridHeader = new HeaderItem(i, "PREFERENCES", null); GridItemPresenter mGridPresenter = new GridItemPresenter(); ArrayObjectAdapter gridRowAdapter = new ArrayObjectAdapter(mGridPresenter); gridRowAdapter.add(getResources().getString(R.string.grid_view)); gridRowAdapter.add(getResources().getString(R.string.send_feeback)); gridRowAdapter.add(getResources().getString(R.string.personal_settings)); mRowsAdapter.add(new ListRow(gridHeader, gridRowAdapter)); setAdapter(mRowsAdapter); }
Example 16
Source File: TVDemoFragment.java From BuildingForAndroidTV with MIT License | 5 votes |
private void loadRows() { List<Movie> list = MovieList.setupMovies(); mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter()); mCardPresenter = new CardPresenter(); int i; for (i = 0; i < NUM_ROWS; i++) { if (i != 0) { Collections.shuffle(list); } ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(mCardPresenter); for (int j = 0; j < NUM_COLS; j++) { listRowAdapter.add(list.get(j % 5)); } HeaderItem header = new HeaderItem(i, MovieList.MOVIE_CATEGORY[i], null); mRowsAdapter.add(new ListRow(header, listRowAdapter)); } HeaderItem gridHeader = new HeaderItem(i, "PREFERENCES", null); GridItemPresenter mGridPresenter = new GridItemPresenter(); ArrayObjectAdapter gridRowAdapter = new ArrayObjectAdapter(mGridPresenter); gridRowAdapter.add(getResources().getString(R.string.grid_view)); gridRowAdapter.add(getResources().getString(R.string.send_feeback)); gridRowAdapter.add(getResources().getString(R.string.personal_settings)); mRowsAdapter.add(new ListRow(gridHeader, gridRowAdapter)); setAdapter(mRowsAdapter); }
Example 17
Source File: PageAndListRowFragment.java From leanback-showcase with Apache License 2.0 | 5 votes |
private ListRow createCardRow(CardRow cardRow) { SettingsIconPresenter iconCardPresenter = new SettingsIconPresenter(getActivity()); ArrayObjectAdapter adapter = new ArrayObjectAdapter(iconCardPresenter); for(Card card : cardRow.getCards()) { adapter.add(card); } HeaderItem headerItem = new HeaderItem(cardRow.getTitle()); return new CardListRow(headerItem, adapter, cardRow); }
Example 18
Source File: RichAppLinkDetailsFragment.java From androidtv-sample-inputs with Apache License 2.0 | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final String displayNumber = getActivity().getIntent().getStringExtra( RichFeedUtil.EXTRA_DISPLAY_NUMBER); DetailsOverviewRowPresenter dorPresenter = new DetailsOverviewRowPresenter( new DetailsDescriptionPresenter()); dorPresenter.setSharedElementEnterTransition(getActivity(), "RichAppLinkDetailsFragment"); DetailsOverviewRow row = new DetailsOverviewRow(displayNumber); Resources res = getResources(); Bitmap bitmap = BitmapFactory.decodeResource(res, R.drawable.your_company); int length = Math.min(bitmap.getWidth(), bitmap.getHeight()); Bitmap croppedBitmap = Bitmap.createBitmap(bitmap, (bitmap.getWidth() - length) / 2, (bitmap.getHeight() - length) / 2, length, length); row.setImageBitmap(getActivity(), croppedBitmap); Action action1 = new Action(0, res.getString(R.string.details_fragment_action_1)); Action action2 = new Action(1, res.getString(R.string.details_fragment_action_2)); row.addAction(action1); row.addAction(action2); ClassPresenterSelector presenterSelector = new ClassPresenterSelector(); dorPresenter.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.detail_background)); dorPresenter.setStyleLarge(true); dorPresenter.setOnActionClickedListener(new OnActionClickedListener() { @Override public void onActionClicked(Action action) { getActivity().finish(); } }); presenterSelector.addClassPresenter(DetailsOverviewRow.class, dorPresenter); presenterSelector.addClassPresenter(ListRow.class, new ListRowPresenter()); ArrayObjectAdapter adapter = new ArrayObjectAdapter(presenterSelector); adapter.add(row); setAdapter(adapter); }
Example 19
Source File: VideoDetailsFragment.java From android-tv-leanback with Apache License 2.0 | 4 votes |
@Override protected void onPostExecute(DetailsOverviewRow detailRow) { ClassPresenterSelector ps = new ClassPresenterSelector(); FullWidthDetailsOverviewRowPresenter detailsPresenter = new FullWidthDetailsOverviewRowPresenter(new DetailsDescriptionPresenter(getContext())); detailsPresenter.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.primary)); detailsPresenter.setInitialState(FullWidthDetailsOverviewRowPresenter.STATE_FULL); detailsPresenter.setOnActionClickedListener(new OnActionClickedListener() { @Override public void onActionClicked(Action action) { if (action.getId() == ACTION_PLAY) { Intent intent = new Intent(getActivity(), PlayerActivity.class); intent.putExtra(Video.INTENT_EXTRA_VIDEO, selectedVideo); startActivity(intent); } else { Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show(); } } }); ps.addClassPresenter(DetailsOverviewRow.class, detailsPresenter); ps.addClassPresenter(ListRow.class, new ListRowPresenter()); /** bonus code for adding related items to details fragment **/ // <START> ArrayObjectAdapter adapter = new ArrayObjectAdapter(ps); adapter.add(detailRow); String subcategories[] = { "You may also like" }; CursorObjectAdapter rowAdapter = new CursorObjectAdapter(new SinglePresenterSelector(new CardPresenter())); VideoDataManager manager = new VideoDataManager(getActivity(), getLoaderManager(), VideoItemContract.VideoItem.buildDirUri(), rowAdapter); manager.startDataLoading(); HeaderItem header = new HeaderItem(0, subcategories[0]); adapter.add(new ListRow(header, rowAdapter)); setAdapter(adapter); // <END> }
Example 20
Source File: VideoDetailsFragment.java From android-tv-leanback with Apache License 2.0 | 4 votes |
@Override protected void onPostExecute(DetailsOverviewRow detailRow) { ClassPresenterSelector ps = new ClassPresenterSelector(); FullWidthDetailsOverviewRowPresenter detailsPresenter = new FullWidthDetailsOverviewRowPresenter(new DetailsDescriptionPresenter(getContext())); detailsPresenter.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.primary)); detailsPresenter.setInitialState(FullWidthDetailsOverviewRowPresenter.STATE_FULL); detailsPresenter.setOnActionClickedListener(new OnActionClickedListener() { @Override public void onActionClicked(Action action) { if (action.getId() == ACTION_PLAY) { Intent intent = new Intent(getActivity(), PlayerActivity.class); intent.putExtra(Video.INTENT_EXTRA_VIDEO, selectedVideo); startActivity(intent); } else { Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show(); } } }); ps.addClassPresenter(DetailsOverviewRow.class, detailsPresenter); ps.addClassPresenter(ListRow.class, new ListRowPresenter()); /** bonus code for adding related items to details fragment **/ // <START> ArrayObjectAdapter adapter = new ArrayObjectAdapter(ps); adapter.add(detailRow); String subcategories[] = { "You may also like" }; CursorObjectAdapter rowAdapter = new CursorObjectAdapter(new SinglePresenterSelector(new CardPresenter())); VideoDataManager manager = new VideoDataManager(getActivity(), getLoaderManager(), VideoItemContract.VideoItem.buildDirUri(), rowAdapter); manager.startDataLoading(); HeaderItem header = new HeaderItem(0, subcategories[0]); adapter.add(new ListRow(header, rowAdapter)); setAdapter(adapter); // <END> }