DetailsFragment

open class DetailsFragment : BaseFragment
kotlin.Any
   ↳ android.app.Fragment
   ↳ androidx.leanback.app.BrandedFragment
   ↳ androidx.leanback.app.BaseFragment
   ↳ androidx.leanback.app.DetailsFragment

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.

When FullWidthDetailsOverviewRowPresenter is found in adapter, DetailsFragment 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 DetailsFragment 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.
  • DetailsFragment can use DetailsFragmentBackgroundController to add a parallax drawable background and embedded video playing fragment.

    Summary

    Public methods
    open ObjectAdapter!

    Returns the list of rows.

    open Unit

    Sets an item clicked listener.

    open RowsFragment!

    Gets embedded RowsFragment showing multiple rows for DetailsFragment.

    open Unit
    onCreate(savedInstanceState: Bundle!)

    open Unit

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

    open DetailsParallax!

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

    open Unit

    Sets an item selection listener.

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

    open Unit

    Sets the selected row position with smooth animation.

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

    Sets the selected row position.

    open Unit

    Sets the list of rows for the fragment.

    open BaseOnItemViewClickedListener<Any!>!

    Returns the item clicked listener.

    open Unit

    Protected methods
    open Any!

    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
    setupPresenter(rowPresenter: Presenter!)

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

    open Unit

    Called to setup FullWidthDetailsOverviewRowPresenter.

    open Unit

    open Unit
    runEntranceTransition(entranceTransition: Any!)

    open Unit

    open Unit

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

    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.

    Inherited functions

    Public methods

    getAdapter

    open fun getAdapter(): ObjectAdapter!

    Returns the list of rows.

    setOnItemViewClickedListener

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

    Sets an item clicked listener.

    getRowsFragment

    open fun getRowsFragment(): RowsFragment!

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

    Return
    RowsFragment!: Embedded RowsFragment showing multiple rows for DetailsFragment.

    onCreate

    open fun onCreate(savedInstanceState: Bundle!): Unit

    onStart

    open fun onStart(): Unit

    onInflateTitleView

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

    getParallax

    open fun getParallax(): DetailsParallax!

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

    setOnItemViewSelectedListener

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

    Sets an item selection listener.

    onCreateView

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

    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.

    setAdapter

    open fun setAdapter(adapter: ObjectAdapter!): Unit

    Sets the list of rows for the fragment.

    getOnItemViewClickedListener

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

    Returns the item clicked listener.

    onStop

    open fun onStop(): Unit

    Protected methods

    createEntranceTransition

    protected open fun createEntranceTransition(): Any!

    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.

    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 DetailsFragment. For example how a row is aligned in details Fragment. The default implementation invokes #setupDetailsOverviewRowPresenter(FullWidthDetailsOverviewRowPresenter)

    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.

    onEntranceTransitionStart

    protected open fun onEntranceTransitionStart(): Unit

    runEntranceTransition

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

    onEntranceTransitionEnd

    protected open fun onEntranceTransitionEnd(): Unit

    onEntranceTransitionPrepare

    protected open fun onEntranceTransitionPrepare(): Unit

    inflateTitle

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

    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.