androidx.leanback.widget.Action Java Examples
The following examples show how to use
androidx.leanback.widget.Action.
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: VideoPlayerGlue.java From androidtv-Leanback with Apache License 2.0 | 6 votes |
private void dispatchAction(Action action) { // Primary actions are handled manually. if (action == mRewindAction) { rewind(); } else if (action == mFastForwardAction) { fastForward(); } else if (action instanceof PlaybackControlsRow.MultiAction) { PlaybackControlsRow.MultiAction multiAction = (PlaybackControlsRow.MultiAction) action; multiAction.nextIndex(); // Notify adapter of action changes to handle secondary actions, such as, thumbs up/down // and repeat. notifyActionChanged( multiAction, (ArrayObjectAdapter) getControlsRow().getSecondaryActionsAdapter()); } }
Example #2
Source File: CustomPlaybackTransportControlGlue.java From jellyfin-androidtv with GNU General Public License v2.0 | 6 votes |
@Override public void onActionClicked(Action action) { if (action == playPauseAction) { if (playPauseAction.getIndex() == PlaybackControlsRow.PlayPauseAction.INDEX_PAUSE) { getPlayerAdapter().pause(); playPauseAction.setIndex(PlaybackControlsRow.PlayPauseAction.INDEX_PLAY); } else if (playPauseAction.getIndex() == PlaybackControlsRow.PlayPauseAction.INDEX_PLAY) { getPlayerAdapter().play(); playPauseAction.setIndex(PlaybackControlsRow.PlayPauseAction.INDEX_PAUSE); } } else if (action == rewindAction) { getPlayerAdapter().rewind(); } else if (action == fastForwardAction) { getPlayerAdapter().fastForward(); } else if (action == skipNextAction) { getPlayerAdapter().next(); } notifyActionChanged(action); }
Example #3
Source File: CustomPlaybackFragmentGlueHost.java From jellyfin-androidtv with GNU General Public License v2.0 | 6 votes |
@Override public void setOnActionClickedListener(OnActionClickedListener listener) { // Copy from superclass if (listener == null) { fragment.setOnPlaybackItemViewClickedListener(null); } else { fragment.setOnPlaybackItemViewClickedListener(new OnItemViewClickedListener() { @Override public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) { // Call our custom function and pass the view instance if (item instanceof CustomAction) { ((CustomAction) item).onCustomActionClicked(itemViewHolder.view); } if (item instanceof Action) { listener.onActionClicked((Action) item); } } }); }; }
Example #4
Source File: DetailViewExampleWithVideoBackgroundFragment.java From tv-samples 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 #5
Source File: VideoPlayerGlue.java From tv-samples with Apache License 2.0 | 6 votes |
private void dispatchAction(Action action) { // Primary actions are handled manually. if (action == mRewindAction) { rewind(); } else if (action == mFastForwardAction) { fastForward(); } else if (action instanceof PlaybackControlsRow.MultiAction) { PlaybackControlsRow.MultiAction multiAction = (PlaybackControlsRow.MultiAction) action; multiAction.nextIndex(); // Notify adapter of action changes to handle secondary actions, such as, thumbs up/down // and repeat. notifyActionChanged( multiAction, (ArrayObjectAdapter) getControlsRow().getSecondaryActionsAdapter()); } }
Example #6
Source File: VideoPlayerGlue.java From tv-samples with Apache License 2.0 | 5 votes |
@Override public void onActionClicked(Action action) { if (shouldDispatchAction(action)) { dispatchAction(action); return; } // Super class handles play/pause and delegates to abstract methods next()/previous(). super.onActionClicked(action); }
Example #7
Source File: VideoDetailsFragment.java From androidtv-Leanback with Apache License 2.0 | 5 votes |
private void setupDetailsOverviewRow() { final DetailsOverviewRow row = new DetailsOverviewRow(mSelectedVideo); RequestOptions options = new RequestOptions() .error(R.drawable.default_background) .dontAnimate(); Glide.with(this) .asBitmap() .load(mSelectedVideo.cardImageUrl) .apply(options) .into(new SimpleTarget<Bitmap>() { @Override public void onResourceReady( Bitmap resource, Transition<? super Bitmap> transition) { row.setImageBitmap(getActivity(), resource); startEntranceTransition(); } }); SparseArrayObjectAdapter adapter = new SparseArrayObjectAdapter(); adapter.set(ACTION_WATCH_TRAILER, new Action(ACTION_WATCH_TRAILER, getResources() .getString(R.string.watch_trailer_1), getResources().getString(R.string.watch_trailer_2))); adapter.set(ACTION_RENT, new Action(ACTION_RENT, getResources().getString(R.string.rent_1), getResources().getString(R.string.rent_2))); adapter.set(ACTION_BUY, new Action(ACTION_BUY, getResources().getString(R.string.buy_1), getResources().getString(R.string.buy_2))); row.setActionsAdapter(adapter); mAdapter.add(row); }
Example #8
Source File: VideoDetailsFragment.java From androidtv-Leanback with Apache License 2.0 | 5 votes |
private void setupAdapter() { // Set detail background and style. FullWidthDetailsOverviewRowPresenter detailsPresenter = new FullWidthDetailsOverviewRowPresenter(new DetailsDescriptionPresenter(), new MovieDetailsOverviewLogoPresenter()); detailsPresenter.setBackgroundColor( ContextCompat.getColor(getActivity(), R.color.selected_background)); detailsPresenter.setInitialState(FullWidthDetailsOverviewRowPresenter.STATE_HALF); // Hook up transition element. mHelper = new FullWidthDetailsOverviewSharedElementHelper(); mHelper.setSharedElementEnterTransition(getActivity(), VideoDetailsActivity.SHARED_ELEMENT_NAME); detailsPresenter.setListener(mHelper); detailsPresenter.setParticipatingEntranceTransition(false); prepareEntranceTransition(); detailsPresenter.setOnActionClickedListener(new OnActionClickedListener() { @Override public void onActionClicked(Action action) { if (action.getId() == ACTION_WATCH_TRAILER) { Intent intent = new Intent(getActivity(), PlaybackActivity.class); intent.putExtra(VideoDetailsActivity.VIDEO, mSelectedVideo); startActivity(intent); } else { Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show(); } } }); mPresenterSelector = new ClassPresenterSelector(); mPresenterSelector.addClassPresenter(DetailsOverviewRow.class, detailsPresenter); mPresenterSelector.addClassPresenter(ListRow.class, new ListRowPresenter()); mAdapter = new ArrayObjectAdapter(mPresenterSelector); setAdapter(mAdapter); }
Example #9
Source File: VideoPlayerGlue.java From androidtv-Leanback with Apache License 2.0 | 5 votes |
private boolean shouldDispatchAction(Action action) { return action == mRewindAction || action == mFastForwardAction || action == mThumbsDownAction || action == mThumbsUpAction || action == mRepeatAction; }
Example #10
Source File: VideoPlayerGlue.java From androidtv-Leanback with Apache License 2.0 | 5 votes |
@Override public void onActionClicked(Action action) { if (shouldDispatchAction(action)) { dispatchAction(action); return; } // Super class handles play/pause and delegates to abstract methods next()/previous(). super.onActionClicked(action); }
Example #11
Source File: CustomPlaybackTransportControlGlue.java From jellyfin-androidtv with GNU General Public License v2.0 | 5 votes |
private void notifyActionChanged(Action action) { ArrayObjectAdapter adapter = primaryActionsAdapter; if (adapter.indexOf(action) >= 0) { adapter.notifyArrayItemRangeChanged(adapter.indexOf(action), 1); return; } adapter = secondaryActionsAdapter; if (adapter.indexOf(action) >= 0) { adapter.notifyArrayItemRangeChanged(adapter.indexOf(action), 1); } }
Example #12
Source File: CustomPlaybackTransportControlGlue.java From jellyfin-androidtv with GNU General Public License v2.0 | 5 votes |
public void onCustomActionClicked(Action action, View view) { // Handle custom action clicks which require a popup menu if (action == selectAudioAction) { leanbackOverlayFragment.setFading(false); selectAudioAction.handleClickAction(playbackController, leanbackOverlayFragment, getContext(), view); } else if (action == closedCaptionsAction) { leanbackOverlayFragment.setFading(false); closedCaptionsAction.handleClickAction(playbackController, leanbackOverlayFragment, getContext(), view); } else if (action == adjustAudioDelayAction) { leanbackOverlayFragment.hideOverlay(); adjustAudioDelayAction.handleClickAction(playbackController, leanbackOverlayFragment, getContext(), view); } else if (action == zoomAction) { leanbackOverlayFragment.setFading(false); zoomAction.handleClickAction(playbackController, leanbackOverlayFragment, getContext(), view); } else if (action == chapterAction) { leanbackOverlayFragment.hideOverlay(); playerAdapter.getMasterOverlayFragment().showChapterSelector(); } else if (action == previousLiveTvChannelAction) { playerAdapter.getMasterOverlayFragment().switchChannel(TvManager.getPrevLiveTvChannel()); } else if (action == channelBarChannelAction) { leanbackOverlayFragment.hideOverlay(); playerAdapter.getMasterOverlayFragment().showQuickChannelChanger(); } else if (action == guideAction) { leanbackOverlayFragment.hideOverlay(); playerAdapter.getMasterOverlayFragment().showGuide(); } else if (action == recordAction) { playerAdapter.toggleRecording(); // Icon will be updated via callback recordingStateChanged } }
Example #13
Source File: VideoDetailsFragment.java From tv-samples with Apache License 2.0 | 5 votes |
private void setupDetailsOverviewRow() { final DetailsOverviewRow row = new DetailsOverviewRow(mSelectedVideo); RequestOptions options = new RequestOptions() .error(R.drawable.default_background) .dontAnimate(); Glide.with(this) .asBitmap() .load(mSelectedVideo.cardImageUrl) .apply(options) .into(new SimpleTarget<Bitmap>() { @Override public void onResourceReady( Bitmap resource, Transition<? super Bitmap> transition) { row.setImageBitmap(getActivity(), resource); startEntranceTransition(); } }); SparseArrayObjectAdapter adapter = new SparseArrayObjectAdapter(); adapter.set(ACTION_WATCH_TRAILER, new Action(ACTION_WATCH_TRAILER, getResources() .getString(R.string.watch_trailer_1), getResources().getString(R.string.watch_trailer_2))); adapter.set(ACTION_RENT, new Action(ACTION_RENT, getResources().getString(R.string.rent_1), getResources().getString(R.string.rent_2))); adapter.set(ACTION_BUY, new Action(ACTION_BUY, getResources().getString(R.string.buy_1), getResources().getString(R.string.buy_2))); row.setActionsAdapter(adapter); mAdapter.add(row); }
Example #14
Source File: VideoDetailsFragment.java From tv-samples with Apache License 2.0 | 5 votes |
private void setupAdapter() { // Set detail background and style. FullWidthDetailsOverviewRowPresenter detailsPresenter = new FullWidthDetailsOverviewRowPresenter(new DetailsDescriptionPresenter(), new MovieDetailsOverviewLogoPresenter()); detailsPresenter.setBackgroundColor( ContextCompat.getColor(getActivity(), R.color.selected_background)); detailsPresenter.setInitialState(FullWidthDetailsOverviewRowPresenter.STATE_HALF); // Hook up transition element. mHelper = new FullWidthDetailsOverviewSharedElementHelper(); mHelper.setSharedElementEnterTransition(getActivity(), VideoDetailsActivity.SHARED_ELEMENT_NAME); detailsPresenter.setListener(mHelper); detailsPresenter.setParticipatingEntranceTransition(false); prepareEntranceTransition(); detailsPresenter.setOnActionClickedListener(new OnActionClickedListener() { @Override public void onActionClicked(Action action) { if (action.getId() == ACTION_WATCH_TRAILER) { Intent intent = new Intent(getActivity(), PlaybackActivity.class); intent.putExtra(VideoDetailsActivity.VIDEO, mSelectedVideo); startActivity(intent); } else { Toast.makeText(getActivity(), action.toString(), Toast.LENGTH_SHORT).show(); } } }); mPresenterSelector = new ClassPresenterSelector(); mPresenterSelector.addClassPresenter(DetailsOverviewRow.class, detailsPresenter); mPresenterSelector.addClassPresenter(ListRow.class, new ListRowPresenter()); mAdapter = new ArrayObjectAdapter(mPresenterSelector); setAdapter(mAdapter); }
Example #15
Source File: VideoPlayerGlue.java From tv-samples with Apache License 2.0 | 5 votes |
private boolean shouldDispatchAction(Action action) { return action == mRewindAction || action == mFastForwardAction || action == mThumbsDownAction || action == mThumbsUpAction || action == mRepeatAction; }
Example #16
Source File: ActionsModule.java From tv-samples with Apache License 2.0 | 5 votes |
@PerFragment @PlayActionQualifier @Provides Action providePlayAction() { return new Action(ACTION_PLAY, SampleApplication.getInstance().getString(R.string.livedata_action_play)); }
Example #17
Source File: DetailViewExampleFragment.java From tv-samples with Apache License 2.0 | 5 votes |
@Override public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) { if (!(item instanceof Action)) return; Action action = (Action) item; if (action.getId() == ACTION_RELATED) { setSelectedPosition(1); } else { Toast.makeText(getActivity(), getString(R.string.action_cicked), Toast.LENGTH_LONG) .show(); } }
Example #18
Source File: MediaPlayerGlue.java From tv-samples with Apache License 2.0 | 5 votes |
@Override public void onActionClicked(Action action) { if (action instanceof PlaybackControlsRow.ShuffleAction || action instanceof PlaybackControlsRow.RepeatAction) { ((PlaybackControlsRow.MultiAction) action).nextIndex(); notifySecondaryActionChanged(action); } else if (action == mThumbsUpAction) { if (mThumbsUpAction.getIndex() == PlaybackControlsRow.ThumbsAction.SOLID) { mThumbsUpAction.setIndex(PlaybackControlsRow.ThumbsAction.OUTLINE); notifySecondaryActionChanged(mThumbsUpAction); } else { mThumbsUpAction.setIndex(PlaybackControlsRow.ThumbsAction.SOLID); mThumbsDownAction.setIndex(PlaybackControlsRow.ThumbsAction.OUTLINE); notifySecondaryActionChanged(mThumbsUpAction); notifySecondaryActionChanged(mThumbsDownAction); } } else if (action == mThumbsDownAction) { if (mThumbsDownAction.getIndex() == PlaybackControlsRow.ThumbsAction.SOLID) { mThumbsDownAction.setIndex(PlaybackControlsRow.ThumbsAction.OUTLINE); notifySecondaryActionChanged(mThumbsDownAction); } else { mThumbsDownAction.setIndex(PlaybackControlsRow.ThumbsAction.SOLID); mThumbsUpAction.setIndex(PlaybackControlsRow.ThumbsAction.OUTLINE); notifySecondaryActionChanged(mThumbsUpAction); notifySecondaryActionChanged(mThumbsDownAction); } } else { super.onActionClicked(action); } }
Example #19
Source File: MusicMediaPlayerGlue.java From tv-samples with Apache License 2.0 | 5 votes |
@Override public void onActionClicked(Action action) { // If either 'Shuffle' or 'Repeat' has been clicked we need to make sure the acitons index // is incremented and the UI updated such that we can display the new state. super.onActionClicked(action); if (action instanceof PlaybackControlsRow.RepeatAction) { int index = ((PlaybackControlsRow.RepeatAction) action).getIndex(); if (mPlaybackService != null) { mPlaybackService.setRepeatState(mapActionIndexToServiceRepeatState(index)); } } }
Example #20
Source File: VideoMediaPlayerGlue.java From tv-samples with Apache License 2.0 | 5 votes |
private void dispatchAction(Action action) { if (action == mPipAction) { ((Activity) getContext()).enterPictureInPictureMode(); } else { Toast.makeText(getContext(), action.toString(), Toast.LENGTH_SHORT).show(); PlaybackControlsRow.MultiAction multiAction = (PlaybackControlsRow.MultiAction) action; multiAction.nextIndex(); notifyActionChanged(multiAction); } }
Example #21
Source File: VideoMediaPlayerGlue.java From tv-samples with Apache License 2.0 | 5 votes |
@Override public void onActionClicked(Action action) { if (shouldDispatchAction(action)) { dispatchAction(action); return; } super.onActionClicked(action); }
Example #22
Source File: LiveDataDetailViewWithVideoBackgroundFragment.java From tv-samples with Apache License 2.0 | 5 votes |
@Override public void onActionClicked(Action action) { if (action == mActionRent) { new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... voids) { if (AppConfiguration.IS_RENTING_OPERATION_DELAY_ENABLED) { addDelay(2000L); } // update the database with rented field mViewModel.updateDatabase(mObservedVideo, RENTED, ""); return null; } }.execute(); getActivity().findViewById(R.id.renting_progressbar).setVisibility(View.VISIBLE); getActivity().findViewById(R.id.loading_renting).setVisibility(View.VISIBLE); } else if (action == mActionPlay) { mDetailsBgController.switchToVideo(); } else if (action == mActionPreview) { mDetailsBgController.switchToVideo(); } else if (action == mActionLoading) { Toast.makeText(getActivity(), "Loading...", Toast.LENGTH_SHORT).show(); } }
Example #23
Source File: ActionsModule.java From tv-samples with Apache License 2.0 | 5 votes |
@PerFragment @LoadingActionQualifier @Provides Action provideLoadingAction() { return new Action(ACTION_LOADING, SampleApplication.getInstance().getString(R.string.livedata_action_loading)); }
Example #24
Source File: ActionsModule.java From tv-samples with Apache License 2.0 | 5 votes |
@PerFragment @PreviewActionQualifier @Provides Action providePreviewAction() { return new Action(ACTION_PREVIEW, SampleApplication.getInstance().getString(R.string.livedata_action_preview)); }
Example #25
Source File: ActionsModule.java From tv-samples with Apache License 2.0 | 5 votes |
@PerFragment @RentActionQualifier @Provides Action provideRentAction() { return new Action(ACTION_RENT, SampleApplication.getInstance().getString(R.string.livedata_actoin_rent), SampleApplication.getInstance().getString(R.string.livedata_rent_price), ResourcesCompat .getDrawable( SampleApplication.getInstance().getResources(), R.drawable.ic_favorite_border_white_24dp, SampleApplication.getInstance().getTheme())); }
Example #26
Source File: MediaPlayerGlue.java From tv-samples with Apache License 2.0 | 4 votes |
void notifySecondaryActionChanged(Action act) { notifyItemChanged((ArrayObjectAdapter) getControlsRow().getSecondaryActionsAdapter(), act); }
Example #27
Source File: VideoMediaPlayerGlue.java From tv-samples with Apache License 2.0 | 4 votes |
private boolean shouldDispatchAction(Action action) { return action == mRepeatAction || action == mThumbsUpAction || action == mThumbsDownAction || action == mPipAction || action == mClosedCaptioningAction; }