DetailsFragment
public class DetailsFragment extends BaseFragment
| java.lang.Object | ||||
| ↳ | 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 methods |
|
|---|---|
ObjectAdapter |
Returns the list of rows. |
BaseOnItemViewClickedListener |
Returns the item clicked listener. |
DetailsParallax |
Returns the |
RowsFragment |
Gets embedded RowsFragment showing multiple rows for DetailsFragment. |
void |
This method is deprecated. |
@Nullable View |
This method is deprecated. |
void |
This method is deprecated. |
@NonNull View |
Called by |
void |
This method is deprecated. |
void |
This method is deprecated. |
void |
Sets the list of rows for the fragment. |
void |
Sets an item clicked listener. |
void |
Sets an item selection listener. |
void |
Sets the selected row position with smooth animation. |
void |
Sets the selected row position. |
Protected methods |
|
|---|---|
Object |
Create entrance transition. |
View |
This method is deprecated. override |
void |
Callback when entrance transition is ended. |
void |
Callback when entrance transition is prepared. |
void |
Callback when entrance transition is started. |
void |
Called to change DetailsOverviewRow view status when current selected row position or selected sub position changed. |
void |
Called on every visible row to change view status when current selected row position or selected sub position changed. |
void |
Run entrance transition. |
void |
Called to setup |
void |
Called to setup each Presenter of Adapter passed in |
Inherited Constants |
||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Inherited methods |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Public constructors
Public methods
public BaseOnItemViewClickedListenergetOnItemViewClickedListener()
Returns the item clicked listener.
public DetailsParallaxgetParallax()
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. |
public RowsFragmentgetRowsFragment()
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. |
public @Nullable ViewonCreateView(
LayoutInflater inflater,
@Nullable ViewGroup container,
Bundle savedInstanceState
)
onInflateTitleView
public @NonNull ViewonInflateTitleView(
@NonNull LayoutInflater inflater,
@Nullable ViewGroup parent,
@Nullable Bundle savedInstanceState
)
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 | |
|---|---|
@NonNull LayoutInflater inflater |
The LayoutInflater object that can be used to inflate any views in the fragment, |
@Nullable ViewGroup parent |
Parent of title view. |
@Nullable Bundle savedInstanceState |
If non-null, this fragment is being re-constructed from a previous saved state as given here. |
| Returns | |
|---|---|
@NonNull View |
Title view which must have a descendant with id browse_title_group that implements |
public voidsetOnItemViewClickedListener(BaseOnItemViewClickedListener listener)
Sets an item clicked listener.
public voidsetOnItemViewSelectedListener(BaseOnItemViewSelectedListener listener)
Sets an item selection listener.
Protected methods
createEntranceTransition
protected ObjectcreateEntranceTransition()
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.
onEntranceTransitionEnd
protected void onEntranceTransitionEnd()Callback when entrance transition is ended.
onEntranceTransitionPrepare
protected void onEntranceTransitionPrepare()Callback when entrance transition is prepared. This is when fragment should stop user input and animations.
onEntranceTransitionStart
protected void onEntranceTransitionStart()Callback when entrance transition is started. This is when fragment should stop processing layout.
protected voidonSetDetailsOverviewRowStatus(
FullWidthDetailsOverviewRowPresenter presenter,
FullWidthDetailsOverviewRowPresenter.ViewHolder viewHolder,
int adapterPosition,
int selectedPosition,
int selectedSubPosition
)
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 | |
|---|---|
FullWidthDetailsOverviewRowPresenter presenter |
The presenter used to create row ViewHolder. |
FullWidthDetailsOverviewRowPresenter.ViewHolder viewHolder |
The visible (attached) row ViewHolder, note that it may or may not be selected. |
int adapterPosition |
The adapter position of viewHolder inside adapter. |
int selectedPosition |
The adapter position of currently selected row. |
int selectedSubPosition |
The sub position within currently selected row. This is used When a row has multiple alignment positions. |
protected voidonSetRowStatus(
RowPresenter presenter,
RowPresenter.ViewHolder viewHolder,
int adapterPosition,
int selectedPosition,
int selectedSubPosition
)
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 | |
|---|---|
RowPresenter presenter |
The presenter used to create row ViewHolder. |
RowPresenter.ViewHolder viewHolder |
The visible (attached) row ViewHolder, note that it may or may not be selected. |
int adapterPosition |
The adapter position of viewHolder inside adapter. |
int selectedPosition |
The adapter position of currently selected row. |
int selectedSubPosition |
The sub position within currently selected row. This is used When a row has multiple alignment positions. |
runEntranceTransition
protected voidrunEntranceTransition(Object entranceTransition)
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 voidsetupDetailsOverviewRowPresenter(
FullWidthDetailsOverviewRowPresenter presenter
)
Called to setup FullWidthDetailsOverviewRowPresenter. The default implementation adds two alignment positions(ItemAlignmentFacet) for ViewHolder of FullWidthDetailsOverviewRowPresenter to align in fragment.
protected voidsetupPresenter(Presenter rowPresenter)
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