BrowseSupportFragment

class BrowseSupportFragment : BaseSupportFragment


A fragment for creating Leanback browse screens. It is composed of a RowsSupportFragment and a HeadersSupportFragment.

A BrowseSupportFragment renders the elements of its ObjectAdapter as a set of rows in a vertical list. The elements in this adapter must be subclasses of Row.

The HeadersSupportFragment can be set to be either shown or hidden by default, or may be disabled entirely. See setHeadersState for details.

By default the BrowseSupportFragment includes support for returning to the headers when the user presses Back. For Activities that customize onBackPressed, you must disable this default Back key support by calling setHeadersTransitionOnBackEnabled with false and use BrowseSupportFragment.BrowseTransitionListener and startHeadersTransition.

The recommended theme to use with a BrowseSupportFragment is Theme_Leanback_Browse.

Summary

Nested types

Listener for transitions between browse headers and rows.

Factory class responsible for creating fragment given the current item.

Possible set of actions that BrowseSupportFragment exposes to clients.

FragmentFactory implementation for ListRow.

Interface that defines the interaction between BrowseSupportFragment and its main content fragment.

Interface to be implemented by all fragments for providing an instance of MainFragmentAdapter.

Registry class maintaining the mapping of Row subclasses to FragmentFactory.

This is used to pass information to RowsSupportFragment or its subclasses.

Interface to be implemented by RowsSupportFragment and its subclasses for providing an instance of MainFragmentRowsAdapter.

Constants

const Int

The headers fragment is disabled and will never be shown.

const Int

The headers fragment is enabled and shown by default.

const Int

The headers fragment is enabled and hidden by default.

Public constructors

Public functions

java-static Bundle!
createArgs(args: Bundle!, title: String!, headersState: Int)

Creates arguments for a browse fragment.

Unit

Enables scaling of main fragment when headers are present.

Unit

This function is deprecated.

use enableMainFragmentScaling instead.

ObjectAdapter!

Returns the adapter containing the rows for the fragment.

@ColorInt Int

Returns the brand color for the browse fragment.

Int

Returns the state of the headers column in the browse fragment.

HeadersSupportFragment!

Get currently bound HeadersSupportFragment or null if HeadersSupportFragment has not been created yet.

Fragment!
BrowseSupportFragment.MainFragmentAdapterRegistry!
OnItemViewClickedListener!

Returns the item Clicked listener.

OnItemViewSelectedListener!

Returns an item selection listener.

RowsSupportFragment!

Get RowsSupportFragment if it's bound to BrowseSupportFragment or null if either BrowseSupportFragment has not been created yet or a different fragment is bound to it.

Int

Gets position of currently selected row.

RowPresenter.ViewHolder!
Boolean

Returns true if headers transition on back key support is enabled.

Boolean

Returns true if the headers transition is currently running.

Boolean

Returns true if headers are shown.

Unit
onCreate(savedInstanceState: Bundle!)

Called to do initial creation of a fragment.

HeadersSupportFragment!

Creates a new HeadersSupportFragment instance.

View?
onCreateView(
    inflater: LayoutInflater,
    container: ViewGroup?,
    savedInstanceState: Bundle?
)

Called to have the fragment instantiate its user interface view.

Unit

Called when the fragment is no longer in use.

Unit

Called when the view previously created by onCreateView has been detached from the fragment.

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.

Unit

Called when the Fragment is visible to the user.

Unit

Called when the Fragment is no longer started.

Unit

Sets the adapter containing the rows for the fragment.

Unit

Sets the brand color for the browse fragment.

Unit

Sets a listener for browse fragment transitions.

Unit
setHeaderPresenterSelector(headerPresenterSelector: PresenterSelector!)

Sets the PresenterSelector used to render the row headers.

Unit
setHeadersState(headersState: Int)

Sets the state for the headers column in the browse fragment.

Unit
setHeadersTransitionOnBackEnabled(headersBackStackEnabled: Boolean)

Enables/disables headers transition on back key support.

Unit

Sets an item clicked listener on the fragment.

Unit

Sets an item selection listener.

Unit

Sets the selected row position with smooth animation.

Unit
setSelectedPosition(position: Int, smooth: Boolean)

Sets the selected row position.

Unit
setSelectedPosition(
    rowPosition: Int,
    smooth: Boolean,
    rowHolderTask: Presenter.ViewHolderTask!
)

