FullWidthDetailsOverviewRowPresenter


public class FullWidthDetailsOverviewRowPresenter extends RowPresenter


Renders a DetailsOverviewRow to display an overview of an item. Typically this row will be the first row in a fragment such as the androidx.leanback.app.DetailsFragment. The View created by the FullWidthDetailsOverviewRowPresenter is made in three parts: logo view on the left, action list view on the top and a customizable detailed description view on the right.

The detailed description is rendered using a Presenter passed in FullWidthDetailsOverviewRowPresenter. Typically this will be an instance of AbstractDetailsDescriptionPresenter. The application can access the detailed description ViewHolder from getDetailsDescriptionViewHolder.

The logo view is rendered using a customizable DetailsOverviewLogoPresenter passed in FullWidthDetailsOverviewRowPresenter. The application can access the logo ViewHolder from getLogoViewHolder.

To support activity shared element transition, call setListener with FullWidthDetailsOverviewSharedElementHelper during Activity's onCreate(). Application is free to create its own "shared element helper" class using the Listener for image binding. Call setParticipatingEntranceTransition with false

The view has three states: STATE_HALFSTATE_FULL and STATE_SMALL. See androidx.leanback.app.DetailsFragment where it switches states based on selected row position.

Summary

Nested types

Listeners for events on ViewHolder.

A ViewHolder for the DetailsOverviewRow.

Constants

static final int

This is the alignment mode that the ending edge of logo and the starting edge of description align to the middle of the overview view.

static final int

This is the alignment mode that the logo and description align to the starting edge of the overview view.

static final int

This is the state when the view covers full width and height of screen.

static final int

This is the default state corresponding to layout file.

static final int

This is the state where the view shrinks to a small banner.

Protected fields

int

Public constructors

Constructor for a FullWidthDetailsOverviewRowPresenter.

FullWidthDetailsOverviewRowPresenter(
    Presenter detailsPresenter,
    DetailsOverviewLogoPresenter logoPresenter
)

Constructor for a FullWidthDetailsOverviewRowPresenter.

Public methods

final int

Returns the background color of actions.

final int

Returns alignment mode of Description.

final int

Returns the background color.

final int

Returns the initial state used to create ViewHolder.

OnActionClickedListener

Returns the listener for Action click events.

final boolean

Returns true if the overview should be part of shared element transition.

final boolean

Returns true if this RowPresenter is using the default dimming effect.

final void

Called by DetailsOverviewLogoPresenter to notify logo was bound to view.

final void

Sets the background color for Action Bar.

final void
setAlignmentMode(int alignmentMode)

Set alignment mode of Description.

final void
setBackgroundColor(int color)

Sets the background color.

void
setEntranceTransitionState(
    @NonNull RowPresenter.ViewHolder holder,
    boolean afterEntrance
)

Changes the visibility of views.

final void
setInitialState(int state)

Change the initial state used to create ViewHolder.

final void

Set listener for details overview presenter.

void

Sets the listener for Action click events.

final void
setParticipatingEntranceTransition(boolean participating)

Sets if the overview should be part of shared element transition.

final void
setState(
    FullWidthDetailsOverviewRowPresenter.ViewHolder viewHolder,
    int state
)

Switch state of a ViewHolder.

Protected methods

RowPresenter.ViewHolder

Called to create a ViewHolder object for a Row.

int

Get resource id to inflate the layout.

boolean

Returns true if the Row view should clip its children.

void

Binds the given row object to the given ViewHolder.

void
onLayoutLogo(
    FullWidthDetailsOverviewRowPresenter.ViewHolder viewHolder,
    int oldState,
    boolean logoChanged
)

Layout logo position based on current state.

void
onLayoutOverviewFrame(
    FullWidthDetailsOverviewRowPresenter.ViewHolder viewHolder,
    int oldState,
    boolean logoChanged
)

Layout overview frame based on current state.

void

Invoked when the row view is attached to the window.

void

Invoked when the row view is detached from the window.

void

Callback when the select level changes.

void
onStateChanged(
    FullWidthDetailsOverviewRowPresenter.ViewHolder viewHolder,
    int oldState
)

Called when getState changes.

void

