DetailsFragment

Added in 1.1.0
Deprecated in 1.1.0

public class DetailsFragment extends BaseFragment


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 recommended activity themes to use with a DetailsFragment are

DetailsFragment can use DetailsFragmentBackgroundController to add a parallax drawable background and embedded video playing fragment.

Summary

Public constructors

Public methods

ObjectAdapter

Returns the list of rows.

BaseOnItemViewClickedListener

Returns the item clicked listener.

DetailsParallax

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

RowsFragment

Gets embedded RowsFragment showing multiple rows for DetailsFragment.

void
onCreate(Bundle savedInstanceState)

This method is deprecated.

@Nullable View
onCreateView(
    LayoutInflater inflater,
    @Nullable ViewGroup container,
    Bundle savedInstanceState
)

This method is deprecated.

void

This method is deprecated.

@NonNull View
onInflateTitleView(
    @NonNull LayoutInflater inflater,
    @Nullable ViewGroup parent,
    @Nullable Bundle savedInstanceState
)

Called by installTitleView to inflate title view.

void

This method is deprecated.

void

This method is deprecated.

void

Sets the list of rows for the fragment.

void

Sets an item clicked listener.

void

Sets an item selection listener.

void
setSelectedPosition(int position)

Sets the selected row position with smooth animation.

void
setSelectedPosition(int position, boolean smooth)

Sets the selected row position.

Protected methods

Object

Create entrance transition.

View
inflateTitle(
    LayoutInflater inflater,
    ViewGroup parent,
    Bundle savedInstanceState
)

This method is deprecated.

override onInflateTitleView instead.

void

Callback when entrance transition is ended.

void

Callback when entrance transition is prepared.

void

Callback when entrance transition is started.

void
onSetDetailsOverviewRowStatus(
    FullWidthDetailsOverviewRowPresenter presenter,
    FullWidthDetailsOverviewRowPresenter.ViewHolder viewHolder,
    int adapterPosition,
    int selectedPosition,
    int selectedSubPosition
)

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

void
onSetRowStatus(
    RowPresenter presenter,
    RowPresenter.ViewHolder viewHolder,
    int adapterPosition,
    int selectedPosition,
    int selectedSubPosition
)

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

void
runEntranceTransition(Object entranceTransition)

Run entrance transition.

void

Called to setup FullWidthDetailsOverviewRowPresenter.

void
setupPresenter(Presenter rowPresenter)

Called to setup each Presenter of Adapter passed in setAdapter.Note that setup should only change the Presenter behavior that is meaningful in DetailsFragment.

Inherited Constants

From android.content.ComponentCallbacks2
static final int
static final int
static final int
static final int
static final int
static final int
static final int

Inherited methods

From androidx.leanback.app.BaseFragment
final ProgressBarManager

Returns the ProgressBarManager.

void
onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState)

This method is deprecated.

void

Enables entrance transition.

void

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.BrandedFragment
@Nullable Drawable

Returns the badge drawable used in the fragment title.

int

Returns the color used to draw the search affordance.

@Nullable SearchOrbView.Colors

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

@Nullable CharSequence

Returns the title text for the fragment.

@Nullable View

Returns the view that implements TitleViewAdapter.Provider.

@Nullable TitleViewAdapter

Returns the TitleViewAdapter implemented by title view.

void
installTitleView(
    @NonNull LayoutInflater inflater,
    @NonNull ViewGroup parent,
    @Nullable Bundle savedInstanceState
)

Inflate title view and add to parent.

final boolean

Returns true/false to indicate the visibility of TitleView.

void

This method is deprecated.

void

This method is deprecated.

void

This method is deprecated.

void

Sets the drawable displayed in the fragment title.

void

Sets a click listener for the search affordance.

void

Sets the color used to draw the search affordance.

void

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

void

Sets title text for the fragment.

void

Sets the view that implemented TitleViewAdapter.

void
showTitle(int flags)

Changes title view's components visibility and shows title.

void
showTitle(boolean show)

Shows or hides the title view.

From android.app.Fragment
void
dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args)

This method is deprecated.

final boolean

This method is deprecated.

final Activity

This method is deprecated.

boolean

This method is deprecated.

boolean

This method is deprecated.

final Bundle

This method is deprecated.

final FragmentManager

This method is deprecated.

Context

This method is deprecated.

Transition

This method is deprecated.

Transition

This method is deprecated.

final FragmentManager

This method is deprecated.

final Object

This method is deprecated.

final int

This method is deprecated.

final LayoutInflater

This method is deprecated.

LoaderManager

This method is deprecated.

final Fragment

This method is deprecated.

Transition

This method is deprecated.

final Resources

This method is deprecated.

final boolean

This method is deprecated.

Transition

This method is deprecated.

Transition

This method is deprecated.

Transition

This method is deprecated.

final String
getString(int resId)

This method is deprecated.

final String

