DetailsFragment
class DetailsFragment : BaseFragment
| kotlin.Any | ||||
| ↳ | android.app.Fragment | |||
| ↳ | androidx.leanback.app.BrandedFragment | |||
| ↳ | androidx.leanback.app.BaseFragment | |||
| ↳ | androidx.leanback.app.DetailsFragment |
A fragment for creating Leanback details screens.
A DetailsFragment renders the elements of its ObjectAdapter as a set of rows in a vertical list.The Adapter's PresenterSelector must maintain subclasses of RowPresenter.
FullWidthDetailsOverviewRowPresenter is found in adapter, DetailsFragment will setup default behavior of the DetailsOverviewRow:
- The alignment of FullWidthDetailsOverviewRowPresenter is setup in
setupDetailsOverviewRowPresenter. - The view status switching of FullWidthDetailsOverviewRowPresenter is done in
onSetDetailsOverviewRowStatus.
The recommended activity themes to use with a DetailsFragment are
Theme_Leanback_Detailswith activity shared element transition forFullWidthDetailsOverviewRowPresenter.Theme_Leanback_Details_NoSharedElementTransitionif shared element transition is not needed, for example if first row is not rendered byFullWidthDetailsOverviewRowPresenter.
DetailsFragment can use DetailsFragmentBackgroundController to add a parallax drawable background and embedded video playing fragment.
Summary
Public constructors |
|---|
Public functions |
|
|---|---|
ObjectAdapter! |
Returns the list of rows. |
BaseOnItemViewClickedListener! |
Returns the item clicked listener. |
DetailsParallax! |
Returns the |
RowsFragment! |
Gets embedded RowsFragment showing multiple rows for DetailsFragment. |
Unit |
This function is deprecated. |
View? |
This function is deprecated. |
Unit |
This function is deprecated. |
View |
Called by |
Unit |
This function is deprecated. |
Unit |
This function is deprecated. |
Unit |
Sets the list of rows for the fragment. |
Unit |
Sets an item clicked listener. |
Unit |
Sets an item selection listener. |
Unit |
Sets the selected row position with smooth animation. |
Unit |
Sets the selected row position. |
Protected functions |
|
|---|---|
Any! |
Create entrance transition. |
View! |
This function is deprecated. override |
Unit |
Callback when entrance transition is ended. |
Unit |
Callback when entrance transition is prepared. |
Unit |
Callback when entrance transition is started. |
Unit |
Called to change DetailsOverviewRow view status when current selected row position or selected sub position changed. |
Unit |
Called on every visible row to change view status when current selected row position or selected sub position changed. |
Unit |
Run entrance transition. |
Unit |
Called to setup |
Unit |
Called to setup each Presenter of Adapter passed in |
Inherited Constants |
||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Inherited functions |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Public constructors
Public functions
fungetOnItemViewClickedListener(): BaseOnItemViewClickedListener!
Returns the item clicked listener.
fungetParallax(): DetailsParallax!
Returns the DetailsParallax instance used by DetailsFragmentBackgroundController to configure parallax effect of background and control embedded video playback. App usually does not use this method directly. App may use this method for other custom parallax tasks.
| Returns | |
|---|---|
DetailsParallax! |
The DetailsParallax instance attached to the DetailsFragment. |
fungetRowsFragment(): RowsFragment!
Gets embedded RowsFragment showing multiple rows for DetailsFragment. If view of DetailsFragment is not created, the method returns null.
| Returns | |
|---|---|
RowsFragment! |
Embedded RowsFragment showing multiple rows for DetailsFragment. |
funonCreateView(
inflater: LayoutInflater!,
container: ViewGroup?,
savedInstanceState: Bundle!
): View?
onInflateTitleView
funonInflateTitleView(
inflater: LayoutInflater,
parent: ViewGroup?,
savedInstanceState: Bundle?
): View
Called by installTitleView to inflate title view. Default implementation uses layout file lb_browse_title. Subclass may override and use its own layout, the layout must have a descendant with id browse_title_group that implements TitleViewAdapter.Provider. Subclass may return null if no title is needed.
| Parameters | |
|---|---|
inflater: LayoutInflater |
The LayoutInflater object that can be used to inflate any views in the fragment, |
parent: ViewGroup? |
Parent of title view. |
savedInstanceState: Bundle? |
If non-null, this fragment is being re-constructed from a previous saved state as given here. |
| Returns | |
|---|---|
View |
Title view which must have a descendant with id browse_title_group that implements |
funsetOnItemViewClickedListener(listener: BaseOnItemViewClickedListener!): Unit
Sets an item clicked listener.
funsetOnItemViewSelectedListener(listener: BaseOnItemViewSelectedListener!): Unit
Sets an item selection listener.
Protected functions
createEntranceTransition
protected funcreateEntranceTransition(): Any!
Create entrance transition. Subclass can override to load transition from resource or construct manually. Typically app does not need to override the default transition that browse and details provides.
protected funinflateTitle(
inflater: LayoutInflater!,
parent: ViewGroup!,
savedInstanceState: Bundle!
): View!
onEntranceTransitionEnd
protected funonEntranceTransitionEnd(): Unit
Callback when entrance transition is ended.
onEntranceTransitionPrepare
protected funonEntranceTransitionPrepare(): Unit
Callback when entrance transition is prepared. This is when fragment should stop user input and animations.
onEntranceTransitionStart
protected funonEntranceTransitionStart(): Unit
Callback when entrance transition is started. This is when fragment should stop processing layout.
protected funonSetDetailsOverviewRowStatus(
presenter: FullWidthDetailsOverviewRowPresenter!,
viewHolder: FullWidthDetailsOverviewRowPresenter.ViewHolder!,
adapterPosition: Int,
selectedPosition: Int,
selectedSubPosition: Int
): Unit
Called to change DetailsOverviewRow view status when current selected row position or selected sub position changed. Subclass may override. The default implementation switches between three states based on the positions: STATE_HALF, STATE_FULL and STATE_SMALL.
| Parameters | |
|---|---|
presenter: FullWidthDetailsOverviewRowPresenter! |
The presenter used to create row ViewHolder. |
viewHolder: FullWidthDetailsOverviewRowPresenter.ViewHolder! |
The visible (attached) row ViewHolder, note that it may or may not be selected. |
adapterPosition: Int |
The adapter position of viewHolder inside adapter. |
selectedPosition: Int |
The adapter position of currently selected row. |
selectedSubPosition: Int |
The sub position within currently selected row. This is used When a row has multiple alignment positions. |
protected funonSetRowStatus(
presenter: RowPresenter!,
viewHolder: RowPresenter.ViewHolder!,
adapterPosition: Int,
selectedPosition: Int,
selectedSubPosition: Int
): Unit
Called on every visible row to change view status when current selected row position or selected sub position changed. Subclass may override. The default implementation calls onSetDetailsOverviewRowStatus if presenter is instance of FullWidthDetailsOverviewRowPresenter.
| Parameters | |
|---|---|
presenter: RowPresenter! |
The presenter used to create row ViewHolder. |
viewHolder: RowPresenter.ViewHolder! |
The visible (attached) row ViewHolder, note that it may or may not be selected. |
adapterPosition: Int |
The adapter position of viewHolder inside adapter. |
selectedPosition: Int |
The adapter position of currently selected row. |
selectedSubPosition: Int |
The sub position within currently selected row. This is used When a row has multiple alignment positions. |
runEntranceTransition
protected funrunEntranceTransition(entranceTransition: Any!): Unit
Run entrance transition. Subclass may use TransitionManager to perform go(Scene) or beginDelayedTransition(). App should not override the default implementation of browse and details fragment.
protected funsetupDetailsOverviewRowPresenter(
presenter: FullWidthDetailsOverviewRowPresenter!
): Unit
Called to setup FullWidthDetailsOverviewRowPresenter. The default implementation adds two alignment positions(ItemAlignmentFacet) for ViewHolder of FullWidthDetailsOverviewRowPresenter to align in fragment.
protected funsetupPresenter(rowPresenter: Presenter!): Unit
Called to setup each Presenter of Adapter passed in setAdapter.Note that setup should only change the Presenter behavior that is meaningful in DetailsFragment. For example how a row is aligned in details Fragment. The default implementation invokes setupDetailsOverviewRowPresenter