public
class
DetailsFragment
extends BrandedFragment
java.lang.Object | |||
↳ | android.app.Fragment | ||
↳ | android.support.v17.leanback.app.BrandedFragment | ||
↳ | android.support.v17.leanback.app.DetailsFragment |
Known Direct Subclasses |
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:
setupDetailsOverviewRowPresenter(FullWidthDetailsOverviewRowPresenter)
.
onSetDetailsOverviewRowStatus(FullWidthDetailsOverviewRowPresenter, FullWidthDetailsOverviewRowPresenter.ViewHolder, int, int, int)
.
The recommended activity themes to use with a DetailsFragment are
Theme_Leanback_Details
with activity
shared element transition for FullWidthDetailsOverviewRowPresenter
.
Theme_Leanback_Details_NoSharedElementTransition
if shared element transition is not needed, for example if first row is not rendered by
FullWidthDetailsOverviewRowPresenter
.
Inherited XML attributes | |
---|---|
From
class
android.app.Fragment
|
Inherited constants |
---|
From
interface
android.content.ComponentCallbacks2
|
Public constructors | |
---|---|
DetailsFragment()
|
Public methods | |
---|---|
ObjectAdapter
|
getAdapter()
Returns the list of rows. |
BaseOnItemViewClickedListener
|
getOnItemViewClickedListener()
Returns the item clicked listener. |
final
ProgressBarManager
|
getProgressBarManager()
Returns the |
RowsFragment
|
getRowsFragment()
Gets embedded RowsFragment showing multiple rows for DetailsFragment. |
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. |
View
|
onInflateTitleView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState)
Called by |
void
|
onStart()
Called when the Fragment is visible to the user. |
void
|
onViewCreated(View view, Bundle savedInstanceState)
Called immediately after |
void
|
prepareEntranceTransition()
Enables entrance transition. |
void
|
setAdapter(ObjectAdapter adapter)
Sets the list of rows for the fragment. |
void
|
setOnItemViewClickedListener(BaseOnItemViewClickedListener listener)
Sets an item clicked listener. |
void
|
setOnItemViewSelectedListener(BaseOnItemViewSelectedListener listener)
Sets an item selection listener. |
void
|
setSelectedPosition(int position)
Sets the selected row position with smooth animation. |
void
|
setSelectedPosition(int position, boolean smooth)
Sets the selected row position. |
void
|
startEntranceTransition()
When fragment finishes loading data, it should call startEntranceTransition() to execute the entrance transition. |
Protected methods | |
---|---|
Object
|
createEntranceTransition()
Create entrance transition. |
View
|
inflateTitle(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState)
This method is deprecated.
override |
void
|
onEntranceTransitionEnd()
Callback when entrance transition is ended. |
void
|
onEntranceTransitionPrepare()
Callback when entrance transition is prepared. |
void
|
onEntranceTransitionStart()
Callback when entrance transition is started. |
void
|
onSetDetailsOverviewRowStatus(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. |
void
|
onSetRowStatus(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. |
void
|
runEntranceTransition(Object entranceTransition)
Run entrance transition. |
void
|
setupDetailsOverviewRowPresenter(FullWidthDetailsOverviewRowPresenter presenter)
Called to setup |
void
|
setupPresenter(Presenter rowPresenter)
Called to setup each Presenter of Adapter passed in |
Inherited methods | |
---|---|
From
class
android.support.v17.leanback.app.BrandedFragment
| |
From
class
android.app.Fragment
| |
From
class
java.lang.Object
| |
From
interface
android.content.ComponentCallbacks2
| |
From
interface
android.view.View.OnCreateContextMenuListener
| |
From
interface
android.content.ComponentCallbacks
|
DetailsFragment ()
BaseOnItemViewClickedListener getOnItemViewClickedListener ()
Returns the item clicked listener.
Returns | |
---|---|
BaseOnItemViewClickedListener |
ProgressBarManager getProgressBarManager ()
Returns the ProgressBarManager
.
Returns | |
---|---|
ProgressBarManager |
RowsFragment getRowsFragment ()
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. |
void onCreate (Bundle savedInstanceState)
Called to do initial creation of a fragment. This is called after
onAttach(Activity)
and before
onCreateView(LayoutInflater, ViewGroup, Bundle)
, but is not called if the fragment
instance is retained across Activity re-creation (see setRetainInstance(boolean)
).
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, see onActivityCreated(Bundle)
.
If your app's targetSdkVersion
is 23 or lower, child fragments
being restored from the savedInstanceState are restored after onCreate
returns. When targeting N or above and running on an N or newer platform version
they are restored by Fragment.onCreate
.
Parameters | |
---|---|
savedInstanceState |
Bundle :
If the fragment is being re-created from
a previous saved state, this is the state.
|
View onCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
Called to have the fragment instantiate its user interface view.
This is optional, and non-graphical fragments can return null (which
is the default implementation). This will be called between
onCreate(Bundle)
and onActivityCreated(Bundle)
.
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. |
View onInflateTitleView (LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState)
Called by installTitleView(LayoutInflater, ViewGroup, Bundle)
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
TitleViewAdapter.Provider , or null for no title view.
|
void onStart ()
Called when the Fragment is visible to the user. This is generally
tied to Activity.onStart
of the containing
Activity's lifecycle.
void onViewCreated (View view, Bundle savedInstanceState)
Called immediately after onCreateView(LayoutInflater, ViewGroup, Bundle)
has returned, but before any saved state has been restored in to the view.
This gives subclasses a chance to initialize themselves once
they know their view hierarchy has been completely created. The fragment's
view hierarchy is not however attached to its parent at this point.
Parameters | |
---|---|
view |
View :
The View returned by onCreateView(LayoutInflater, ViewGroup, Bundle) . |
savedInstanceState |
Bundle :
If non-null, this fragment is being re-constructed
from a previous saved state as given here.
|
void prepareEntranceTransition ()
Enables entrance transition.
Entrance transition is the standard slide-in transition that shows rows of data in browse screen and details screen.
The method is ignored before LOLLIPOP (API21).
This method must be called in or
before onCreate(). Typically entrance transition should be enabled when savedInstance is
null so that fragment restored from instanceState does not run an extra entrance transition.
When the entrance transition is enabled, the fragment will make headers and content
hidden initially.
When data of rows are ready, app must call startEntranceTransition()
to kick off
the transition, otherwise the rows will be invisible forever.
It is similar to android:windowsEnterTransition and can be considered a late-executed android:windowsEnterTransition controlled by app. There are two reasons that app needs it:
Transition object is returned by createEntranceTransition(). Typically the app does not need override the default transition that browse and details provides.
void setAdapter (ObjectAdapter adapter)
Sets the list of rows for the fragment.
Parameters | |
---|---|
adapter |
ObjectAdapter
|
void setOnItemViewClickedListener (BaseOnItemViewClickedListener listener)
Sets an item clicked listener.
Parameters | |
---|---|
listener |
BaseOnItemViewClickedListener
|
void setOnItemViewSelectedListener (BaseOnItemViewSelectedListener listener)
Sets an item selection listener.
Parameters | |
---|---|
listener |
BaseOnItemViewSelectedListener
|
void setSelectedPosition (int position)
Sets the selected row position with smooth animation.
Parameters | |
---|---|
position |
int
|
void setSelectedPosition (int position, boolean smooth)
Sets the selected row position.
Parameters | |
---|---|
position |
int
|
smooth |
boolean
|
void startEntranceTransition ()
When fragment finishes loading data, it should call startEntranceTransition() to execute the entrance transition. startEntranceTransition() will start transition only if both two conditions are satisfied:
If startEntranceTransition() is called before onViewCreated(), it will be pending and executed when view is created.
Object createEntranceTransition ()
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.
Returns | |
---|---|
Object |
View inflateTitle (LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState)
This method is deprecated.
override onInflateTitleView(LayoutInflater, ViewGroup, Bundle)
instead.
Parameters | |
---|---|
inflater |
LayoutInflater
|
parent |
ViewGroup
|
savedInstanceState |
Bundle
|
Returns | |
---|---|
View |
void onEntranceTransitionEnd ()
Callback when entrance transition is ended.
void onEntranceTransitionPrepare ()
Callback when entrance transition is prepared. This is when fragment should stop user input and animations.
void onEntranceTransitionStart ()
Callback when entrance transition is started. This is when fragment should stop processing layout.
void onSetDetailsOverviewRowStatus (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 | |
---|---|
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.
|
void onSetRowStatus (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(FullWidthDetailsOverviewRowPresenter, FullWidthDetailsOverviewRowPresenter.ViewHolder, int, int, int)
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.
|
void runEntranceTransition (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.
Parameters | |
---|---|
entranceTransition |
Object
|
void setupDetailsOverviewRowPresenter (FullWidthDetailsOverviewRowPresenter presenter)
Called to setup FullWidthDetailsOverviewRowPresenter
. The default implementation
adds two aligment positions(ItemAlignmentFacet
) for ViewHolder of
FullWidthDetailsOverviewRowPresenter to align in fragment.
Parameters | |
---|---|
presenter |
FullWidthDetailsOverviewRowPresenter
|
void setupPresenter (Presenter rowPresenter)
Called to setup each Presenter of Adapter passed in setAdapter(ObjectAdapter)
. 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(FullWidthDetailsOverviewRowPresenter)
Parameters | |
---|---|
rowPresenter |
Presenter
|