This method is deprecated.

final Fragment

This method is deprecated.

final int

This method is deprecated.

final CharSequence
getText(int resId)

This method is deprecated.

boolean

This method is deprecated.

View

This method is deprecated.

final int

This method is deprecated.

static Fragment
instantiate(Context context, String fname)

This method is deprecated.

final boolean

This method is deprecated.

final boolean

This method is deprecated.

final boolean

This method is deprecated.

final boolean

This method is deprecated.

final boolean

This method is deprecated.

final boolean

This method is deprecated.

final boolean

This method is deprecated.

final boolean

This method is deprecated.

void
onActivityCreated(Bundle savedInstanceState)

This method is deprecated.

void
onActivityResult(int requestCode, int resultCode, Intent data)

This method is deprecated.

void
onAttach(Context context)

This method is deprecated.

void
onAttachFragment(Fragment childFragment)

This method is deprecated.

void

This method is deprecated.

boolean

This method is deprecated.

void
onCreate(Bundle savedInstanceState)

This method is deprecated.

Animator
onCreateAnimator(int transit, boolean enter, int nextAnim)

This method is deprecated.

void
onCreateContextMenu(
    ContextMenu menu,
    View v,
    ContextMenu.ContextMenuInfo menuInfo
)

This method is deprecated.

void

This method is deprecated.

void

This method is deprecated.

void

This method is deprecated.

void

This method is deprecated.

void

This method is deprecated.

LayoutInflater
onGetLayoutInflater(Bundle savedInstanceState)

This method is deprecated.

void
onHiddenChanged(boolean hidden)

This method is deprecated.

void
onInflate(AttributeSet attrs, Bundle savedInstanceState)

This method is deprecated.

void

This method is deprecated.

void
onMultiWindowModeChanged(
    boolean isInMultiWindowMode,
    Configuration newConfig
)

This method is deprecated.

boolean

This method is deprecated.

void

This method is deprecated.

void

This method is deprecated.

void
onPictureInPictureModeChanged(
    boolean isInPictureInPictureMode,
    Configuration newConfig
)

This method is deprecated.

void

This method is deprecated.

void
onRequestPermissionsResult(
    int requestCode,
    String[] permissions,
    int[] grantResults
)

This method is deprecated.

void

This method is deprecated.

void

This method is deprecated.

void

This method is deprecated.

void
onTrimMemory(int level)

This method is deprecated.

void
onViewCreated(View view, Bundle savedInstanceState)

This method is deprecated.

void
onViewStateRestored(Bundle savedInstanceState)

This method is deprecated.

void

This method is deprecated.

void

This method is deprecated.

final void
requestPermissions(String[] permissions, int requestCode)

This method is deprecated.

void

This method is deprecated.

void

This method is deprecated.

void

This method is deprecated.

void

This method is deprecated.

void

This method is deprecated.

void

This method is deprecated.

void

This method is deprecated.

void
setHasOptionsMenu(boolean hasMenu)

This method is deprecated.

void

This method is deprecated.

void
setMenuVisibility(boolean menuVisible)

This method is deprecated.

void

This method is deprecated.

void
setRetainInstance(boolean retain)

This method is deprecated.

void

This method is deprecated.

void

This method is deprecated.

void

This method is deprecated.

void
setTargetFragment(Fragment fragment, int requestCode)

This method is deprecated.

void
setUserVisibleHint(boolean isVisibleToUser)

This method is deprecated.

boolean

This method is deprecated.

void

This method is deprecated.

void
startActivityForResult(Intent intent, int requestCode)

This method is deprecated.

void
startIntentSenderForResult(
    IntentSender intent,
    int requestCode,
    Intent fillInIntent,
    int flagsMask,
    int flagsValues,
    int extraFlags,
    Bundle options
)

This method is deprecated.

void

This method is deprecated.

String

This method is deprecated.

void

This method is deprecated.

Public constructors

DetailsFragment

Added in 1.1.0
Deprecated in 1.1.0
public DetailsFragment()

Public methods

getAdapter

Added in 1.1.0
Deprecated in 1.1.0
public ObjectAdapter getAdapter()

Returns the list of rows.

getOnItemViewClickedListener

Added in 1.1.0
Deprecated in 1.1.0
public BaseOnItemViewClickedListener getOnItemViewClickedListener()

Returns the item clicked listener.

getParallax

Added in 1.1.0
Deprecated in 1.1.0
public DetailsParallax getParallax()

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.

Returns
DetailsParallax

The DetailsParallax instance attached to the DetailsFragment.

getRowsFragment

Added in 1.1.0
Deprecated in 1.1.0
public RowsFragment getRowsFragment()

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

Returns
RowsFragment

Embedded RowsFragment showing multiple rows for DetailsFragment.

onCreate

public void onCreate(Bundle savedInstanceState)

onCreateView

