RowsSupportFragment
class RowsSupportFragment : Fragment, 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 |
|---|
|
The adapter that RowsSupportFragment implements BrowseSupportFragment.MainFragmentRowsAdapter. |
Public constructors |
|---|
Public functions |
|
|---|---|
Unit |
This function is deprecated. use |
RowPresenter.ViewHolder! |
findRowViewHolderByPosition(position: Int)Find row ViewHolder by position in adapter. |
ObjectAdapter! |
Returns the Adapter that represents list of rows. |
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. |
PresenterSelector! |
Get the presenter selector used to create and bind views. |
RowPresenter.ViewHolder! |
getRowViewHolder(position: Int)Get row ViewHolder at adapter position. |
Int |
Gets position of currently selected row. |
VerticalGridView! |
|
Boolean |
|
View? |
onCreateView(Called to have the fragment instantiate its user interface view. |
Unit |
Called when the view previously created by |
Unit |
onSaveInstanceState(outState: Bundle!)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. |
Unit |
|
Boolean |
|
Unit |
|
Unit |
onViewCreated(view: View, savedInstanceState: Bundle?)Called immediately after |
Unit |
setAdapter(rowsAdapter: ObjectAdapter!)Sets the adapter that represents a list of rows. |
Unit |
setAlignment(windowAlignOffsetFromTop: Int) |
Unit |
setEntranceTransitionState(afterTransition: Boolean)For rows that willing to participate entrance transition, this function hide views if afterTransition is true, show views if afterTransition is false. |
Unit |
Set the visibility of titles/hovercard of browse rows. |
Unit |
Sets an item clicked listener on the fragment. |
Unit |
Sets an item selection listener. |
Unit |
setPresenterSelector(presenterSelector: PresenterSelector!)Set the presenter selector used to create and bind views. |
Unit |
setSelectedPosition(position: Int)Sets the selected row position with smooth animation. |
Unit |
setSelectedPosition(position: Int, smooth: Boolean)Sets the selected row position. |
Unit |
setSelectedPosition(Selects a Row and perform an optional task on the Row. |
Protected functions |
|
|---|---|
VerticalGridView! |
findGridViewFromRoot(view: View!) |
Inherited functions |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Public constructors
Public functions
findRowViewHolderByPosition
fun findRowViewHolderByPosition(position: Int): RowPresenter.ViewHolder!
Find row ViewHolder by position in adapter.
| Parameters | |
|---|---|
position: Int |
Position of row. |
| Returns | |
|---|---|
RowPresenter.ViewHolder! |
ViewHolder of Row. |
getAdapter
fun getAdapter(): ObjectAdapter!
Returns the Adapter that represents list of rows.
| Returns | |
|---|---|
ObjectAdapter! |
Adapter that represents list of rows. |
getBridgeAdapter
fun getBridgeAdapter(): ItemBridgeAdapter!
Returns the RecyclerView.Adapter that wraps getAdapter.
| Returns | |
|---|---|
ItemBridgeAdapter! |
The RecyclerView.Adapter that wraps |
getMainFragmentAdapter
fun getMainFragmentAdapter(): BrowseSupportFragment.MainFragmentAdapter!
Returns an instance of MainFragmentAdapter that BrowseSupportFragment would use to communicate with the target fragment.
getMainFragmentRowsAdapter
fun getMainFragmentRowsAdapter(): BrowseSupportFragment.MainFragmentRowsAdapter!
Returns an instance of MainFragmentRowsAdapter that BrowseSupportFragment would use to communicate with the target fragment.
getOnItemViewClickedListener
fun getOnItemViewClickedListener(): BaseOnItemViewClickedListener!
Returns the item clicked listener.
getOnItemViewSelectedListener
fun getOnItemViewSelectedListener(): BaseOnItemViewSelectedListener!
Returns an item selection listener.
getPresenterSelector
fun getPresenterSelector(): PresenterSelector!
Get the presenter selector used to create and bind views.
getRowViewHolder
fun getRowViewHolder(position: Int): RowPresenter.ViewHolder!
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 | |
|---|---|
position: Int |
Position of row in adapter. |
| Returns | |
|---|---|
RowPresenter.ViewHolder! |
Row ViewHolder at a given adapter position. |
getSelectedPosition
fun getSelectedPosition(): Int
Gets position of currently selected row.
| Returns | |
|---|---|
Int |
Position of currently selected row. |
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.
onSaveInstanceState
fun onSaveInstanceState(outState: Bundle!): Unit
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 | |
|---|---|
outState: Bundle! |
Bundle in which to place your saved state. |
onViewCreated
fun onViewCreated(view: View, savedInstanceState: Bundle?): Unit
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 | |
|---|---|
view: View |
The View returned by |
savedInstanceState: Bundle? |
If non-null, this fragment is being re-constructed from a previous saved state as given here. |
setAdapter
fun setAdapter(rowsAdapter: ObjectAdapter!): Unit
Sets the adapter that represents a list of rows.
| Parameters | |
|---|---|
rowsAdapter: ObjectAdapter! |
Adapter that represents list of rows. |
setEntranceTransitionState
fun setEntranceTransitionState(afterTransition: Boolean): Unit
For rows that willing to participate entrance transition, this function hide views if afterTransition is true, show views if afterTransition is false.
setExpand
fun setExpand(expand: Boolean): Unit
Set the visibility of titles/hovercard of browse rows.
setOnItemViewClickedListener
fun setOnItemViewClickedListener(listener: BaseOnItemViewClickedListener!): Unit
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
fun setOnItemViewSelectedListener(listener: BaseOnItemViewSelectedListener!): Unit
Sets an item selection listener.
setPresenterSelector
fun setPresenterSelector(presenterSelector: PresenterSelector!): Unit
Set the presenter selector used to create and bind views.
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.
setSelectedPosition
fun setSelectedPosition(
rowPosition: Int,
smooth: Boolean,
rowHolderTask: Presenter.ViewHolderTask!
): Unit
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 | |
|---|---|
rowPosition: Int |
Which row to select. |
smooth: Boolean |
True to scroll to the row, false for no animation. |
rowHolderTask: Presenter.ViewHolderTask! |
Task to perform on the Row. |
Protected functions
findGridViewFromRoot
protected fun findGridViewFromRoot(view: View!): VerticalGridView!