Selects a Row and perform an optional task on the Row.

Unit

Starts a headers transition.

Protected functions

Any!

Create entrance transition.

Unit

Callback when entrance transition is ended.

Unit

Callback when entrance transition is prepared.

Unit

Callback when entrance transition is started.

Unit
runEntranceTransition(entranceTransition: Any!)

Run entrance transition.

Inherited functions

From androidx.activity.result.ActivityResultCaller
abstract ActivityResultLauncher<I!>!
<I, O> registerForActivityResult(
    contract: ActivityResultContract<I!, O!>!,
    callback: ActivityResultCallback<O!>!
)

Register a request to start an activity for result, designated by the given contract.

From androidx.leanback.app.BaseSupportFragment
ProgressBarManager!

Returns the ProgressBarManager.

Unit
onViewCreated(view: View, savedInstanceState: Bundle?)

Called immediately after onCreateView has returned, but before any saved state has been restored in to the view.

Unit

Enables entrance transition.

Unit

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:

From androidx.leanback.app.BrandedSupportFragment
Drawable?

Returns the badge drawable used in the fragment title.

Int

Returns the color used to draw the search affordance.

SearchOrbView.Colors?

Returns the androidx.leanback.widget.SearchOrbView.Colors used to draw the search affordance.

CharSequence?

Returns the title text for the fragment.

View?

Returns the view that implements TitleViewAdapter.Provider.

TitleViewAdapter?

Returns the TitleViewAdapter implemented by title view.

Unit
installTitleView(
    inflater: LayoutInflater,
    parent: ViewGroup,
    savedInstanceState: Bundle?
)

Inflate title view and add to parent.

Boolean

Returns true/false to indicate the visibility of TitleView.

View
onInflateTitleView(
    inflater: LayoutInflater,
    parent: ViewGroup?,
    savedInstanceState: Bundle?
)

Called by installTitleView to inflate title view.

Unit

Called when the Fragment is no longer resumed.

Unit

Called when the fragment is visible to the user and actively running.

Unit

Sets the drawable displayed in the fragment title.

Unit

Sets a click listener for the search affordance.

Unit

Sets the color used to draw the search affordance.

Unit

Sets the androidx.leanback.widget.SearchOrbView.Colors used to draw the search affordance.

Unit

Sets title text for the fragment.

Unit
setTitleView(titleView: View?)

Sets the view that implemented TitleViewAdapter.

Unit
showTitle(flags: Int)

Changes title view's components visibility and shows title.

Unit

Shows or hides the title view.

From android.content.ComponentCallbacks
From androidx.fragment.app.Fragment
Unit
dump(
    prefix: String,
    fd: FileDescriptor?,
    writer: PrintWriter,
    args: Array<String!>?
)

Print the Fragments's state into the given stream.

Boolean
equals(o: Any?)

Subclasses can not override equals().

FragmentActivity?

Return the FragmentActivity this fragment is currently associated with.

Boolean

Returns whether the the exit transition and enter transition overlap or not.

Boolean

Returns whether the the return transition and reenter transition overlap or not.

Bundle?

Return the arguments supplied when the fragment was instantiated, if any.

FragmentManager

Return a private FragmentManager for placing and managing Fragments inside of this Fragment.

Context?

Return the Context this fragment is currently associated with.

CreationExtras

Returns the default CreationExtras that should be passed into ViewModelProvider.Factory.create when no overriding CreationExtras were passed to the ViewModelProvider constructors.

ViewModelProvider.Factory

Returns the default ViewModelProvider.Factory that should be used when no custom Factory is provided to the ViewModelProvider constructors.

Any?

Returns the Transition that will be used to move Views into the initial scene.

Any?

Returns the Transition that will be used to move Views out of the scene when the fragment is removed, hidden, or detached when not popping the back stack.

FragmentManager?

This function is deprecated.

This has been removed in favor of getParentFragmentManager() which throws an IllegalStateException if the FragmentManager is null.

Any?

Return the host object of this fragment.

Int

Return the identifier this fragment is known by.

LayoutInflater

Returns the cached LayoutInflater used to inflate Views of this Fragment.

Lifecycle

Returns the Lifecycle of the provider.

LoaderManager

This function is deprecated.

Use LoaderManager.getInstance(this).

Fragment?

Returns the parent Fragment containing this Fragment.

FragmentManager

