Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

DetailsSupportFragment

open class DetailsSupportFragment : BaseSupportFragment
kotlin.Any
   ↳ androidx.fragment.app.Fragment
   ↳ androidx.leanback.app.BrandedSupportFragment
   ↳ androidx.leanback.app.BaseSupportFragment
   ↳ androidx.leanback.app.DetailsSupportFragment

A fragment for creating Leanback details screens.

A DetailsSupportFragment renders the elements of its ObjectAdapter as a set of rows in a vertical list.The Adapter's PresenterSelector must maintain subclasses of RowPresenter.

When FullWidthDetailsOverviewRowPresenter is found in adapter, DetailsSupportFragment will setup default behavior of the DetailsOverviewRow:
  • The alignment of FullWidthDetailsOverviewRowPresenter is setup in setupDetailsOverviewRowPresenter(FullWidthDetailsOverviewRowPresenter).
  • The view status switching of FullWidthDetailsOverviewRowPresenter is done in onSetDetailsOverviewRowStatus(FullWidthDetailsOverviewRowPresenter, * FullWidthDetailsOverviewRowPresenter.ViewHolder, int, int, int).
  • The recommended activity themes to use with a DetailsSupportFragment are

  • androidx.leanback.R.style#Theme_Leanback_Details with activity shared element transition for FullWidthDetailsOverviewRowPresenter.
  • androidx.leanback.R.style#Theme_Leanback_Details_NoSharedElementTransition if shared element transition is not needed, for example if first row is not rendered by FullWidthDetailsOverviewRowPresenter.
  • DetailsSupportFragment can use DetailsSupportFragmentBackgroundController to add a parallax drawable background and embedded video playing fragment.

    Summary

    Public constructors

    A fragment for creating Leanback details screens.

    Public methods

    open ObjectAdapter!

    Returns the list of rows.

    open BaseOnItemViewClickedListener<Any!>!

    Returns the item clicked listener.

    open DetailsParallax!

    Returns the DetailsParallax instance used by DetailsSupportFragmentBackgroundController to configure parallax effect of background and control embedded video playback.

    open RowsSupportFragment!

    Gets embedded RowsSupportFragment showing multiple rows for DetailsSupportFragment.

    open Unit
    onCreate(savedInstanceState: Bundle?)

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

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

    open Unit

    open Unit

    open Unit

    Sets the list of rows for the fragment.

    open Unit

    Sets an item clicked listener.

    open Unit

    Sets an item selection listener.

    open Unit

    Sets the selected row position with smooth animation.

    open Unit
    setSelectedPosition(position: Int, smooth: Boolean)

    Sets the selected row position.

    Protected methods

    open Any!

    open View!
    inflateTitle(inflater: LayoutInflater!, parent: ViewGroup!, savedInstanceState: Bundle!)

    open Unit

    open Unit

    open Unit

    open Unit
    onSetDetailsOverviewRowStatus(presenter: FullWidthDetailsOverviewRowPresenter!, viewHolder: FullWidthDetailsOverviewRowPresenter.ViewHolder!, adapterPosition: Int, selectedPosition: Int, selectedSubPosition: Int)

    Called to change DetailsOverviewRow view status when current selected row position or selected sub position changed.

    open Unit
    onSetRowStatus(presenter: RowPresenter!, viewHolder: RowPresenter.ViewHolder!, adapterPosition: Int, selectedPosition: Int, selectedSubPosition: Int)

    Called on every visible row to change view status when current selected row position or selected sub position changed.

    open Unit
    runEntranceTransition(entranceTransition: Any!)

    open Unit

    Called to setup FullWidthDetailsOverviewRowPresenter.

    open Unit
    setupPresenter(rowPresenter: Presenter!)

    Called to setup each Presenter of Adapter passed in setAdapter(ObjectAdapter).

    Inherited functions

    Public constructors

    <init>

    DetailsSupportFragment()

    A fragment for creating Leanback details screens.

    A DetailsSupportFragment renders the elements of its ObjectAdapter as a set of rows in a vertical list.The Adapter's PresenterSelector must maintain subclasses of RowPresenter.

    When FullWidthDetailsOverviewRowPresenter is found in adapter, DetailsSupportFragment will setup default behavior of the DetailsOverviewRow:
  • The alignment of FullWidthDetailsOverviewRowPresenter is setup in setupDetailsOverviewRowPresenter(FullWidthDetailsOverviewRowPresenter).
  • The view status switching of FullWidthDetailsOverviewRowPresenter is done in onSetDetailsOverviewRowStatus(FullWidthDetailsOverviewRowPresenter, * FullWidthDetailsOverviewRowPresenter.ViewHolder, int, int, int).
  • The recommended activity themes to use with a DetailsSupportFragment are

  • androidx.leanback.R.style#Theme_Leanback_Details with activity shared element transition for FullWidthDetailsOverviewRowPresenter.
  • androidx.leanback.R.style#Theme_Leanback_Details_NoSharedElementTransition if shared element transition is not needed, for example if first row is not rendered by FullWidthDetailsOverviewRowPresenter.
  • DetailsSupportFragment can use DetailsSupportFragmentBackgroundController to add a parallax drawable background and embedded video playing fragment.

    Public methods

    getAdapter

    open fun getAdapter(): ObjectAdapter!

    Returns the list of rows.

    getOnItemViewClickedListener

    open fun getOnItemViewClickedListener(): BaseOnItemViewClickedListener<Any!>!

    Returns the item clicked listener.

    getParallax

    open fun getParallax(): DetailsParallax!

    Returns the DetailsParallax instance used by DetailsSupportFragmentBackgroundController 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.

    Return
    DetailsParallax!: The DetailsParallax instance attached to the DetailsSupportFragment.

    getRowsSupportFragment

    open fun getRowsSupportFragment(): RowsSupportFragment!

    Gets embedded RowsSupportFragment showing multiple rows for DetailsSupportFragment. If view of DetailsSupportFragment is not created, the method returns null.

    Return
    RowsSupportFragment!: Embedded RowsSupportFragment showing multiple rows for DetailsSupportFragment.

    onCreate

    open fun onCreate(savedInstanceState: Bundle?): Unit

    onCreateView

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

    onInflateTitleView

    open fun onInflateTitleView(inflater: LayoutInflater!, parent: ViewGroup!, savedInstanceState: Bundle!): View!

    onStart

    open fun onStart(): Unit

    onStop

    open fun onStop(): Unit

    setAdapter

    open fun setAdapter(adapter: ObjectAdapter!): Unit

    Sets the list of rows for the fragment.

    setOnItemViewClickedListener

    open fun setOnItemViewClickedListener(listener: BaseOnItemViewClickedListener<Any!>!): Unit

    Sets an item clicked listener.

    setOnItemViewSelectedListener

    open fun setOnItemViewSelectedListener(listener: BaseOnItemViewSelectedListener<Any!>!): Unit

    Sets an item selection listener.

    setSelectedPosition

    open fun setSelectedPosition(position: Int): Unit

    Sets the selected row position with smooth animation.

    setSelectedPosition

    open fun setSelectedPosition(position: Int, smooth: Boolean): Unit

    Sets the selected row position.

    Protected methods

    createEntranceTransition

    protected open fun createEntranceTransition(): Any!

    inflateTitle

    protected open fun inflateTitle(inflater: LayoutInflater!, parent: ViewGroup!, savedInstanceState: Bundle!): View!

    Deprecated: override onInflateTitleView(LayoutInflater,ViewGroup,Bundle) instead.

    onEntranceTransitionEnd

    protected open fun onEntranceTransitionEnd(): Unit

    onEntranceTransitionPrepare

    protected open fun onEntranceTransitionPrepare(): Unit

    onEntranceTransitionStart

    protected open fun onEntranceTransitionStart(): Unit

    onSetDetailsOverviewRowStatus

    protected open fun onSetDetailsOverviewRowStatus(presenter: FullWidthDetailsOverviewRowPresenter!, viewHolder: FullWidthDetailsOverviewRowPresenter.ViewHolder!, adapterPosition: Int, selectedPosition: Int, selectedSubPosition: Int): Unit

    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: FullWidthDetailsOverviewRowPresenter#STATE_HALF, FullWidthDetailsOverviewRowPresenter#STATE_FULL and FullWidthDetailsOverviewRowPresenter#STATE_SMALL.

    Parameters
    presenter FullWidthDetailsOverviewRowPresenter!: The presenter used to create row ViewHolder.
    viewHolder FullWidthDetailsOverviewRowPresenter!: The visible (attached) row ViewHolder, note that it may or may not be selected.
    adapterPosition FullWidthDetailsOverviewRowPresenter!: The adapter position of viewHolder inside adapter.
    selectedPosition FullWidthDetailsOverviewRowPresenter!: The adapter position of currently selected row.
    selectedSubPosition FullWidthDetailsOverviewRowPresenter!: The sub position within currently selected row. This is used When a row has multiple alignment positions.

    onSetRowStatus

    protected open fun onSetRowStatus(presenter: RowPresenter!, viewHolder: RowPresenter.ViewHolder!, adapterPosition: Int, selectedPosition: Int, selectedSubPosition: Int): Unit

    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!: The visible (attached) row ViewHolder, note that it may or may not be selected.
    adapterPosition RowPresenter!: The adapter position of viewHolder inside adapter.
    selectedPosition RowPresenter!: The adapter position of currently selected row.
    selectedSubPosition RowPresenter!: The sub position within currently selected row. This is used When a row has multiple alignment positions.

    runEntranceTransition

    protected open fun runEntranceTransition(entranceTransition: Any!): Unit

    setupDetailsOverviewRowPresenter

    protected open fun setupDetailsOverviewRowPresenter(presenter: FullWidthDetailsOverviewRowPresenter!): Unit

    Called to setup FullWidthDetailsOverviewRowPresenter. The default implementation adds two alignment positions(ItemAlignmentFacet) for ViewHolder of FullWidthDetailsOverviewRowPresenter to align in fragment.

    setupPresenter

    protected open fun setupPresenter(rowPresenter: Presenter!): Unit

    Called to setup each Presenter of Adapter passed in setAdapter(ObjectAdapter).Note that setup should only change the Presenter behavior that is meaningful in DetailsSupportFragment. For example how a row is aligned in details Fragment. The default implementation invokes setupDetailsOverviewRowPresenter(FullWidthDetailsOverviewRowPresenter)