Added in 1.1.0
Deprecated in 1.1.0
public @Nullable View onCreateView(
    LayoutInflater inflater,
    @Nullable ViewGroup container,
    Bundle savedInstanceState
)

onDestroyView

public void onDestroyView()

onInflateTitleView

public @NonNull View onInflateTitleView(
    @NonNull LayoutInflater inflater,
    @Nullable ViewGroup parent,
    @Nullable Bundle savedInstanceState
)

Called by installTitleView to inflate title view. Default implementation uses layout file lb_browse_title. Subclass may override and use its own layout, the layout must have a descendant with id browse_title_group that implements TitleViewAdapter.Provider. Subclass may return null if no title is needed.

Parameters
@NonNull LayoutInflater inflater

The LayoutInflater object that can be used to inflate any views in the fragment,

@Nullable ViewGroup parent

Parent of title view.

@Nullable Bundle savedInstanceState

If non-null, this fragment is being re-constructed from a previous saved state as given here.

Returns
@NonNull View

Title view which must have a descendant with id browse_title_group that implements TitleViewAdapter.Provider, or null for no title view.

onStart

public void onStart()

onStop

Added in 1.1.0
Deprecated in 1.1.0
public void onStop()

setAdapter

Added in 1.1.0
Deprecated in 1.1.0
public void setAdapter(ObjectAdapter adapter)

Sets the list of rows for the fragment.

setOnItemViewClickedListener

Added in 1.1.0
Deprecated in 1.1.0
public void setOnItemViewClickedListener(BaseOnItemViewClickedListener listener)

Sets an item clicked listener.

setOnItemViewSelectedListener

Added in 1.1.0
Deprecated in 1.1.0
public void setOnItemViewSelectedListener(BaseOnItemViewSelectedListener listener)

Sets an item selection listener.

setSelectedPosition

Added in 1.1.0
Deprecated in 1.1.0
public void setSelectedPosition(int position)

Sets the selected row position with smooth animation.

setSelectedPosition

Added in 1.1.0
Deprecated in 1.1.0
public void setSelectedPosition(int position, boolean smooth)

Sets the selected row position.

Protected methods

createEntranceTransition

protected Object createEntranceTransition()

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.

inflateTitle

Added in 1.1.0
Deprecated in 1.1.0
protected View inflateTitle(
    LayoutInflater inflater,
    ViewGroup parent,
    Bundle savedInstanceState
)

onEntranceTransitionEnd

protected void onEntranceTransitionEnd()

Callback when entrance transition is ended.

onEntranceTransitionPrepare

protected void onEntranceTransitionPrepare()

Callback when entrance transition is prepared. This is when fragment should stop user input and animations.

onEntranceTransitionStart

protected void onEntranceTransitionStart()

Callback when entrance transition is started. This is when fragment should stop processing layout.

onSetDetailsOverviewRowStatus

Added in 1.1.0
Deprecated in 1.1.0
protected void onSetDetailsOverviewRowStatus(
    FullWidthDetailsOverviewRowPresenter presenter,
    FullWidthDetailsOverviewRowPresenter.ViewHolder viewHolder,
    int adapterPosition,
    int selectedPosition,
    int selectedSubPosition
)

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

Parameters
FullWidthDetailsOverviewRowPresenter presenter

The presenter used to create row ViewHolder.

FullWidthDetailsOverviewRowPresenter.ViewHolder viewHolder

The visible (attached) row ViewHolder, note that it may or may not be selected.

int adapterPosition

The adapter position of viewHolder inside adapter.

int selectedPosition

The adapter position of currently selected row.

int selectedSubPosition

The sub position within currently selected row. This is used When a row has multiple alignment positions.

onSetRowStatus

Added in 1.1.0
Deprecated in 1.1.0
protected void onSetRowStatus(
    RowPresenter presenter,
    RowPresenter.ViewHolder viewHolder,
    int adapterPosition,
    int selectedPosition,
    int selectedSubPosition
)

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 if presenter is instance of FullWidthDetailsOverviewRowPresenter.

Parameters
RowPresenter presenter

The presenter used to create row ViewHolder.

RowPresenter.ViewHolder viewHolder

The visible (attached) row ViewHolder, note that it may or may not be selected.

int adapterPosition

The adapter position of viewHolder inside adapter.

int selectedPosition

The adapter position of currently selected row.

int selectedSubPosition

The sub position within currently selected row. This is used When a row has multiple alignment positions.

runEntranceTransition

protected void runEntranceTransition(Object entranceTransition)

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.

setupDetailsOverviewRowPresenter

Added in 1.1.0
Deprecated in 1.1.0
protected void setupDetailsOverviewRowPresenter(
    FullWidthDetailsOverviewRowPresenter presenter
)

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

setupPresenter

Added in 1.1.0
Deprecated in 1.1.0
protected void setupPresenter(Presenter rowPresenter)

Called to setup each Presenter of Adapter passed in setAdapter.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