RowsSupportFragment
public class RowsSupportFragment extends Fragment implements BrowseSupportFragment.MainFragmentRowsAdapterProvider, BrowseSupportFragment.MainFragmentAdapterProvider
An ordered set of rows of leanback widgets.
A RowsSupportFragment renders the elements of its androidx.leanback.widget.ObjectAdapter as a set of rows in a vertical list. The Adapter's PresenterSelector must maintain subclasses of RowPresenter.
Summary
Nested types |
|---|
public class RowsSupportFragment.MainFragmentAdapter extends BrowseSupportFragment.MainFragmentAdapter |
public class RowsSupportFragment.MainFragmentRowsAdapter extends BrowseSupportFragment.MainFragmentRowsAdapterThe adapter that RowsSupportFragment implements BrowseSupportFragment.MainFragmentRowsAdapter. |
Public constructors |
|---|
Public methods |
|
|---|---|
void |
This method is deprecated. use |
RowPresenter.ViewHolder |
findRowViewHolderByPosition(int position)Find row ViewHolder by position in adapter. |
final ObjectAdapter |
Returns the Adapter that represents list of rows. |
final ItemBridgeAdapter |
Returns the RecyclerView.Adapter that wraps |
BrowseSupportFragment.MainFragmentAdapter |
Returns an instance of |
BrowseSupportFragment.MainFragmentRowsAdapter |
Returns an instance of |
BaseOnItemViewClickedListener |
Returns the item clicked listener. |
BaseOnItemViewSelectedListener |
Returns an item selection listener. |
final PresenterSelector |
Get the presenter selector used to create and bind views. |
RowPresenter.ViewHolder |
getRowViewHolder(int position)Get row ViewHolder at adapter position. |
int |
Gets position of currently selected row. |
final VerticalGridView |
|
boolean |
|
@Nullable View |
onCreateView(Called to have the fragment instantiate its user interface view. |
void |
Called when the view previously created by |
void |
onSaveInstanceState(Bundle outState)Called to ask the fragment to save its current dynamic state, so it can later be reconstructed in a new instance if its process is restarted. |
void |
|
boolean |
|
void |
|
void |
onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState)Called immediately after |
final void |
setAdapter(ObjectAdapter rowsAdapter)Sets the adapter that represents a list of rows. |
void |
setAlignment(int windowAlignOffsetFromTop) |
void |
setEntranceTransitionState(boolean afterTransition)For rows that willing to participate entrance transition, this function hide views if afterTransition is true, show views if afterTransition is false. |
void |
setExpand(boolean expand)Set the visibility of titles/hovercard of browse rows. |
void |
Sets an item clicked listener on the fragment. |
void |
Sets an item selection listener. |
final void |
setPresenterSelector(PresenterSelector presenterSelector)Set the presenter selector used to create and bind views. |
void |
setSelectedPosition(int position)Sets the selected row position with smooth animation. |
void |
setSelectedPosition(int position, boolean smooth)Sets the selected row position. |
void |
setSelectedPosition(Selects a Row and perform an optional task on the Row. |
Protected methods |
|
|---|---|
VerticalGridView |
findGridViewFromRoot(View view) |
Inherited methods |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Public constructors
Public methods
findRowViewHolderByPosition
public RowPresenter.ViewHolder findRowViewHolderByPosition(int position)
Find row ViewHolder by position in adapter.
| Parameters | |
|---|---|
int position |
Position of row. |
| Returns | |
|---|---|
RowPresenter.ViewHolder |
ViewHolder of Row. |
getAdapter
public final ObjectAdapter getAdapter()
Returns the Adapter that represents list of rows.
| Returns | |
|---|---|
ObjectAdapter |
Adapter that represents list of rows. |
getBridgeAdapter
public final ItemBridgeAdapter getBridgeAdapter()
Returns the RecyclerView.Adapter that wraps getAdapter.
| Returns | |
|---|---|
ItemBridgeAdapter |
The RecyclerView.Adapter that wraps |
getMainFragmentAdapter
public BrowseSupportFragment.MainFragmentAdapter getMainFragmentAdapter()
Returns an instance of MainFragmentAdapter that BrowseSupportFragment would use to communicate with the target fragment.
getMainFragmentRowsAdapter
public BrowseSupportFragment.MainFragmentRowsAdapter getMainFragmentRowsAdapter()
Returns an instance of MainFragmentRowsAdapter that BrowseSupportFragment would use to communicate with the target fragment.
getOnItemViewClickedListener
public BaseOnItemViewClickedListener getOnItemViewClickedListener()
Returns the item clicked listener.
getOnItemViewSelectedListener
public BaseOnItemViewSelectedListener getOnItemViewSelectedListener()
Returns an item selection listener.
getPresenterSelector
public final PresenterSelector getPresenterSelector()
Get the presenter selector used to create and bind views.
getRowViewHolder
public RowPresenter.ViewHolder getRowViewHolder(int position)
Get row ViewHolder at adapter position. Returns null if the row object is not in adapter or the row object has not been bound to a row view.
| Parameters | |
|---|---|
int position |
Position of row in adapter. |
| Returns | |
|---|---|
RowPresenter.ViewHolder |
Row ViewHolder at a given adapter position. |
getSelectedPosition
public int getSelectedPosition()
Gets position of currently selected row.
| Returns | |
|---|---|
int |
Position of currently selected row. |
onCreateView
public @Nullable View onCreateView(
@NonNull LayoutInflater inflater,
@Nullable ViewGroup container,
@Nullable Bundle savedInstanceState
)
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 | |
|---|---|
@NonNull LayoutInflater inflater |
The LayoutInflater object that can be used to inflate any views in the fragment, |
@Nullable ViewGroup container |
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. |
@Nullable Bundle savedInstanceState |
If non-null, this fragment is being re-constructed from a previous saved state as given here. |
onDestroyView
public void onDestroyView()
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.
onSaveInstanceState
public void onSaveInstanceState(Bundle outState)
Called to ask the fragment to save its current dynamic state, so it can later be reconstructed in a new instance if its process is restarted. If a new instance of the fragment later needs to be created, the data you place in the Bundle here will be available in the Bundle given to onCreate, onCreateView, and onViewCreated.
This corresponds to Activity.onSaveInstanceState(Bundle) and most of the discussion there applies here as well. Note however: this method may be called at any time before onDestroy. There are many situations where a fragment may be mostly torn down (such as when placed on the back stack with no UI showing), but its state will not be saved until its owning activity actually needs to save its state.
| Parameters | |
|---|---|
Bundle outState |
Bundle in which to place your saved state. |
onViewCreated
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState)
Called immediately after onCreateView 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 | |
|---|---|
@NonNull View view |
The View returned by |
@Nullable Bundle savedInstanceState |
If non-null, this fragment is being re-constructed from a previous saved state as given here. |
setAdapter
public final void setAdapter(ObjectAdapter rowsAdapter)
Sets the adapter that represents a list of rows.
| Parameters | |
|---|---|
ObjectAdapter rowsAdapter |
Adapter that represents list of rows. |
setEntranceTransitionState
public void setEntranceTransitionState(boolean afterTransition)
For rows that willing to participate entrance transition, this function hide views if afterTransition is true, show views if afterTransition is false.
setExpand
public void setExpand(boolean expand)
Set the visibility of titles/hovercard of browse rows.
setOnItemViewClickedListener
public void setOnItemViewClickedListener(BaseOnItemViewClickedListener listener)
Sets an item clicked listener on the fragment. OnItemViewClickedListener will override View.OnClickListener that item presenter sets during onCreateViewHolder. So in general, developer should choose one of the listeners but not both.
setOnItemViewSelectedListener
public void setOnItemViewSelectedListener(BaseOnItemViewSelectedListener listener)
Sets an item selection listener.
setPresenterSelector
public final void setPresenterSelector(PresenterSelector presenterSelector)
Set the presenter selector used to create and bind views.
setSelectedPosition
public void setSelectedPosition(int position)
Sets the selected row position with smooth animation.
setSelectedPosition
public void setSelectedPosition(int position, boolean smooth)
Sets the selected row position.
setSelectedPosition
public void setSelectedPosition(
int rowPosition,
boolean smooth,
Presenter.ViewHolderTask rowHolderTask
)
Selects a Row and perform an optional task on the Row. For example setSelectedPosition(10, true, new ListRowPresenterSelectItemViewHolderTask(5)) Scroll to 11th row and selects 6th item on that row. The method will be ignored if RowsSupportFragment has not been created (i.e. before onCreateView).
| Parameters | |
|---|---|
int rowPosition |
Which row to select. |
boolean smooth |
True to scroll to the row, false for no animation. |
Presenter.ViewHolderTask rowHolderTask |
Task to perform on the Row. |