Return the FragmentManager for interacting with fragments associated with this fragment's activity.

Any?

Returns the Transition that will be used to move Views in to the scene when returning due to popping a back stack.

Resources

Return requireActivity().getResources().

Boolean

This function is deprecated.

Instead of retaining the Fragment itself, use a non-retained Fragment and keep retained state in a ViewModel attached to that Fragment.

Any?

Returns the Transition that will be used to move Views out of the scene when the Fragment is preparing to be removed, hidden, or detached because of popping the back stack.

SavedStateRegistry

The SavedStateRegistry owned by this SavedStateRegistryOwner

Any?

Returns the Transition that will be used for shared elements transferred into the content Scene.

Any?

Return the Transition that will be used for shared elements transferred back during a pop of the back stack.

String

Return a localized string from the application's package's default string table.

String
getString(resId: @StringRes Int, formatArgs: Array<Any!>?)

Return a localized formatted string from the application's package's default string table, substituting the format arguments as defined in java.util.Formatter and format.

String?

Get the tag name of the fragment, if specified.

Fragment?

This function is deprecated.

Instead of using a target fragment to pass results, use setFragmentResult to deliver results to FragmentResultListener instances registered by other fragments via setFragmentResultListener.

Int

This function is deprecated.

When using the target fragment replacement of setFragmentResultListener and setFragmentResult, consider using setArguments to pass a requestKey if you need to support dynamic request keys.

CharSequence

Return a localized, styled CharSequence from the application's package's default string table.

Boolean

This function is deprecated.

Use setMaxLifecycle instead.

View?

Get the root view for the fragment's layout (the one returned by onCreateView), if provided.

LifecycleOwner

Get a LifecycleOwner that represents the Fragment's View lifecycle.

LiveData<LifecycleOwner!>

Retrieve a LiveData which allows you to observe the lifecycle of the Fragment's View.

ViewModelStore

Returns the ViewModelStore associated with this Fragment

Int

Subclasses can not override hashCode().

java-static Fragment
instantiate(context: Context, fname: String)

This function is deprecated.

Use getFragmentFactory and instantiate

java-static Fragment
instantiate(context: Context, fname: String, args: Bundle?)

This function is deprecated.

Use getFragmentFactory and instantiate, manually calling setArguments on the returned Fragment.

Boolean

Return true if the fragment is currently added to its activity.

Boolean

Return true if the fragment has been explicitly detached from the UI.

Boolean

Return true if the fragment has been hidden.

Boolean

Return true if the layout is included as part of an activity view hierarchy via the tag.

Boolean

Return true if this fragment is currently being removed from its activity.

Boolean

Return true if the fragment is in the resumed state.

Boolean

Returns true if this fragment is added and its state has already been saved by its host.

Boolean

Return true if the fragment is currently visible to the user.

Unit

This function is deprecated.

use onViewCreated for code touching the view created by onCreateView and onCreate for other initialization.

Unit
onActivityResult(requestCode: Int, resultCode: Int, data: Intent?)

This function is deprecated.

This method has been deprecated in favor of using the Activity Result API which brings increased type safety via an ActivityResultContract and the prebuilt contracts for common intents available in androidx.activity.result.contract.ActivityResultContracts, provides hooks for testing, and allow receiving results in separate, testable classes independent from your fragment.

Unit

This function is deprecated.

See onAttach.

Unit

Called when a fragment is first attached to its context.

Unit

This function is deprecated.

The responsibility for listening for fragments being attached has been moved to FragmentManager.

Unit
Boolean

This hook is called whenever an item in a context menu is selected.

Unit
@MainThread
@CallSuper
onCreate(savedInstanceState: Bundle?)

Called to do initial creation of a fragment.

Animation?
@MainThread
onCreateAnimation(transit: Int, enter: Boolean, nextAnim: Int)

Called when a fragment loads an animation.

Animator?
@MainThread
onCreateAnimator(transit: Int, enter: Boolean, nextAnim: Int)

Called when a fragment loads an animator.

Unit
@MainThread
onCreateContextMenu(
    menu: ContextMenu,
    v: View,
    menuInfo: ContextMenu.ContextMenuInfo?
)

Called when a context menu for the view is about to be shown.

Unit

This function is deprecated.

androidx.activity.ComponentActivity now implements MenuHost, an interface that allows any component, including your activity itself, to add menu items by calling addMenuProvider without forcing all components through this single method override.