Unbinds the given ViewHolder.

Inherited Constants

From androidx.leanback.widget.RowPresenter
static final int

Don't synchronize row view activated status with selected status or expanded status, application will do its own through setActivated.

static final int

Synchronizes row view's activated status to expand status of the row view holder.

static final int

Sets the row view's activated status to true when both expand and selected are true.

static final int

Synchronizes row view's activated status to selected status of the row view holder.

Inherited methods

From androidx.leanback.widget.FacetProvider
abstract @Nullable Object
getFacet(@NonNull Class<Object> facetClass)

Queries optional implemented facet.

From androidx.leanback.widget.Presenter
static void

Utility method for removing all running animations on a view.

final Object
getFacet(Class<Object> facetClass)

Queries optional implemented facet.

abstract void
onBindViewHolder(
    @NonNull Presenter.ViewHolder viewHolder,
    @Nullable Object item
)

Binds a View to an item.

void
onBindViewHolder(
    @NonNull Presenter.ViewHolder viewHolder,
    @NonNull Object item,
    @NonNull List<Object> payloads
)

Binds a View to an item with a list of payloads.

abstract @NonNull Presenter.ViewHolder

Creates a new View.

abstract void

Unbinds a View from an item.

void

Called when a view created by this presenter has been attached to a window.

void

Called when a view created by this presenter has been detached from its window.

final void
setFacet(Class<Object> facetClass, Object facetImpl)

Sets dynamic implemented facet in addition to basic Presenter functions.

void

Called to set a click listener for the given view holder.

From androidx.leanback.widget.RowPresenter
void
dispatchItemSelectedListener(
    RowPresenter.ViewHolder vh,
    boolean selected
)

This method is only called from onRowViewSelected onRowViewSelected.

void
freeze(@NonNull RowPresenter.ViewHolder holder, boolean freeze)

Freezes/unfreezes the row, typically used when a transition starts/ends.

final RowHeaderPresenter

Returns the Presenter used for rendering the header, or null if none has been set.

final RowPresenter.ViewHolder

Returns the RowPresenter.ViewHolder from the given RowPresenter ViewHolder.

final boolean

Returns true if the row selection effect is enabled.

final float

Returns the current select level.

final int

Returns the policy of updating row view activated status.

void

Called after a RowPresenter.ViewHolder is created for a Row.

final void
onBindViewHolder(
    @NonNull Presenter.ViewHolder viewHolder,
    @Nullable Object item
)

Binds a View to an item.

final Presenter.ViewHolder

Creates a new View.

void

Called when the row view's expanded state changes.

void

Called when the given row view changes selection state.

final void

Unbinds a View from an item.

final void

Called when a view created by this presenter has been attached to a window.

final void

Called when a view created by this presenter has been detached from its window.

final void

Sets the Presenter used for rendering the header.

final void
setRowViewExpanded(Presenter.ViewHolder holder, boolean expanded)

Sets the expanded state of a Row view.

final void
setRowViewSelected(Presenter.ViewHolder holder, boolean selected)

Sets the selected state of a Row view.

final void
setSelectEffectEnabled(boolean applyDimOnSelect)

Enables or disables the row selection effect.

final void

Sets the current select level to a value between 0 (unselected) and 1 (selected).

final void
setSyncActivatePolicy(int syncActivatePolicy)

Sets the policy of updating row view activated status.

Constants

ALIGN_MODE_MIDDLE

Added in 1.1.0
public static final int ALIGN_MODE_MIDDLE = 1

This is the alignment mode that the ending edge of logo and the starting edge of description align to the middle of the overview view. Note that this might not be the exact horizontal center of the overview view.

ALIGN_MODE_START

Added in 1.1.0
public static final int ALIGN_MODE_START = 0

This is the alignment mode that the logo and description align to the starting edge of the overview view.

STATE_FULL

Added in 1.1.0
public static final int STATE_FULL = 1

This is the state when the view covers full width and height of screen.

STATE_HALF

Added in 1.1.0
public static final int STATE_HALF = 0

This is the default state corresponding to layout file. The view takes full width of screen and covers bottom half of the screen.

STATE_SMALL

Added in 1.1.0
public static final int STATE_SMALL = 2

