PlaybackSupportFragment
public
class
PlaybackSupportFragment
extends Fragment
| java.lang.Object | ||
| ↳ | androidx.fragment.app.Fragment | |
| ↳ | androidx.leanback.app.PlaybackSupportFragment | |
A fragment for displaying playback controls and related content.
A PlaybackSupportFragment renders the elements of its ObjectAdapter as a set
of rows in a vertical list. The Adapter's PresenterSelector must maintain subclasses
of RowPresenter.
A playback row is a row rendered by PlaybackRowPresenter.
App can call setPlaybackRow(Row) to set playback row for the first element of adapter.
App can call setPlaybackRowPresenter(PlaybackRowPresenter) to set presenter for it.
setPlaybackRow(Row) and setPlaybackRowPresenter(PlaybackRowPresenter) are
optional, app can pass playback row and PlaybackRowPresenter in the adapter using
setAdapter(ObjectAdapter).
Hiding and showing controls: the controls are initially visible and automatically show/hide when play/pause or user interacts with fragment.
-
App may manually call
showControlsOverlay(boolean)orhideControlsOverlay(boolean)to show or hide the controls. - The controls are visible by default upon onViewCreated(). To make it initially invisible, call hideControlsOverlay(false) in overridden onViewCreated().
-
Upon play or pause, PlaybackControlGlue or PlaybackTransportControlGlue will fade-in
the controls and automatically fade out after a delay customized by
R.attr.playbackControlsAutoHideTimeout. To disable the fade in and fade out behavior: call#setControlsOverlayAutoHideEnabled(boolean)with false. -
Upon user interaction event, fragment will fade-in the controls and automatically fade
out after a delay customized by
R.attr.playbackControlsAutoHideTickleTimeout. To disable the fade in and fade out behavior, callsetShowOrHideControlsOverlayOnUserInteraction(boolean)with false.
Summary
Constants | |
|---|---|
int |
BG_DARK
A dark translucent background. |
int |
BG_LIGHT
A light translucent background. |
int |
BG_NONE
No background. |
Public constructors | |
|---|---|
PlaybackSupportFragment()
|
|
Public methods | |
|---|---|
void
|
fadeOut()
This method is deprecated.
Call |
ObjectAdapter
|
getAdapter()
|
int
|
getBackgroundType()
Returns the background type. |
ProgressBarManager
|
getProgressBarManager()
Returns the ProgressBarManager that will show or hide progress bar in
|
void
|
hideControlsOverlay(boolean runAnimation)
Hide controls overlay. |
boolean
|
isControlsOverlayAutoHideEnabled()
Returns true if controls will be auto hidden after a delay when fragment is resumed. |
boolean
|
isControlsOverlayVisible()
Returns true if controls overlay is visible, false otherwise. |
boolean
|
isFadingEnabled()
This method is deprecated.
Uses |
boolean
|
isShowOrHideControlsOverlayOnUserInteraction()
Returns true if showing and auto-hiding controls when user interacts; false otherwise. |
void
|
notifyPlaybackRowChanged()
Updates the ui when the row data changes. |
void
|
onCreate(Bundle savedInstanceState)
Called to do initial creation of a fragment. |
View
|
onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
Called to have the fragment instantiate its user interface view. |
void
|
onDestroy()
Called when the fragment is no longer in use. |
void
|
onDestroyView()
Called when the view previously created by |
void
|
onPause()
Called when the Fragment is no longer resumed. |
void
|
onResume()
Called when the fragment is visible to the user and actively running. |
void
|
onStart()
Called when the Fragment is visible to the user. |
void
|
onStop()
Called when the Fragment is no longer started. |
void
|
onViewCreated(View view, Bundle savedInstanceState)
Called immediately after |
void
|
setAdapter(ObjectAdapter adapter)
Sets the list of rows for the fragment. |
void
|
setBackgroundType(int type)
Sets the background type. |
void
|
setControlsOverlayAutoHideEnabled(boolean enabled)
Enables or disables auto hiding controls overlay after a short delay fragment is resumed. |
void
|
setFadingEnabled(boolean enabled)
This method is deprecated.
Uses |
void
|
setHostCallback(PlaybackGlueHost.HostCallback hostCallback)
Sets the |
void
|
setOnItemViewClickedListener(BaseOnItemViewClickedListener listener)
This listener is called every time there is a click in |
void
|
setOnItemViewSelectedListener(BaseOnItemViewSelectedListener listener)
This listener is called every time there is a selection in |
final
void
|
setOnKeyInterceptListener(View.OnKeyListener handler)
Sets the input event handler. |
void
|
setOnPlaybackItemViewClickedListener(BaseOnItemViewClickedListener listener)
Sets the |
void
|
setPlaybackRow(Row row)
Sets the playback row for the playback controls. |
void
|
setPlaybackRowPresenter(PlaybackRowPresenter presenter)
Sets the presenter for rendering the playback row set by |
void
|
setPlaybackSeekUiClient(PlaybackSeekUi.Client client)
Interface to be implemented by UI widget to support PlaybackSeekUi. |
void
|
setSelectedPosition(int position)
Sets the selected row position with smooth animation. |
void
|
setSelectedPosition(int position, boolean smooth)
Sets the selected row position. |
void
|
setShowOrHideControlsOverlayOnUserInteraction(boolean showOrHideControlsOverlayOnUserInteraction)
Enables or disables showing and auto-hiding controls when user interacts. |
void
|
showControlsOverlay(boolean runAnimation)
Show controls overlay. |
void
|
tickle()
Tickles the playback controls. |
Protected methods | |
|---|---|
void
|
onBufferingStateChanged(boolean start)
Called when media has start or stop buffering. |
void
|
onError(int errorCode, CharSequence errorMessage)
Called when media has error. |
void
|
onVideoSizeChanged(int videoWidth, int videoHeight)
Called when size of the video changes. |
Inherited methods | |
|---|---|