Unit

This function is deprecated.

androidx.activity.ComponentActivity now implements MenuHost, an interface that allows any component, including your activity itself, to add menu items by calling addMenuProvider without forcing all components through this single method override.

Unit

Called when the fragment is no longer attached to its activity.

LayoutInflater
onGetLayoutInflater(savedInstanceState: Bundle?)

Returns the LayoutInflater used to inflate Views of this Fragment.

Unit

Called when the hidden state (as returned by isHidden of the fragment or another fragment in its hierarchy has changed.

Unit
@UiThread
@CallSuper
onInflate(
    activity: Activity,
    attrs: AttributeSet,
    savedInstanceState: Bundle?
)

This function is deprecated.

See onInflate.

Unit
@UiThread
@CallSuper
onInflate(
    context: Context,
    attrs: AttributeSet,
    savedInstanceState: Bundle?
)

Called when a fragment is being created as part of a view layout inflation, typically from setting the content view of an activity.

Unit
Unit
onMultiWindowModeChanged(isInMultiWindowMode: Boolean)

Called when the Fragment's activity changes from fullscreen mode to multi-window mode and visa-versa.

Boolean

This function is deprecated.

androidx.activity.ComponentActivity now implements MenuHost, an interface that allows any component, including your activity itself, to add menu items by calling addMenuProvider without forcing all components through this single method override.

Unit

This function is deprecated.

androidx.activity.ComponentActivity now implements MenuHost, an interface that allows any component, including your activity itself, to add menu items by calling addMenuProvider without forcing all components through this single method override.

Unit
onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean)

Called by the system when the activity changes to and from picture-in-picture mode.

Unit

This function is deprecated.

androidx.activity.ComponentActivity now implements MenuHost, an interface that allows any component, including your activity itself, to add menu items by calling addMenuProvider without forcing all components through this single method override.

Unit
@MainThread
onPrimaryNavigationFragmentChanged(
    isPrimaryNavigationFragment: Boolean
)

Callback for when the primary navigation state of this Fragment has changed.

Unit
onRequestPermissionsResult(
    requestCode: Int,
    permissions: Array<String!>,
    grantResults: IntArray
)

This function is deprecated.

This method has been deprecated in favor of using the Activity Result API which brings increased type safety via an ActivityResultContract and the prebuilt contracts for common intents available in androidx.activity.result.contract.ActivityResultContracts, provides hooks for testing, and allow receiving results in separate, testable classes independent from your fragment.

Unit

Called when all saved state has been restored into the view hierarchy of the fragment.

Unit

Postpone the entering Fragment transition until startPostponedEnterTransition or executePendingTransactions has been called.

Unit
postponeEnterTransition(duration: Long, timeUnit: TimeUnit)

Postpone the entering Fragment transition for a given amount of time and then call startPostponedEnterTransition.

ActivityResultLauncher<I!>
@MainThread
<I, O> registerForActivityResult(
    contract: ActivityResultContract<I!, O!>,
    callback: ActivityResultCallback<O!>
)

Register a request to start an activity for result, designated by the given contract.

ActivityResultLauncher<I!>
@MainThread
<I, O> registerForActivityResult(
    contract: ActivityResultContract<I!, O!>,
    registry: ActivityResultRegistry,
    callback: ActivityResultCallback<O!>
)

Register a request to start an activity for result, designated by the given contract.

Unit

Registers a context menu to be shown for the given view (multiple views can show the context menu).

Unit
requestPermissions(permissions: Array<String!>, requestCode: Int)

This function is deprecated.

This method has been deprecated in favor of using the Activity Result API which brings increased type safety via an ActivityResultContract and the prebuilt contracts for common intents available in androidx.activity.result.contract.ActivityResultContracts, provides hooks for testing, and allow receiving results in separate, testable classes independent from your fragment.

FragmentActivity

Return the FragmentActivity this fragment is currently associated with.

Bundle

Return the arguments supplied when the fragment was instantiated.

Context

Return the Context this fragment is currently associated with.

FragmentManager

This function is deprecated.

This has been renamed to getParentFragmentManager() to make it clear that you are accessing the FragmentManager that contains this Fragment and not the FragmentManager associated with child Fragments.

Any

Return the host object of this fragment.

Fragment

Returns the parent Fragment containing this Fragment.

View