This is the state where the view shrinks to a small banner.

Protected fields

mInitialState

Added in 1.1.0
protected int mInitialState

Public constructors

FullWidthDetailsOverviewRowPresenter

Added in 1.1.0
public FullWidthDetailsOverviewRowPresenter(Presenter detailsPresenter)

Constructor for a FullWidthDetailsOverviewRowPresenter.

Parameters
Presenter detailsPresenter

The Presenter used to render the detailed description of the row.

FullWidthDetailsOverviewRowPresenter

Added in 1.1.0
public FullWidthDetailsOverviewRowPresenter(
    Presenter detailsPresenter,
    DetailsOverviewLogoPresenter logoPresenter
)

Constructor for a FullWidthDetailsOverviewRowPresenter.

Parameters
Presenter detailsPresenter

The Presenter used to render the detailed description of the row.

DetailsOverviewLogoPresenter logoPresenter

The Presenter used to render the logo view.

Public methods

getActionsBackgroundColor

Added in 1.1.0
public final int getActionsBackgroundColor()

Returns the background color of actions. If setActionsBackgroundColor is not called, transparent is returned.

getAlignmentMode

Added in 1.1.0
public final int getAlignmentMode()

Returns alignment mode of Description.

Returns
int

One of ALIGN_MODE_MIDDLE or ALIGN_MODE_START.

getBackgroundColor

Added in 1.1.0
public final int getBackgroundColor()

Returns the background color. If setBackgroundColor, transparent is returned.

getInitialState

Added in 1.1.0
public final int getInitialState()

Returns the initial state used to create ViewHolder.

getOnActionClickedListener

Added in 1.1.0
public OnActionClickedListener getOnActionClickedListener()

Returns the listener for Action click events.

isParticipatingEntranceTransition

Added in 1.1.0
public final boolean isParticipatingEntranceTransition()

Returns true if the overview should be part of shared element transition.

isUsingDefaultSelectEffect

Added in 1.2.0-alpha04
public final boolean isUsingDefaultSelectEffect()

Returns true if this RowPresenter is using the default dimming effect. A subclass may (most likely) return false and override onSelectLevelChanged.

notifyOnBindLogo

Added in 1.1.0
public final void notifyOnBindLogo(
    FullWidthDetailsOverviewRowPresenter.ViewHolder viewHolder
)

Called by DetailsOverviewLogoPresenter to notify logo was bound to view. Application should not directly call this method.

Parameters
FullWidthDetailsOverviewRowPresenter.ViewHolder viewHolder

The row ViewHolder that has logo bound to view.

setActionsBackgroundColor

Added in 1.1.0
public final void setActionsBackgroundColor(int color)

Sets the background color for Action Bar. If not set, a default from the theme will be used.

setAlignmentMode

Added in 1.1.0
public final void setAlignmentMode(int alignmentMode)

Set alignment mode of Description.

Parameters
int alignmentMode

One of ALIGN_MODE_MIDDLE or ALIGN_MODE_START

setBackgroundColor

Added in 1.1.0
public final void setBackgroundColor(int color)

Sets the background color. If not set, a default from the theme will be used.

setEntranceTransitionState

public void setEntranceTransitionState(
    @NonNull RowPresenter.ViewHolder holder,
    boolean afterEntrance
)

Changes the visibility of views. The entrance transition will be run against the views that change visibilities. A subclass may override and begin with calling super.setEntranceTransitionState(). This method is called by the fragment, it should not be called directly by the application.

Parameters
@NonNull RowPresenter.ViewHolder holder

The ViewHolder of the row.

boolean afterEntrance

true if children of row participating in entrance transition should be set to visible, false otherwise.

setInitialState

Added in 1.1.0
public final void setInitialState(int state)

Change the initial state used to create ViewHolder.

setListener

Added in 1.1.0
public final void setListener(FullWidthDetailsOverviewRowPresenter.Listener listener)

Set listener for details overview presenter. Must be called before creating ViewHolder.

setOnActionClickedListener

Added in 1.1.0
public void setOnActionClickedListener(OnActionClickedListener listener)

Sets the listener for Action click events.

setParticipatingEntranceTransition

