android.support.v17.leanback.widget.RowPresenter Java Examples
The following examples show how to use
android.support.v17.leanback.widget.RowPresenter.
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: 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 #3
Source File: RowsFragment.java From adt-leanback-support with Apache License 2.0 | 6 votes |
@Override public void onCreate(ItemBridgeAdapter.ViewHolder vh) { VerticalGridView listView = getVerticalGridView(); if (listView != null && ((RowPresenter) vh.getPresenter()).canDrawOutOfBounds()) { listView.setClipChildren(false); } setupSharedViewPool(vh); mViewsCreated = true; vh.setExtraObject(new RowViewHolderExtra(vh)); // selected state is initialized to false, then driven by grid view onChildSelected // events. When there is rebind, grid view fires onChildSelected event properly. // So we don't need do anything special later in onBind or onAttachedToWindow. setRowViewSelected(vh, false, true); if (mExternalAdapterListener != null) { mExternalAdapterListener.onCreate(vh); } }
Example #4
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 #5
Source File: RowsSupportFragment.java From adt-leanback-support with Apache License 2.0 | 6 votes |
private void setupSharedViewPool(ItemBridgeAdapter.ViewHolder bridgeVh) { RowPresenter rowPresenter = (RowPresenter) bridgeVh.getPresenter(); RowPresenter.ViewHolder rowVh = rowPresenter.getRowViewHolder(bridgeVh.getViewHolder()); if (rowVh instanceof ListRowPresenter.ViewHolder) { HorizontalGridView view = ((ListRowPresenter.ViewHolder) rowVh).getGridView(); // Recycled view pool is shared between all list rows if (mRecycledViewPool == null) { mRecycledViewPool = view.getRecycledViewPool(); } else { view.setRecycledViewPool(mRecycledViewPool); } ItemBridgeAdapter bridgeAdapter = ((ListRowPresenter.ViewHolder) rowVh).getBridgeAdapter(); if (mPresenterMapper == null) { mPresenterMapper = bridgeAdapter.getPresenterMapper(); } else { bridgeAdapter.setPresenterMapper(mPresenterMapper); } } }
Example #6
Source File: RowsFragment.java From adt-leanback-support with Apache License 2.0 | 6 votes |
private void setupSharedViewPool(ItemBridgeAdapter.ViewHolder bridgeVh) { RowPresenter rowPresenter = (RowPresenter) bridgeVh.getPresenter(); RowPresenter.ViewHolder rowVh = rowPresenter.getRowViewHolder(bridgeVh.getViewHolder()); if (rowVh instanceof ListRowPresenter.ViewHolder) { HorizontalGridView view = ((ListRowPresenter.ViewHolder) rowVh).getGridView(); // Recycled view pool is shared between all list rows if (mRecycledViewPool == null) { mRecycledViewPool = view.getRecycledViewPool(); } else { view.setRecycledViewPool(mRecycledViewPool); } ItemBridgeAdapter bridgeAdapter = ((ListRowPresenter.ViewHolder) rowVh).getBridgeAdapter(); if (mPresenterMapper == null) { mPresenterMapper = bridgeAdapter.getPresenterMapper(); } else { bridgeAdapter.setPresenterMapper(mPresenterMapper); } } }
Example #7
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 #8
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 #9
Source File: RowsSupportFragment.java From adt-leanback-support with Apache License 2.0 | 6 votes |
@Override public void onCreate(ItemBridgeAdapter.ViewHolder vh) { VerticalGridView listView = getVerticalGridView(); if (listView != null && ((RowPresenter) vh.getPresenter()).canDrawOutOfBounds()) { listView.setClipChildren(false); } setupSharedViewPool(vh); mViewsCreated = true; vh.setExtraObject(new RowViewHolderExtra(vh)); // selected state is initialized to false, then driven by grid view onChildSelected // events. When there is rebind, grid view fires onChildSelected event properly. // So we don't need do anything special later in onBind or onAttachedToWindow. setRowViewSelected(vh, false, true); if (mExternalAdapterListener != null) { mExternalAdapterListener.onCreate(vh); } }
Example #10
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 #11
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 #12
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 #13
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 #14
Source File: ListenerModule.java From leanback-showcase with Apache License 2.0 | 6 votes |
@PerFragment @Provides @IntoMap @ListenerModuleKey(LiveDataFragment.class) public OnItemViewSelectedListener provideOnItemViewSelectedListener(final Activity activity, final DisplayMetrics metrics, final BackgroundManager backgroundManager, final RequestOptions defaultPlaceHolder, final Drawable finalDrawable, final Handler mainHandler) { return new OnItemViewSelectedListener() { @Override public void onItemSelected(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) { VideoEntity selectedVideo = (VideoEntity) item; RunnableClass backgroundRunnable = new RunnableClass(selectedVideo, activity, metrics, backgroundManager, defaultPlaceHolder, finalDrawable); if (lastTime != null) { mainHandler.removeCallbacks(lastTime); } mainHandler.postDelayed(backgroundRunnable, BACKGROUND_UPDATE_DELAY); lastTime = backgroundRunnable; } }; }
Example #15
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 #16
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 #17
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 #18
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 #19
Source File: PlaybackOverlayFragment.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(), PlaybackActivity.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 #20
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 #21
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 #22
Source File: LeanbackBrowseFragment.java From android-tv-leanback with Apache License 2.0 | 5 votes |
protected OnItemViewClickedListener getDefaultItemViewClickedListener() { return new OnItemViewClickedListener() { @Override public void onItemClicked(Presenter.ViewHolder viewHolder, Object o, RowPresenter.ViewHolder viewHolder2, Row row) { Intent intent = new Intent(getActivity(), VideoDetailsActivity.class); intent.putExtra(Video.INTENT_EXTRA_VIDEO, (Serializable) o); startActivity(intent); } }; }
Example #23
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 #24
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 #25
Source File: SearchFragment.java From VCL-Android with Apache License 2.0 | 5 votes |
protected OnItemViewClickedListener getDefaultItemClickedListener() { return new OnItemViewClickedListener() { @Override public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) { if (item instanceof MediaWrapper) { TvUtil.openMedia(mActivity, (MediaWrapper) item, row); } } }; }
Example #26
Source File: VerticalGridFragment.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 = mGridViewHolder.getGridView().getSelectedPosition(); if (DEBUG) Log.v(TAG, "row selected position " + position); onRowSelected(position); if (mOnItemSelectedListener != null) { mOnItemSelectedListener.onItemSelected(item, row); } if (mOnItemViewSelectedListener != null) { mOnItemViewSelectedListener.onItemSelected(itemViewHolder, item, rowViewHolder, row); } }
Example #27
Source File: MainFragment.java From BuildingForAndroidTV with MIT License | 5 votes |
@Override public void onItemSelected(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) { if (item instanceof Movie) { mBackgroundURI = ((Movie) item).getBackgroundImageURI(); startBackgroundTimer(); } }
Example #28
Source File: RowsSupportFragment.java From adt-leanback-support with Apache License 2.0 | 5 votes |
private void freezeRows(boolean freeze) { VerticalGridView verticalView = getVerticalGridView(); if (verticalView != null) { final int count = verticalView.getChildCount(); for (int i = 0; i < count; i++) { ItemBridgeAdapter.ViewHolder ibvh = (ItemBridgeAdapter.ViewHolder) verticalView.getChildViewHolder(verticalView.getChildAt(i)); RowPresenter rowPresenter = (RowPresenter) ibvh.getPresenter(); RowPresenter.ViewHolder vh = rowPresenter.getRowViewHolder(ibvh.getViewHolder()); rowPresenter.freeze(vh, freeze); } } }
Example #29
Source File: RowsFragment.java From adt-leanback-support with Apache License 2.0 | 5 votes |
@Override public void onAddPresenter(Presenter presenter, int type) { ((RowPresenter) presenter).setOnItemClickedListener(mOnItemClickedListener); ((RowPresenter) presenter).setOnItemViewClickedListener(mOnItemViewClickedListener); if (mExternalAdapterListener != null) { mExternalAdapterListener.onAddPresenter(presenter, type); } }
Example #30
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(); } }