Get the root view for the fragment's layout (the one returned by onCreateView).

Unit

Sets whether the the exit transition and enter transition overlap or not.

Unit

Sets whether the the return transition and reenter transition overlap or not.

Unit

Supply the construction arguments for this fragment.

Unit

When custom transitions are used with Fragments, the enter transition callback is called when this Fragment is attached or detached when not popping the back stack.

Unit
setEnterTransition(transition: Any?)

Sets the Transition that will be used to move Views into the initial scene.

Unit

When custom transitions are used with Fragments, the exit transition callback is called when this Fragment is attached or detached when popping the back stack.

Unit
setExitTransition(transition: Any?)

Sets the Transition that will be used to move Views out of the scene when the fragment is removed, hidden, or detached when not popping the back stack.

Unit

This function is deprecated.

This method is no longer needed when using a MenuProvider to provide a Menu to your activity, which replaces onCreateOptionsMenu as the recommended way to provide a consistent, optionally Lifecycle-aware, and modular way to handle menu creation and item selection.

Unit

Set the initial saved state that this Fragment should restore itself from when first being constructed, as returned by FragmentManager.saveFragmentInstanceState.

Unit
setMenuVisibility(menuVisible: Boolean)

Set a hint for whether this fragment's menu should be visible.

Unit
setReenterTransition(transition: Any?)

Sets the Transition that will be used to move Views in to the scene when returning due to popping a back stack.

Unit

This function is deprecated.

Instead of retaining the Fragment itself, use a non-retained Fragment and keep retained state in a ViewModel attached to that Fragment.

Unit
setReturnTransition(transition: Any?)

Sets the Transition that will be used to move Views out of the scene when the Fragment is preparing to be removed, hidden, or detached because of popping the back stack.

Unit

Sets the Transition that will be used for shared elements transferred into the content Scene.

Unit

Sets the Transition that will be used for shared elements transferred back during a pop of the back stack.

Unit
setTargetFragment(fragment: Fragment?, requestCode: Int)

This function is deprecated.

Instead of using a target fragment to pass results, the fragment requesting a result should use setFragmentResultListener to register a FragmentResultListener with a requestKey using its parent fragment manager.

Unit
setUserVisibleHint(isVisibleToUser: Boolean)

This function is deprecated.

If you are manually calling this method, use setMaxLifecycle instead.

Boolean

Gets whether you should show UI with rationale before requesting a permission.

Unit

Call startActivity from the fragment's containing Activity.

Unit
startActivity(intent: Intent, options: Bundle?)

Call startActivity from the fragment's containing Activity.

Unit
startActivityForResult(intent: Intent, requestCode: Int)

This function is deprecated.

This method has been deprecated in favor of using the Activity Result API which brings increased type safety via an ActivityResultContract and the prebuilt contracts for common intents available in androidx.activity.result.contract.ActivityResultContracts, provides hooks for testing, and allow receiving results in separate, testable classes independent from your fragment.

Unit
startActivityForResult(intent: Intent, requestCode: Int, options: Bundle?)

This function is deprecated.

This method has been deprecated in favor of using the Activity Result API which brings increased type safety via an ActivityResultContract and the prebuilt contracts for common intents available in androidx.activity.result.contract.ActivityResultContracts, provides hooks for testing, and allow receiving results in separate, testable classes independent from your fragment.

Unit
startIntentSenderForResult(
    intent: IntentSender,
    requestCode: Int,
    fillInIntent: Intent?,
    flagsMask: Int,
    flagsValues: Int,
    extraFlags: Int,
    options: Bundle?
)

This function is deprecated.

This method has been deprecated in favor of using the Activity Result API which brings increased type safety via an ActivityResultContract and the prebuilt contracts for common intents available in androidx.activity.result.contract.ActivityResultContracts, provides hooks for testing, and allow receiving results in separate, testable classes independent from your fragment.

Unit

Begin postponed transitions after postponeEnterTransition was called.

String
Unit

Prevents a context menu to be shown for the given view.

From androidx.lifecycle.HasDefaultViewModelProviderFactory
CreationExtras!

Returns the default CreationExtras that should be passed into ViewModelProvider.Factory.create when no overriding CreationExtras were passed to the ViewModelProvider constructors.

abstract ViewModelProvider.Factory!

Returns the default ViewModelProvider.Factory that should be used when no custom Factory is provided to the ViewModelProvider constructors.

