DetailsOverviewLogoPresenter

public class DetailsOverviewLogoPresenter extends Presenter


Presenter that responsible to create a ImageView and bind to DetailsOverviewRow. The default implementation uses getImageDrawable and binds to ImageView.

Default implementation assumes no scaleType on ImageView and uses intrinsic width and height of getImageDrawable to initialize ImageView's layout params. To specify a fixed size and/or specify a scapeType, subclass should change ImageView's layout params and scaleType in onCreateView.

Subclass may override and has its own image view. Subclass may also download image from URL instead of using getImageDrawable. It's subclass's responsibility to call notifyOnBindLogo whenever isBoundToImage turned to true so that activity transition can be started.

Summary

Nested types

ViewHolder for Logo view of DetailsOverviewRow.

Public constructors

Public methods

boolean

Returns true if the logo view is bound to image.

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

Bind logo View to drawable of DetailsOverviewRow and call notifyOnBindLogo().

@NonNull View

Create a View for the Logo, default implementation loads from lb_fullwidth_details_overview_logo.

@NonNull Presenter.ViewHolder

Creates a new View.

void

Unbinds a View from an item.

void

Called from FullWidthDetailsOverviewRowPresenter to setup FullWidthDetailsOverviewRowPresenter and FullWidthDetailsOverviewRowPresenter.ViewHolder that hosts the logo.

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.

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

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

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.

Public constructors

DetailsOverviewLogoPresenter

Added in 1.1.0
public DetailsOverviewLogoPresenter()

Public methods

isBoundToImage

Added in 1.1.0
public boolean isBoundToImage(
    @NonNull DetailsOverviewLogoPresenter.ViewHolder viewHolder,
    @Nullable DetailsOverviewRow row
)

Returns true if the logo view is bound to image. Subclass may override. The default implementation returns true when getImageDrawable is not null. If subclass of DetailsOverviewLogoPresenter manages its own image drawable, it should override this function to report status correctly and invoke notifyOnBindLogo when image view is bound to the drawable.

onBindViewHolder

Added in 1.2.0-alpha04
public void onBindViewHolder(
    @NonNull Presenter.ViewHolder viewHolder,
    @Nullable Object item
)

Bind logo View to drawable of DetailsOverviewRow and call notifyOnBindLogo(). The default implementation assumes the Logo View is an ImageView and change layout size to intrinsic size of ImageDrawable if isSizeFromDrawableIntrinsic is true.

Parameters
@NonNull Presenter.ViewHolder viewHolder

ViewHolder to bind.

@Nullable Object item

DetailsOverviewRow object to bind.

onCreateView

Added in 1.1.0
public @NonNull View onCreateView(@NonNull ViewGroup parent)

Create a View for the Logo, default implementation loads from lb_fullwidth_details_overview_logo. Subclass may override this method to use a fixed layout size and change ImageView scaleType. If the layout params is WRAP_CONTENT for both width and size, the ViewHolder would be using intrinsic size of Drawable in onBindViewHolder.

Parameters
@NonNull ViewGroup parent

Parent view.

Returns
@NonNull View

View created for the logo.

onCreateViewHolder

Added in 1.2.0-alpha04
public @NonNull Presenter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent)

Creates a new View.

onUnbindViewHolder

Added in 1.2.0-alpha04
public void onUnbindViewHolder(@NonNull Presenter.ViewHolder viewHolder)

Unbinds a View from an item. Any expensive references may be released here, and any fields that are not bound for every item should be cleared here.

setContext

Added in 1.1.0
public void setContext(
    @NonNull DetailsOverviewLogoPresenter.ViewHolder viewHolder,
    @Nullable FullWidthDetailsOverviewRowPresenter.ViewHolder parentViewHolder,
    @Nullable FullWidthDetailsOverviewRowPresenter parentPresenter
)

Called from FullWidthDetailsOverviewRowPresenter to setup FullWidthDetailsOverviewRowPresenter and FullWidthDetailsOverviewRowPresenter.ViewHolder that hosts the logo.