android.support.v17.leanback.widget.Row Java Examples
The following examples show how to use
android.support.v17.leanback.widget.Row.
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: PageAndListRowFragment.java From leanback-showcase with Apache License 2.0 | 7 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 #2
Source File: VideoGridExampleFragment.java From leanback-showcase with Apache License 2.0 | 6 votes |
@Override public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) { if (item instanceof VideoCard) { VideoCard itemCard = (VideoCard) item; List<String> videoSources = itemCard.getVideoSources(); if (videoSources == null || videoSources.isEmpty()) { return; } MediaMetaData metaData = new MediaMetaData(); metaData.setMediaSourcePath(videoSources.get(0)); metaData.setMediaTitle(itemCard.getTitle()); metaData.setMediaArtistName(itemCard.getDescription()); metaData.setMediaAlbumArtUrl(itemCard.getImageUrl()); Intent intent = new Intent(getActivity(), VideoExampleActivity.class); intent.putExtra(VideoExampleActivity.TAG, metaData); intent.setData(Uri.parse(metaData.getMediaSourcePath())); getActivity().startActivity(intent); } }
Example #3
Source File: MainFragment.java From leanback-homescreen-channels with Apache License 2.0 | 6 votes |
@Override public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) { if (isAdded()) { if (item instanceof Clip) { Clip clip = (Clip) item; Intent intent = new Intent(getActivity(), PlaybackActivity.class); intent.putExtra(PlaybackActivity.EXTRA_CLIP, clip); startActivity(intent); final long programId = clip.getProgramId(); if (programId != 0) { // This clip is published as a program. Increment the view count for the // program to demonstrate updating. new SetViewCountInBackground(programId, clip.incrementViewCount()); } } } }
Example #4
Source File: SearchFragment.java From BuildingForAndroidTV with MIT License | 6 votes |
@Override public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) { if (item instanceof Movie) { Movie movie = (Movie) item; Log.d(TAG, "Movie: " + movie.toString()); Intent intent = new Intent(getActivity(), MovieDetailsActivity.class); intent.putExtra(MovieDetailsActivity.MOVIE, movie); Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation( getActivity(), ((ImageCardView) itemViewHolder.view).getMainImageView(), MovieDetailsActivity.SHARED_ELEMENT_NAME).toBundle(); getActivity().startActivity(intent, bundle); } else { Toast.makeText(getActivity(), ((String) item), Toast.LENGTH_SHORT) .show(); } }
Example #5
Source File: TvSearchFragment.java From leanback-homescreen-channels with Apache License 2.0 | 6 votes |
private OnItemViewClickedListener getDefaultItemClickedListener() { return new OnItemViewClickedListener() { @Override public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) { if (item instanceof Clip) { Toast.makeText(getActivity(), "** toggle selected **", Toast.LENGTH_LONG).show(); } else { Toast.makeText(getActivity(), "** add as playlist **", Toast.LENGTH_LONG).show(); } } }; }
Example #6
Source File: MainFragment.java From alltv with MIT License | 6 votes |
@Override public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) { if (item instanceof String) { if (((String) item).contains(getString(R.string.preferences))) { Intent intent = new Intent(getActivity(), SettingsActivity.class); intent.putExtra(getStringById(R.string.SETTINGSDATA_STR), mGson.toJson(mSettingsData)); getActivity().startActivityForResult(intent, Utils.Code.SettingsRequestCode.ordinal()); } else if (((String) item).contains(getString(R.string.opensource))) { showLicensesDialogFragment(); } } }
Example #7
Source File: AllTvBaseRowsSupportFragment.java From alltv with MIT License | 6 votes |
@Override public void onItemSelected(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) { if(rowViewHolder.getSelectedItem() != null) { ChannelData channelData = (ChannelData)rowViewHolder.getSelectedItem(); mRowIndex = getSelectedPosition(); mItemIndex = channelData.getItemIndex(); // Log.e(TAG, "onItemSelected: row: " + Integer.toString(mRowIndex) + ", Cnt: " + Integer.toString(mItemIndex)); } else { mRowIndex = 0; mItemIndex = 0; } }
Example #8
Source File: MainFragment.java From alltv with MIT License | 6 votes |
@Override public Fragment createFragment(Object rowObj) { Row row = (Row) rowObj; if(row.getHeaderItem().getId() == Utils.Header.Favorite.ordinal()) { return new FavoriteRowSupportFragment(); } else if (row.getHeaderItem().getId() == Utils.Header.Pooq.ordinal()) { return new PooqRowSupportFragment(); } else if (row.getHeaderItem().getId() == Utils.Header.Tving.ordinal()) { return new TvingRowSupportFragment(); } else if (row.getHeaderItem().getId() == Utils.Header.Oksusu.ordinal()) { return new OksusuRowSupportFragment(); } throw new IllegalArgumentException(String.format("Invalid row %s", rowObj)); }
Example #9
Source File: MainFragment.java From TvAppRepo with Apache License 2.0 | 6 votes |
@Override public void onItemClicked(Presenter.ViewHolder itemViewHolder, final Object item, RowPresenter.ViewHolder rowViewHolder, Row row) { if (item instanceof Apk) { Apk application = (Apk) item; Log.d(TAG, "Item: " + item.toString()); Intent intent = new Intent(getActivity(), DetailsActivity.class); intent.putExtra(DetailsActivity.APPLICATION, application.toString()); Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation( getActivity(), ((ImageCardView) itemViewHolder.view).getMainImageView(), DetailsActivity.SHARED_ELEMENT_NAME).toBundle(); getActivity().startActivity(intent, bundle); } else if (item instanceof SettingOption) { ((SettingOption) item).getClickListener().onClick(); } else if (item instanceof File) { Log.d(TAG, "Open file " + ((File) item).getAbsolutePath()); mApkDownloadHelper.install((File) item); } else if (item instanceof ResolveInfo) { GenerateShortcutHelper.begin(mMainActivity, (ResolveInfo) item); } }
Example #10
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 #11
Source File: CustomRowsFragment.java From BuildingForAndroidTV with MIT License | 6 votes |
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); loadVideoData(); setCustomPadding(); setOnItemViewClickedListener(new OnItemViewClickedListener() { @Override public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) { Movie movie = (Movie) item; Intent intent = new Intent(getActivity(), MovieDetailsActivity.class); intent.putExtra(MovieDetailsActivity.MOVIE, movie); Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation( getActivity(), ((ImageCardView) itemViewHolder.view).getMainImageView(), MovieDetailsActivity.SHARED_ELEMENT_NAME).toBundle(); getActivity().startActivity(intent, bundle); } }); }
Example #12
Source File: PageAndListRowFragment.java From leanback-showcase with Apache License 2.0 | 6 votes |
@Override public Fragment createFragment(Object rowObj) { Row row = (Row)rowObj; mBackgroundManager.setDrawable(null); if (row.getHeaderItem().getId() == HEADER_ID_1) { return new SampleFragmentA(); } else if (row.getHeaderItem().getId() == HEADER_ID_2) { return new SampleFragmentB(); } else if (row.getHeaderItem().getId() == HEADER_ID_3) { return new SettingsFragment(); } else if (row.getHeaderItem().getId() == HEADER_ID_4) { return new WebViewFragment(); } throw new IllegalArgumentException(String.format("Invalid row %s", rowObj)); }
Example #13
Source File: PageAndListRowFragment.java From leanback-showcase 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 #14
Source File: MovieDetailsFragment.java From BuildingForAndroidTV with MIT License | 6 votes |
@Override public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) { if (item instanceof Movie) { Movie movie = (Movie) item; Log.d(TAG, "Item: " + item.toString()); Intent intent = new Intent(getActivity(), MovieDetailsActivity.class); intent.putExtra(MovieDetailsActivity.MOVIE, movie); Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation( getActivity(), ((ImageCardView) itemViewHolder.view).getMainImageView(), MovieDetailsActivity.SHARED_ELEMENT_NAME).toBundle(); getActivity().startActivity(intent, bundle); } }
Example #15
Source File: DetailViewExampleWithVideoBackgroundFragment.java From leanback-showcase with Apache License 2.0 | 6 votes |
@Override public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) { if (!(item instanceof Action)) return; Action action = (Action) item; long id = action.getId(); if (id == ACTION_RENT) { startWizardActivityForPayment(); } else if (action.getId() == ACTION_PLAY) { playMainVideoOnBackground(); } else if (action.getId() == ACTION_RELATED) { setSelectedPosition(1); } else { Toast.makeText(getActivity(), getString(R.string.action_cicked), Toast.LENGTH_LONG) .show(); } }
Example #16
Source File: MainTvActivity.java From VCL-Android with Apache License 2.0 | 6 votes |
@Override public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) { if (row.getId() == HEADER_CATEGORIES) { if (((CardPresenter.SimpleCard)item).getId() == MusicFragment.CATEGORY_NOW_PLAYING){ //NOW PLAYING CARD startActivity(new Intent(this, AudioPlayerActivity.class)); return; } CardPresenter.SimpleCard card = (CardPresenter.SimpleCard) item; Intent intent = new Intent(mContext, VerticalGridActivity.class); intent.putExtra(BROWSER_TYPE, HEADER_CATEGORIES); intent.putExtra(MusicFragment.AUDIO_CATEGORY, card.getId()); startActivity(intent); } else if (row.getId() == HEADER_VIDEO) TvUtil.openMedia(mContext, item, row); else if (row.getId() == HEADER_MISC) startActivityForResult(new Intent(this, PreferencesActivity.class), ACTIVITY_RESULT_PREFERENCES); else if (row.getId() == HEADER_NETWORK) { TvUtil.openMedia(mContext, item, row); } }
Example #17
Source File: DetailsFragment.java From iview-android-tv with MIT License | 6 votes |
private OnItemViewClickedListener getItemClickedListener() { return new OnItemViewClickedListener() { @Override public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) { Log.d(TAG, "Clicked item:" + item); if (item instanceof EpisodeBaseModel) { EpisodeBaseModel ep = (EpisodeBaseModel) item; Intent intent = new Intent(getActivity(), getPlayerActivityClass()); intent.putExtra(ContentManagerBase.CONTENT_ID, ep); String[] others = getOtherEpisodeUrls().toArray(new String[getOtherEpisodeUrls().size()]); intent.putExtra(ContentManagerBase.OTHER_EPISODES, others); startActivity(intent); } } }; }
Example #18
Source File: VerticalGridFragment.java From BuildingForAndroidTV with MIT License | 6 votes |
@Override public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) { if (item instanceof Movie) { Movie movie = (Movie) item; Log.d(TAG, "Item: " + item.toString()); Intent intent = new Intent(getActivity(), MovieDetailsActivity.class); intent.putExtra(MovieDetailsActivity.MOVIE, movie); Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation( getActivity(), ((ImageCardView) itemViewHolder.view).getMainImageView(), MovieDetailsActivity.SHARED_ELEMENT_NAME).toBundle(); getActivity().startActivity(intent, bundle); } }
Example #19
Source File: SearchFragment.java From Amphitheatre with Apache License 2.0 | 6 votes |
private OnItemClickedListener getDefaultItemClickedListener() { return new OnItemClickedListener() { @Override public void onItemClicked(Object item, Row row) { if (item instanceof Video) { Video video = (Video) item; if (!video.isMatched()) { VideoUtils.playVideo(new WeakReference<Activity>(getActivity()), (Video) item); return; } Intent intent = new Intent(getActivity(), DetailsActivity.class); intent.putExtra(Constants.VIDEO, video); startActivity(intent); } } }; }
Example #20
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 #21
Source File: LeanbackFragment.java From CumulusTV with MIT License | 5 votes |
@Override public void onItemSelected(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) { if (item instanceof JsonChannel) { startBackgroundTimer(); } }
Example #22
Source File: CategoryFragment.java From iview-android-tv with MIT License | 5 votes |
private OnItemViewClickedListener getItemClickedListener() { return new OnItemViewClickedListener() { @Override public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) { if (item instanceof EpisodeBaseModel) { Intent intent = new Intent(getActivity(), getDetailsActivityClass()); intent.putExtra(ContentManagerBase.CONTENT_ID, (EpisodeBaseModel) item); startActivity(intent); } } }; }
Example #23
Source File: DetailsFragment.java From iview-android-tv with MIT License | 5 votes |
private OnItemViewSelectedListener getItemSelectedListener() { return new OnItemViewSelectedListener() { @Override public void onItemSelected(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) { Log.d(TAG, "Selected item:" + item); if (item instanceof EpisodeBaseModel) { selectCurrentEpisode((EpisodeBaseModel) item, false); } } }; }
Example #24
Source File: SearchFragment.java From TuentiTV with Apache License 2.0 | 5 votes |
protected OnItemClickedListener getDefaultItemClickedListener() { return new OnItemClickedListener() { @Override public void onItemClicked(Object item, Row row) { searchPresenter.onContactClicked((Contact) item); } }; }
Example #25
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 #26
Source File: HeadersFragment.java From adt-leanback-support with Apache License 2.0 | 5 votes |
@Override protected void onRowSelected(ViewGroup parent, View view, int position, long id) { if (mOnItemSelectedListener != null) { if (position >= 0) { Row row = (Row) getAdapter().get(position); mOnItemSelectedListener.onItemSelected(null, row); } else { mOnItemSelectedListener.onItemSelected(null, null); } } }
Example #27
Source File: BrowseFragment.java From adt-leanback-support with Apache License 2.0 | 5 votes |
@Override public void onItemSelected(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) { int position = mRowsFragment.getVerticalGridView().getSelectedPosition(); if (DEBUG) Log.v(TAG, "row selected position " + position); onRowSelected(position); if (mExternalOnItemViewSelectedListener != null) { mExternalOnItemViewSelectedListener.onItemSelected(itemViewHolder, item, rowViewHolder, row); } }
Example #28
Source File: HeadersSupportFragment.java From adt-leanback-support with Apache License 2.0 | 5 votes |
@Override protected void onRowSelected(ViewGroup parent, View view, int position, long id) { if (mOnItemSelectedListener != null) { if (position >= 0) { Row row = (Row) getAdapter().get(position); mOnItemSelectedListener.onItemSelected(null, row); } else { mOnItemSelectedListener.onItemSelected(null, null); } } }
Example #29
Source File: SearchFragment.java From iview-android-tv with MIT License | 5 votes |
private OnItemViewClickedListener getItemClickedListener() { return new OnItemViewClickedListener() { @Override public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) { if (item instanceof EpisodeBaseModel) { Intent intent = new Intent(getActivity(), getDetailsActivityClass()); intent.putExtra(ContentManagerBase.CONTENT_ID, (EpisodeBaseModel) item); startActivity(intent); } } }; }
Example #30
Source File: BrowseSupportFragment.java From adt-leanback-support with Apache License 2.0 | 5 votes |
@Override public void onItemSelected(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) { int position = mRowsSupportFragment.getVerticalGridView().getSelectedPosition(); if (DEBUG) Log.v(TAG, "row selected position " + position); onRowSelected(position); if (mExternalOnItemViewSelectedListener != null) { mExternalOnItemViewSelectedListener.onItemSelected(itemViewHolder, item, rowViewHolder, row); } }