Java 类android.support.v17.leanback.widget.PlaybackControlsRowPresenter 实例源码

项目:lostfilm-android-client    文件:PlayerActivity.java   
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);
}
项目:chaosflix-leanback    文件:PlaybackHelper.java   
@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;
}
项目:chaosflix    文件:PlaybackHelper.java   
@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;
}
项目:danish-media-license    文件:PlaybackFragment.java   
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);
      }
    }
  });
}
项目:androidtv-sample    文件:PlaybackControlHelper.java   
@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;
}
项目:androidtv-sample    文件:PlaybackOverlayFragment.java   
@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();
}
项目:chilly    文件:PlaybackControlHelper.java   
@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;
}
项目:chilly    文件:PlaybackOverlayFragment.java   
@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();

    }
项目:android_packages_apps_tv    文件:DvrPlaybackOverlayFragment.java   
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);
}
项目:popcorn-android    文件:PTVPlaybackOverlayFragment.java   
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);
}
项目:leanback-showcase    文件:MediaPlayerGlue.java   
@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));
}
项目:youtubetv    文件:MediaPlayerGlue.java   
@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;
}
项目:youtubetv    文件:VideoPlayerFragment.java   
private void addPlaybackControlsRow() {
    final PlaybackControlsRowPresenter controlsPresenter = mGlue
            .createControlsRowAndPresenter();
    mRowsAdapter = new ArrayObjectAdapter(controlsPresenter);
    mRowsAdapter.add(mGlue.getControlsRow());
    setAdapter(mRowsAdapter);
    setOnItemViewClickedListener(this);
}
项目:adt-leanback-support    文件:PlaybackOverlaySupportFragment.java   
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());
    }
}
项目:adt-leanback-support    文件:PlaybackOverlaySupportFragment.java   
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);
}
项目:adt-leanback-support    文件:PlaybackOverlaySupportFragment.java   
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);
    }
}
项目:adt-leanback-support    文件:PlaybackOverlaySupportFragment.java   
@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);
        }
    }
}
项目:adt-leanback-support    文件:PlaybackOverlayFragment.java   
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());
    }
}
项目:adt-leanback-support    文件:PlaybackOverlayFragment.java   
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);
}
项目:adt-leanback-support    文件:PlaybackOverlayFragment.java   
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);
    }
}
项目:adt-leanback-support    文件:PlaybackOverlayFragment.java   
@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);
        }
    }
}
项目:chaosflix-leanback    文件:OverlayFragment.java   
@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();
    }
}
项目:chaosflix    文件:OverlayFragment.java   
@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();
    }
}