DetailsSupportFragment
class DetailsSupportFragment : BaseSupportFragment
| kotlin.Any | ||||
| ↳ | androidx.fragment.app.Fragment | |||
| ↳ | androidx.leanback.app.BrandedSupportFragment | |||
| ↳ | androidx.leanback.app.BaseSupportFragment | |||
| ↳ | androidx.leanback.app.DetailsSupportFragment |
A fragment for creating Leanback details screens.
A DetailsSupportFragment 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, DetailsSupportFragment 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 DetailsSupportFragment 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.
DetailsSupportFragment can use DetailsSupportFragmentBackgroundController 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 |
RowsSupportFragment! |
Gets embedded RowsSupportFragment showing multiple rows for DetailsSupportFragment. |
Unit |
Called to do initial creation of a fragment. |
View? |
onCreateView(Called to have the fragment instantiate its user interface view. |
Unit |
Called when the view previously created by |
View |
onInflateTitleView(Called by |
Unit |
onStart()Called when the Fragment is visible to the user. |
Unit |
onStop()Called when the Fragment is no longer started. |
Unit |
setAdapter(adapter: ObjectAdapter!)Sets the list of rows for the fragment. |
Unit |
Sets an item clicked listener. |
Unit |
Sets an item selection listener. |
Unit |
setSelectedPosition(position: Int)Sets the selected row position with smooth animation. |
Unit |
setSelectedPosition(position: Int, smooth: Boolean)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 |
onSetDetailsOverviewRowStatus(Called to change DetailsOverviewRow view status when current selected row position or selected sub position changed. |
Unit |
onSetRowStatus(Called on every visible row to change view status when current selected row position or selected sub position changed. |
Unit |
runEntranceTransition(entranceTransition: Any!)Run entrance transition. |
Unit |
Called to setup |
Unit |
setupPresenter(rowPresenter: Presenter!)Called to setup each Presenter of Adapter passed in |
Inherited functions |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Public constructors
Public functions
getOnItemViewClickedListener
fun getOnItemViewClickedListener(): BaseOnItemViewClickedListener!
Returns the item clicked listener.
getParallax
fun getParallax(): DetailsParallax!
Returns the DetailsParallax instance used by DetailsSupportFragmentBackgroundController 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 DetailsSupportFragment. |
getRowsSupportFragment
fun getRowsSupportFragment(): RowsSupportFragment!
Gets embedded RowsSupportFragment showing multiple rows for DetailsSupportFragment. If view of DetailsSupportFragment is not created, the method returns null.
| Returns | |
|---|---|
RowsSupportFragment! |
Embedded RowsSupportFragment showing multiple rows for DetailsSupportFragment. |
onCreate
fun onCreate(savedInstanceState: Bundle!): Unit
Called to do initial creation of a fragment. This is called after onAttach and before onCreateView.
Note that this can be called while the fragment's activity is still in the process of being created. As such, you can not rely on things like the activity's content view hierarchy being initialized at this point. If you want to do work once the activity itself is created, add a androidx.lifecycle.LifecycleObserver on the activity's Lifecycle, removing it when it receives the CREATED callback.
Any restored child fragments will be created before the base Fragment.onCreate method returns.
| Parameters | |
|---|---|
savedInstanceState: Bundle! |
If the fragment is being re-created from a previous saved state, this is the state. |
onCreateView
fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View?
Called to have the fragment instantiate its user interface view. This is optional, and non-graphical fragments can return null. This will be called between onCreate and onViewCreated.
A default View can be returned by calling Fragment in your constructor. Otherwise, this method returns null.
It is recommended to only inflate the layout in this method and move logic that operates on the returned View to onViewCreated.
If you return a View from here, you will later be called in onDestroyView when the view is being released.
| Parameters | |
|---|---|
inflater: LayoutInflater |
The LayoutInflater object that can be used to inflate any views in the fragment, |
container: ViewGroup? |
If non-null, this is the parent view that the fragment's UI should be attached to. The fragment should not add the view itself, but this can be used to generate the LayoutParams of the view. |
savedInstanceState: Bundle? |
If non-null, this fragment is being re-constructed from a previous saved state as given here. |
| Returns | |
|---|---|
View? |
Return the View for the fragment's UI, or null. |
onDestroyView
fun onDestroyView(): Unit
Called when the view previously created by onCreateView has been detached from the fragment. The next time the fragment needs to be displayed, a new view will be created. This is called after onStop and before onDestroy. It is called regardless of whether onCreateView returned a non-null view. Internally it is called after the view's state has been saved but before it has been removed from its parent.
onInflateTitleView
fun onInflateTitleView(
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 |
onStart
fun onStart(): Unit
Called when the Fragment is visible to the user. This is generally tied to Activity.onStart of the containing Activity's lifecycle.
onStop
fun onStop(): Unit
Called when the Fragment is no longer started. This is generally tied to Activity.onStop of the containing Activity's lifecycle.
setAdapter
fun setAdapter(adapter: ObjectAdapter!): Unit
Sets the list of rows for the fragment.
setOnItemViewClickedListener
fun setOnItemViewClickedListener(listener: BaseOnItemViewClickedListener!): Unit
Sets an item clicked listener.
setOnItemViewSelectedListener
fun setOnItemViewSelectedListener(listener: BaseOnItemViewSelectedListener!): Unit
Sets an item selection listener.
setSelectedPosition
fun setSelectedPosition(position: Int): Unit
Sets the selected row position with smooth animation.
setSelectedPosition
fun setSelectedPosition(position: Int, smooth: Boolean): Unit
Sets the selected row position.
Protected functions
createEntranceTransition
protected fun createEntranceTransition(): 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 fun onEntranceTransitionEnd(): Unit
Callback when entrance transition is ended.
onEntranceTransitionPrepare
protected fun onEntranceTransitionPrepare(): Unit
Callback when entrance transition is prepared. This is when fragment should stop user input and animations.
onEntranceTransitionStart
protected fun onEntranceTransitionStart(): Unit
Callback when entrance transition is started. This is when fragment should stop processing layout.
onSetDetailsOverviewRowStatus
protected fun onSetDetailsOverviewRowStatus(
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. |
onSetRowStatus
protected fun onSetRowStatus(
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 fun runEntranceTransition(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.
setupDetailsOverviewRowPresenter
protected fun setupDetailsOverviewRowPresenter(
presenter: FullWidthDetailsOverviewRowPresenter!
): Unit
Called to setup FullWidthDetailsOverviewRowPresenter. The default implementation adds two alignment positions(ItemAlignmentFacet) for ViewHolder of FullWidthDetailsOverviewRowPresenter to align in fragment.
setupPresenter
protected fun setupPresenter(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 DetailsSupportFragment. For example how a row is aligned in details Fragment. The default implementation invokes setupDetailsOverviewRowPresenter