From androidx.lifecycle.LifecycleOwner
abstract Lifecycle!

Returns the Lifecycle of the provider.

From androidx.savedstate.SavedStateRegistryOwner
abstract SavedStateRegistry!

The SavedStateRegistry owned by this SavedStateRegistryOwner

From android.view.View.OnCreateContextMenuListener
abstract Unit
onCreateContextMenu(
    p: ContextMenu!,
    p1: View!,
    p2: ContextMenu.ContextMenuInfo!
)
From androidx.lifecycle.ViewModelStoreOwner

Constants

HEADERS_DISABLED

Added in 1.1.0
const val HEADERS_DISABLED = 3: Int

The headers fragment is disabled and will never be shown.

HEADERS_ENABLED

Added in 1.1.0
const val HEADERS_ENABLED = 1: Int

The headers fragment is enabled and shown by default.

HEADERS_HIDDEN

Added in 1.1.0
const val HEADERS_HIDDEN = 2: Int

The headers fragment is enabled and hidden by default.

Public constructors

BrowseSupportFragment

Added in 1.1.0
BrowseSupportFragment()

Public functions

createArgs

Added in 1.1.0
java-static fun createArgs(args: Bundle!, title: String!, headersState: Int): Bundle!

Creates arguments for a browse fragment.

Parameters
args: Bundle!

The Bundle to place arguments into, or null if the method should return a new Bundle.

title: String!

The title of the BrowseSupportFragment.

headersState: Int

The initial state of the headers of the BrowseSupportFragment. Must be one of HEADERS_ENABLED, HEADERS_HIDDEN, or HEADERS_DISABLED.

Returns
Bundle!

A Bundle with the given arguments for creating a BrowseSupportFragment.

enableMainFragmentScaling

Added in 1.1.0
fun enableMainFragmentScaling(enable: Boolean): Unit

Enables scaling of main fragment when headers are present. For the page/row fragment, scaling is enabled only when both this method and isScalingEnabled are enabled.

Parameters
enable: Boolean

true to enable row scaling

enableRowScaling

Added in 1.1.0
Deprecated in 1.1.0
fun enableRowScaling(enable: Boolean): Unit
Parameters
enable: Boolean

true to enable row scaling

getAdapter

Added in 1.1.0
fun getAdapter(): ObjectAdapter!

Returns the adapter containing the rows for the fragment.

getBrandColor

Added in 1.1.0
fun getBrandColor(): @ColorInt Int

Returns the brand color for the browse fragment. The default is transparent.

getHeadersState

Added in 1.1.0
fun getHeadersState(): Int

Returns the state of the headers column in the browse fragment.

getHeadersSupportFragment

Added in 1.1.0
fun getHeadersSupportFragment(): HeadersSupportFragment!

Get currently bound HeadersSupportFragment or null if HeadersSupportFragment has not been created yet.

Returns
HeadersSupportFragment!

Currently bound HeadersSupportFragment or null if HeadersSupportFragment has not been created yet.

getMainFragment

Added in 1.1.0
fun getMainFragment(): Fragment!
Returns
Fragment!

Current main fragment or null if not created.

getOnItemViewClickedListener

Added in 1.1.0
fun getOnItemViewClickedListener(): OnItemViewClickedListener!

Returns the item Clicked listener.

getOnItemViewSelectedListener

Added in 1.1.0
fun getOnItemViewSelectedListener(): OnItemViewSelectedListener!

Returns an item selection listener.

getRowsSupportFragment

Added in 1.1.0
fun getRowsSupportFragment(): RowsSupportFragment!

Get RowsSupportFragment if it's bound to BrowseSupportFragment or null if either BrowseSupportFragment has not been created yet or a different fragment is bound to it.

Returns
RowsSupportFragment!

RowsSupportFragment if it's bound to BrowseSupportFragment or null otherwise.

getSelectedPosition

Added in 1.1.0
fun getSelectedPosition(): Int

Gets position of currently selected row.

Returns
Int

Position of currently selected row.

getSelectedRowViewHolder

Added in 1.1.0
fun getSelectedRowViewHolder(): RowPresenter.ViewHolder!
Returns
RowPresenter.ViewHolder!

selected row ViewHolder inside fragment created by MainFragmentRowsAdapter.

isHeadersTransitionOnBackEnabled

Added in 1.1.0
fun isHeadersTransitionOnBackEnabled(): Boolean

