private void setupUI() { VideoFragment videoFragment = (VideoFragment) getFragmentManager().findFragmentById(R.id.video_fragment); mGlue = new VideoFragmentGlueHost(videoFragment); mGlue.setSurfaceHolderCallback(this); mGlue.setOnActionClickedListener(this); mControlsRow = new PlaybackControlsRow(mSelectedLink); ArrayObjectAdapter adapter = new ArrayObjectAdapter(new ControlButtonPresenterSelector()); mPlayPauseAction = new PlaybackControlsRow.PlayPauseAction(this); mPlayPauseAction.nextIndex(); // set to play adapter.add(new PlaybackControlsRow.RewindAction(this)); adapter.add(mPlayPauseAction); adapter.add(new PlaybackControlsRow.FastForwardAction(this)); mControlsRow.setPrimaryActionsAdapter(adapter); PlaybackControlsRowPresenter presenter = new PlaybackControlsRowPresenter(new DetailsPresenter()); mGlue.setPlaybackRow(mControlsRow); mGlue.setPlaybackRowPresenter(presenter); }
@Override public PlaybackControlsRowPresenter createControlsRowAndPresenter() { PlaybackControlsRowPresenter presenter = super.createControlsRowAndPresenter(); adapter = new ArrayObjectAdapter(new ControlButtonPresenterSelector()); getControlsRow().setSecondaryActionsAdapter(adapter); mFastForwardAction = (PlaybackControlsRow.FastForwardAction) getPrimaryActionsAdapter() .lookup(ACTION_FAST_FORWARD); mRewindAction = (PlaybackControlsRow.RewindAction) getPrimaryActionsAdapter() .lookup(ACTION_REWIND); presenter.setOnActionClickedListener(new OnActionClickedListener() { @Override public void onActionClicked(Action action) { dispatchAction(action); } }); return presenter; }
private void initUi() { PlaybackControlsRowPresenter presenter = mediaControllerHelper.createControlsRowAndPresenter(); rows = new ArrayObjectAdapter(presenter); rows.add(mediaControllerHelper.getControlsRow()); setAdapter(rows); setOnItemViewClickedListener(new OnItemViewClickedListener() { @Override public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) { if (item instanceof Action) { mediaControllerHelper.onActionClicked((Action) item); } } }); }
@Override public PlaybackControlsRowPresenter createControlsRowAndPresenter() { PlaybackControlsRowPresenter presenter = super.createControlsRowAndPresenter(); ArrayObjectAdapter adapter = new ArrayObjectAdapter(new ControlButtonPresenterSelector()); getControlsRow().setSecondaryActionsAdapter(adapter); mFastForwardAction = (PlaybackControlsRow.FastForwardAction) getPrimaryActionsAdapter() .lookup(ACTION_FAST_FORWARD); mRewindAction = (PlaybackControlsRow.RewindAction) getPrimaryActionsAdapter() .lookup(ACTION_REWIND); // odebrani zbytecnych tlacitek /* adapter.add(mThumbsDownAction); adapter.add(mRepeatAction); adapter.add(mThumbsUpAction); */ if (PlaybackOverlayActivity.supportsPictureInPicture(getContext())) { adapter.add(mPipAction); } presenter.setOnActionClickedListener(new OnActionClickedListener() { @Override public void onActionClicked(Action action) { dispatchAction(action); } }); return presenter; }
@Override public void onStart() { super.onStart(); // Set up UI Video video = getActivity().getIntent().getParcelableExtra(VideoDetailsActivity.VIDEO); if (!updateSelectedVideo(video)) { return; } mGlue = new PlaybackControlHelper(getActivity(), this, mSelectedVideo); PlaybackControlsRowPresenter controlsRowPresenter = mGlue.createControlsRowAndPresenter(); PlaybackControlsRow controlsRow = mGlue.getControlsRow(); mMediaControllerCallback = mGlue.createMediaControllerCallback(); mMediaController = getActivity().getMediaController(); mMediaController.registerCallback(mMediaControllerCallback); ClassPresenterSelector ps = new ClassPresenterSelector(); ps.addClassPresenter(PlaybackControlsRow.class, controlsRowPresenter); ps.addClassPresenter(ListRow.class, new ListRowPresenter()); mRowsAdapter = new ArrayObjectAdapter(ps); mRowsAdapter.add(controlsRow); addOtherRows(); updatePlaybackRow(); setAdapter(mRowsAdapter); startPlaying(); }
@Override public PlaybackControlsRowPresenter createControlsRowAndPresenter() { PlaybackControlsRowPresenter presenter = super.createControlsRowAndPresenter(); ArrayObjectAdapter adapter = new ArrayObjectAdapter(new ControlButtonPresenterSelector()); getControlsRow().setSecondaryActionsAdapter(adapter); mFastForwardAction = (PlaybackControlsRow.FastForwardAction) getPrimaryActionsAdapter() .lookup(ACTION_FAST_FORWARD); mRewindAction = (PlaybackControlsRow.RewindAction) getPrimaryActionsAdapter() .lookup(ACTION_REWIND); adapter.add(mThumbsDownAction); adapter.add(mRepeatAction); adapter.add(mThumbsUpAction); if (PlaybackOverlayActivity.supportsPictureInPicture(getContext())) { adapter.add(mPipAction); } presenter.setOnActionClickedListener(new OnActionClickedListener() { @Override public void onActionClicked(Action action) { dispatchAction(action); } }); return presenter; }
@Override public void onStart() { super.onStart(); // Set up UI Video video = getActivity().getIntent().getParcelableExtra(VideoDetailsActivity.VIDEO); if (!updateSelectedVideo(video)) { return; } mGlue = new PlaybackControlHelper(getActivity(), this, mSelectedVideo); PlaybackControlsRowPresenter controlsRowPresenter = mGlue.createControlsRowAndPresenter(); PlaybackControlsRow controlsRow = mGlue.getControlsRow(); mMediaControllerCallback = mGlue.createMediaControllerCallback(); // mMediaController = getActivity().getMediaController(); mMediaController.registerCallback(mMediaControllerCallback); // ClassPresenterSelector ps = new ClassPresenterSelector(); ps.addClassPresenter(PlaybackControlsRow.class, controlsRowPresenter); ps.addClassPresenter(ListRow.class, new ListRowPresenter()); mRowsAdapter = new ArrayObjectAdapter(ps); mRowsAdapter.add(controlsRow); addOtherRows(); updatePlaybackRow(); setAdapter(mRowsAdapter); startPlaying(); }
private void setUpRows() { PlaybackControlsRowPresenter controlsRowPresenter = mPlaybackControlHelper.createControlsRowAndPresenter(); ClassPresenterSelector selector = new ClassPresenterSelector(); selector.addClassPresenter(PlaybackControlsRow.class, controlsRowPresenter); selector.addClassPresenter(ListRow.class, new ListRowPresenter()); mRowsAdapter = new ArrayObjectAdapter(selector); mRowsAdapter.add(mPlaybackControlHelper.getControlsRow()); mRelatedRecordingsRow = getRelatedRecordingsRow(); setAdapter(mRowsAdapter); }
private void initialisePlaybackControlPresenter() { ClassPresenterSelector presenterSelector = new ClassPresenterSelector(); mPlaybackControlsRowPresenter = new PlaybackControlsRowPresenter(new DescriptionPresenter()); mPlaybackControlsRowPresenter.setSecondaryActionsHidden(false); presenterSelector.addClassPresenter(PlaybackControlsRow.class, mPlaybackControlsRowPresenter); presenterSelector.addClassPresenter(ListRow.class, new ListRowPresenter()); mRowsAdapter = new ArrayObjectAdapter(presenterSelector); setAdapter(mRowsAdapter); }
@Override protected void onCreateControlsRowAndPresenter() { super.onCreateControlsRowAndPresenter(); PlaybackControlsRowPresenter presenter = (PlaybackControlsRowPresenter) getPlaybackRowPresenter(); presenter.setProgressColor(getContext().getResources().getColor( R.color.player_progress_color)); presenter.setBackgroundColor(getContext().getResources().getColor( R.color.player_background_color)); }
@Override public PlaybackControlsRowPresenter createControlsRowAndPresenter() { PlaybackControlsRowPresenter presenter = super.createControlsRowAndPresenter(); mControlsRow = getControlsRow(); // Add secondary actions and change the control row color. ArrayObjectAdapter secondaryActions = new ArrayObjectAdapter( new ControlButtonPresenterSelector()); mControlsRow.setSecondaryActionsAdapter(secondaryActions); addSecondaryActions(secondaryActions); setupControlsRowPresenter(presenter); return presenter; }
private void addPlaybackControlsRow() { final PlaybackControlsRowPresenter controlsPresenter = mGlue .createControlsRowAndPresenter(); mRowsAdapter = new ArrayObjectAdapter(controlsPresenter); mRowsAdapter.add(mGlue.getControlsRow()); setAdapter(mRowsAdapter); setOnItemViewClickedListener(this); }
private void resetControlsToPrimaryActions(ItemBridgeAdapter.ViewHolder vh) { if (vh == null && getVerticalGridView() != null) { vh = (ItemBridgeAdapter.ViewHolder) getVerticalGridView().findViewHolderForPosition(0); } if (vh == null) { mResetControlsToPrimaryActionsPending = true; } else if (vh.getPresenter() instanceof PlaybackControlsRowPresenter) { mResetControlsToPrimaryActionsPending = false; ((PlaybackControlsRowPresenter) vh.getPresenter()).showPrimaryActions( (PlaybackControlsRowPresenter.ViewHolder) vh.getViewHolder()); } }
private void loadDescriptionAnimator() { AnimatorUpdateListener listener = new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator arg0) { if (getVerticalGridView() == null) { return; } ItemBridgeAdapter.ViewHolder adapterVh = (ItemBridgeAdapter.ViewHolder) getVerticalGridView().findViewHolderForPosition(0); if (adapterVh != null && adapterVh.getViewHolder() instanceof PlaybackControlsRowPresenter.ViewHolder) { final Presenter.ViewHolder vh = ((PlaybackControlsRowPresenter.ViewHolder) adapterVh.getViewHolder()).mDescriptionViewHolder; if (vh != null) { vh.view.setAlpha((Float) arg0.getAnimatedValue()); } } } }; mDescriptionFadeInAnimator = loadAnimator( getActivity(), R.animator.lb_playback_description_fade_in); mDescriptionFadeInAnimator.addUpdateListener(listener); mDescriptionFadeInAnimator.setInterpolator(mLogDecelerateInterpolator); mDescriptionFadeOutAnimator = loadAnimator( getActivity(), R.animator.lb_playback_description_fade_out); mDescriptionFadeOutAnimator.addUpdateListener(listener); }
private void updateControlsBottomSpace(ItemBridgeAdapter.ViewHolder vh) { // Add extra space between rows 0 and 1 if (vh == null && getVerticalGridView() != null) { vh = (ItemBridgeAdapter.ViewHolder) getVerticalGridView().findViewHolderForPosition(0); } if (vh != null && vh.getPresenter() instanceof PlaybackControlsRowPresenter) { final int adapterSize = getAdapter() == null ? 0 : getAdapter().size(); ((PlaybackControlsRowPresenter) vh.getPresenter()).showBottomSpace( (PlaybackControlsRowPresenter.ViewHolder) vh.getViewHolder(), adapterSize > 1); } }
@Override public void onDetachedFromWindow(ItemBridgeAdapter.ViewHolder vh) { if (DEBUG) Log.v(TAG, "onDetachedFromWindow " + vh.getViewHolder().view); // Reset animation state vh.getViewHolder().view.setAlpha(1f); vh.getViewHolder().view.setTranslationY(0); if (vh.getViewHolder() instanceof PlaybackControlsRowPresenter.ViewHolder) { Presenter.ViewHolder descriptionVh = ((PlaybackControlsRowPresenter.ViewHolder) vh.getViewHolder()).mDescriptionViewHolder; if (descriptionVh != null) { descriptionVh.view.setAlpha(1f); } } }
@Override public synchronized void onStart() { super.onStart(); Log.d(TAG, "OnStart"); PlaybackControlsRowPresenter playbackControlsRowPresenter = mHelper.createControlsRowAndPresenter(); PlaybackControlsRow controlsRow = mHelper.getControlsRow(); mMediaControllerCallback = mHelper.createMediaControllerCallback(); requestAudioFocus(); mMediaControler = getActivity().getMediaController(); if (mMediaControler != null) { mMediaControler.registerCallback(mMediaControllerCallback); } else { Log.d(TAG, "MediaController is null"); getActivity().finish(); } ClassPresenterSelector ps = new ClassPresenterSelector(); ps.addClassPresenter(PlaybackControlsRow.class, playbackControlsRowPresenter); ps.addClassPresenter(ListRow.class, new ListRowPresenter()); mRowsAdapter = new ArrayObjectAdapter(ps); mRowsAdapter.add(controlsRow); if (eventType == DetailsActivity.TYPE_RECORDING) { if (mSelectedEvent.getMetadata() != null && mSelectedEvent.getMetadata().getRelated() != null) { mRowsAdapter.add(getRelatedItems()); setOnItemViewClickedListener(new ItemViewClickedListener(this)); } } else if (eventType == DetailsActivity.TYPE_STREAM) { // TODO add other streams as related events } setAdapter(mRowsAdapter); if (mCallback != null && eventType == DetailsActivity.TYPE_STREAM) { mCallback.setVideoSource(mSelectedStream.getUrl()); } else if (mCallback != null && eventType == DetailsActivity.TYPE_RECORDING) { mCallback.setVideoSource(mSelectedRecording.getRecordingUrl()); } else { Log.d(TAG, "Callback not set or not event/stream"); } requestAudioFocus(); if (mPlaybackProgress != null) { showContinueOrRestartDialog(); } else { play(); } }