public class

PlaybackSupportFragmentGlueHost

extends PlaybackGlueHost

implements PlaybackSeekUi

 java.lang.Object

androidx.leanback.media.PlaybackGlueHost

↳androidx.leanback.app.PlaybackSupportFragmentGlueHost

Subclasses:

VideoSupportFragmentGlueHost

Gradle dependencies

compile group: 'androidx.leanback', name: 'leanback', version: '1.2.0-alpha04'

  • groupId: androidx.leanback
  • artifactId: leanback
  • version: 1.2.0-alpha04

Artifact androidx.leanback:leanback:1.2.0-alpha04 it located at Google repository (https://maven.google.com/)

Androidx artifact mapping:

androidx.leanback:leanback com.android.support:leanback-v17

Androidx class mapping:

androidx.leanback.app.PlaybackSupportFragmentGlueHost android.support.v17.leanback.app.PlaybackSupportFragmentGlueHost

Overview

PlaybackGlueHost implementation the interaction between this class and PlaybackSupportFragment.

Summary

Constructors
publicPlaybackSupportFragmentGlueHost(PlaybackSupportFragment fragment)

Methods
public voidfadeOut()

Fades out the playback overlay immediately.

public PlaybackGlueHost.PlayerCallbackgetPlayerCallback()

Implemented by PlaybackGlueHost for responding to player events.

public voidhideControlsOverlay(boolean runAnimation)

Hide controls overlay.

public booleanisControlsOverlayAutoHideEnabled()

Returns true if auto hides controls overlay.

public booleanisControlsOverlayVisible()

Returns true if controls overlay is visible, false otherwise.

public voidnotifyPlaybackRowChanged()

Notifies host about a change so it can update the view.

public voidsetControlsOverlayAutoHideEnabled(boolean enabled)

Enables or disables controls overlay auto hidden.

public voidsetHostCallback(PlaybackGlueHost.HostCallback callback)

Sets the host PlaybackGlueHost.HostCallback callback on the host.

public voidsetOnActionClickedListener(OnActionClickedListener listener)

Sets the on this fragment.

public voidsetOnKeyInterceptListener(View.OnKeyListener onKeyListener)

Sets the on the host.

public voidsetPlaybackRow(Row row)

Sets the Row that represents the information on control items that needs to be rendered.

public voidsetPlaybackRowPresenter(PlaybackRowPresenter presenter)

Sets PlaybackRowPresenter for rendering the playback controls.

public voidsetPlaybackSeekUiClient(PlaybackSeekUi.Client client)

public voidshowControlsOverlay(boolean runAnimation)

Show controls overlay.

from PlaybackGlueHostsetFadingEnabled
from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public PlaybackSupportFragmentGlueHost(PlaybackSupportFragment fragment)

Methods

public void setControlsOverlayAutoHideEnabled(boolean enabled)

Enables or disables controls overlay auto hidden. If enabled, the view will be faded out after a time period.

Parameters:

enabled: True to enable auto hidden of controls overlay.

public boolean isControlsOverlayAutoHideEnabled()

Returns true if auto hides controls overlay.

Returns:

True if auto hiding controls overlay.

public void setOnKeyInterceptListener(View.OnKeyListener onKeyListener)

Sets the on the host. This would trigger the listener when a is unhandled by the host.

public void setOnActionClickedListener(OnActionClickedListener listener)

Sets the on this fragment.

public void setHostCallback(PlaybackGlueHost.HostCallback callback)

Sets the host PlaybackGlueHost.HostCallback callback on the host. This method should only be called by PlaybackGlue. App should not directly call this method, app should override PlaybackGlue.onHostStart() etc.

public void notifyPlaybackRowChanged()

Notifies host about a change so it can update the view.

public void setPlaybackRowPresenter(PlaybackRowPresenter presenter)

Sets PlaybackRowPresenter for rendering the playback controls.

public void setPlaybackRow(Row row)

Sets the Row that represents the information on control items that needs to be rendered.

public void fadeOut()

Deprecated: Call PlaybackGlueHost.hideControlsOverlay(boolean)

Fades out the playback overlay immediately.

public boolean isControlsOverlayVisible()

Returns true if controls overlay is visible, false otherwise.

Returns:

True if controls overlay is visible, false otherwise.

See also: PlaybackGlueHost.showControlsOverlay(boolean), PlaybackGlueHost.hideControlsOverlay(boolean)

public void hideControlsOverlay(boolean runAnimation)

Hide controls overlay.

Parameters:

runAnimation: True to run animation, false otherwise.

public void showControlsOverlay(boolean runAnimation)

Show controls overlay.

Parameters:

runAnimation: True to run animation, false otherwise.

public void setPlaybackSeekUiClient(PlaybackSeekUi.Client client)

public PlaybackGlueHost.PlayerCallback getPlayerCallback()

Implemented by PlaybackGlueHost for responding to player events. Such as showing a spinning wheel progress bar when PlaybackGlueHost.PlayerCallback.onBufferingStateChanged(boolean).

Returns:

PlayerEventCallback that Host supports, null if not supported.

Source

/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */
package androidx.leanback.app;

import android.view.View;

import androidx.leanback.media.PlaybackGlueHost;
import androidx.leanback.widget.Action;
import androidx.leanback.widget.OnActionClickedListener;
import androidx.leanback.widget.OnItemViewClickedListener;
import androidx.leanback.widget.PlaybackRowPresenter;
import androidx.leanback.widget.PlaybackSeekUi;
import androidx.leanback.widget.Presenter;
import androidx.leanback.widget.Row;
import androidx.leanback.widget.RowPresenter;

/**
 * {@link PlaybackGlueHost} implementation
 * the interaction between this class and {@link PlaybackSupportFragment}.
 */
public class PlaybackSupportFragmentGlueHost extends PlaybackGlueHost implements PlaybackSeekUi {
    final PlaybackSupportFragment mFragment;

    public PlaybackSupportFragmentGlueHost(PlaybackSupportFragment fragment) {
        this.mFragment = fragment;
    }

    @Override
    public void setControlsOverlayAutoHideEnabled(boolean enabled) {
        mFragment.setControlsOverlayAutoHideEnabled(enabled);
    }

    @Override
    public boolean isControlsOverlayAutoHideEnabled() {
        return mFragment.isControlsOverlayAutoHideEnabled();
    }

    @Override
    public void setOnKeyInterceptListener(View.OnKeyListener onKeyListener) {
        mFragment.setOnKeyInterceptListener(onKeyListener);
    }

    @Override
    public void setOnActionClickedListener(final OnActionClickedListener listener) {
        if (listener == null) {
            mFragment.setOnPlaybackItemViewClickedListener(null);
        } else {
            mFragment.setOnPlaybackItemViewClickedListener(new OnItemViewClickedListener() {
                @Override
                public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item,
                                          RowPresenter.ViewHolder rowViewHolder, Row row) {
                    if (item instanceof Action) {
                        listener.onActionClicked((Action) item);
                    }
                }
            });
        }
    }

    @Override
    public void setHostCallback(HostCallback callback) {
        mFragment.setHostCallback(callback);
    }

    @Override
    public void notifyPlaybackRowChanged() {
        mFragment.notifyPlaybackRowChanged();
    }

    @Override
    public void setPlaybackRowPresenter(PlaybackRowPresenter presenter) {
        mFragment.setPlaybackRowPresenter(presenter);
    }

    @Override
    public void setPlaybackRow(Row row) {
        mFragment.setPlaybackRow(row);
    }

    @Override
    public void fadeOut() {
        mFragment.fadeOut();
    }

    @Override
    public boolean isControlsOverlayVisible() {
        return mFragment.isControlsOverlayVisible();
    }

    @Override
    public void hideControlsOverlay(boolean runAnimation) {
        mFragment.hideControlsOverlay(runAnimation);
    }

    @Override
    public void showControlsOverlay(boolean runAnimation) {
        mFragment.showControlsOverlay(runAnimation);
    }

    @Override
    public void setPlaybackSeekUiClient(Client client) {
        mFragment.setPlaybackSeekUiClient(client);
    }

    final PlayerCallback mPlayerCallback =
            new PlayerCallback() {
                @Override
                public void onBufferingStateChanged(boolean start) {
                    mFragment.onBufferingStateChanged(start);
                }

                @Override
                public void onError(int errorCode, CharSequence errorMessage) {
                    mFragment.onError(errorCode, errorMessage);
                }

                @Override
                public void onVideoSizeChanged(int videoWidth, int videoHeight) {
                    mFragment.onVideoSizeChanged(videoWidth, videoHeight);
                }
            };

    @Override
    public PlayerCallback getPlayerCallback() {
        return mPlayerCallback;
    }
}