Returns true if headers transition on back key support is enabled.

isInHeadersTransition

Added in 1.1.0
fun isInHeadersTransition(): Boolean

Returns true if the headers transition is currently running.

isShowingHeaders

Added in 1.1.0
fun isShowingHeaders(): Boolean

Returns true if headers are shown.

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.

onCreateHeadersSupportFragment

Added in 1.1.0
fun onCreateHeadersSupportFragment(): HeadersSupportFragment!

Creates a new HeadersSupportFragment instance. Subclass of BrowseSupportFragment may override and return an instance of subclass of HeadersSupportFragment, e.g. when app wants to replace presenter to render HeaderItem.

Returns
HeadersSupportFragment!

A new instance of HeadersSupportFragment or its subclass.

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.

onDestroy

fun onDestroy(): Unit

Called when the fragment is no longer in use. This is called after onStop and before onDetach.

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.

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

Added in 1.1.0
fun setAdapter(adapter: ObjectAdapter!): Unit

Sets the adapter containing the rows for the fragment.

The items referenced by the adapter must be be derived from Row. These rows will be used by the rows fragment and the headers fragment (if not disabled) to render the browse rows.

Parameters
adapter: ObjectAdapter!

An ObjectAdapter for the browse rows. All items must derive from Row.

setBrandColor

Added in 1.1.0
fun setBrandColor(color: @ColorInt Int): Unit

Sets the brand color for the browse fragment. The brand color is used as the primary color for UI elements in the browse fragment. For example, the background color of the headers fragment uses the brand color.

Parameters
color: @ColorInt Int

The color to use as the brand color of the fragment.

setBrowseTransitionListener

Added in 1.1.0
fun setBrowseTransitionListener(
    listener: BrowseSupportFragment.BrowseTransitionListener!
): Unit

Sets a listener for browse fragment transitions.

Parameters
listener: BrowseSupportFragment.BrowseTransitionListener!

The listener to call when a browse headers transition begins or ends.

setHeaderPresenterSelector

Added in 1.1.0
fun setHeaderPresenterSelector(headerPresenterSelector: PresenterSelector!): Unit

Sets the PresenterSelector used to render the row headers.

Parameters
headerPresenterSelector: PresenterSelector!

The PresenterSelector that will determine the Presenter for each row header.

setHeadersState

Added in 1.1.0
fun setHeadersState(headersState: Int): Unit

Sets the state for the headers column in the browse fragment. Must be one of HEADERS_ENABLED, HEADERS_HIDDEN, or HEADERS_DISABLED.

Parameters
headersState: Int

The state of the headers for the browse fragment.

setHeadersTransitionOnBackEnabled

Added in 1.1.0
fun setHeadersTransitionOnBackEnabled(headersBackStackEnabled: Boolean): Unit

Enables/disables headers transition on back key support. This is enabled by default. The BrowseSupportFragment will add a back stack entry when headers are showing. Running a headers transition when the back key is pressed only works when the headers state is HEADERS_ENABLED or HEADERS_HIDDEN.

NOTE: If an Activity has its own onBackPressed() handling, you must disable this feature. You may use startHeadersTransition and BrowseTransitionListener in your own back stack handling.

setOnItemViewClickedListener

Added in 1.1.0
fun setOnItemViewClickedListener(listener: OnItemViewClickedListener!): 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

Added in 1.1.0
fun setOnItemViewSelectedListener(listener: OnItemViewSelectedListener!): Unit

Sets an item selection listener.

setSelectedPosition

Added in 1.1.0
fun setSelectedPosition(position: Int): Unit

Sets the selected row position with smooth animation.

setSelectedPosition

Added in 1.1.0
fun setSelectedPosition(position: Int, smooth: Boolean): Unit

Sets the selected row position.

setSelectedPosition

Added in 1.1.0
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)) scrolls 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!

Optional task to perform on the Row. When the task is not null, headers fragment will be collapsed.

startHeadersTransition

Added in 1.1.0
fun startHeadersTransition(withHeaders: Boolean): Unit

Starts a headers transition.

This method will begin a transition to either show or hide the headers, depending on the value of withHeaders. If headers are disabled for this browse fragment, this method will throw an exception.

Parameters
withHeaders: Boolean

True if the headers should transition to being shown, false if the transition should result in headers being hidden.

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.

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.

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.