Added in 1.1.0
public final void setParticipatingEntranceTransition(boolean participating)

Sets if the overview should be part of shared element transition.

setState

Added in 1.1.0
public final void setState(
    FullWidthDetailsOverviewRowPresenter.ViewHolder viewHolder,
    int state
)

Switch state of a ViewHolder.

Parameters
FullWidthDetailsOverviewRowPresenter.ViewHolder viewHolder

The ViewHolder to change state.

int state

New state, can be STATE_FULL, STATE_HALF or STATE_SMALL.

Protected methods

createRowViewHolder

Added in 1.2.0-alpha04
protected RowPresenter.ViewHolder createRowViewHolder(ViewGroup parent)

Called to create a ViewHolder object for a Row. Subclasses will override this method to return a different concrete ViewHolder object.

Parameters
ViewGroup parent

The parent View for the Row's view holder.

Returns
RowPresenter.ViewHolder

A ViewHolder for the Row's View.

getLayoutResourceId

Added in 1.1.0
protected int getLayoutResourceId()

Get resource id to inflate the layout. The layout must match STATE_HALF

isClippingChildren

protected boolean isClippingChildren()

Returns true if the Row view should clip its children. The clipChildren flag is set on view in initializeRowViewHolder. Note that Slide transition or explode transition need turn off clipChildren. Default value is false.

onBindRowViewHolder

protected void onBindRowViewHolder(
    @NonNull RowPresenter.ViewHolder holder,
    @NonNull Object item
)

Binds the given row object to the given ViewHolder. Derived classes of RowPresenter overriding onBindRowViewHolder must call through the super class's implementation of this method.

onLayoutLogo

Added in 1.1.0
protected void onLayoutLogo(
    FullWidthDetailsOverviewRowPresenter.ViewHolder viewHolder,
    int oldState,
    boolean logoChanged
)

Layout logo position based on current state. Subclass may override. The method is called when a logo is bound to view or state changes.

Parameters
FullWidthDetailsOverviewRowPresenter.ViewHolder viewHolder

The row ViewHolder that contains the logo.

int oldState

The old state, can be same as current viewHolder.getState()

boolean logoChanged

Whether logo was changed.

onLayoutOverviewFrame

Added in 1.1.0
protected void onLayoutOverviewFrame(
    FullWidthDetailsOverviewRowPresenter.ViewHolder viewHolder,
    int oldState,
    boolean logoChanged
)

Layout overview frame based on current state. Subclass may override. The method is called when a logo is bound to view or state changes.

Parameters
FullWidthDetailsOverviewRowPresenter.ViewHolder viewHolder

The row ViewHolder that contains the logo.

int oldState

The old state, can be same as current viewHolder.getState()

boolean logoChanged

Whether logo was changed.

onRowViewAttachedToWindow

protected void onRowViewAttachedToWindow(@NonNull RowPresenter.ViewHolder vh)

Invoked when the row view is attached to the window.

onRowViewDetachedFromWindow

protected void onRowViewDetachedFromWindow(@NonNull RowPresenter.ViewHolder vh)

Invoked when the row view is detached from the window.

onSelectLevelChanged

protected void onSelectLevelChanged(RowPresenter.ViewHolder holder)

Callback when the select level changes. The default implementation applies the select level to setSelectLevel when getSelectEffectEnabled is true. Subclasses may override this function and implement a different select effect. In this case, the method isUsingDefaultSelectEffect should also be overridden to disable the default dimming effect.

onStateChanged

Added in 1.1.0
protected void onStateChanged(
    FullWidthDetailsOverviewRowPresenter.ViewHolder viewHolder,
    int oldState
)

Called when getState changes. Subclass may override. The default implementation calls onLayoutLogo and onLayoutOverviewFrame.

Parameters
FullWidthDetailsOverviewRowPresenter.ViewHolder viewHolder

The ViewHolder which state changed.

int oldState

The old state.

onUnbindRowViewHolder

protected void onUnbindRowViewHolder(@NonNull RowPresenter.ViewHolder holder)

Unbinds the given ViewHolder. Derived classes of RowPresenter overriding onUnbindRowViewHolder must call through the super class's implementation of this method.