Header.Builder

public final class Header.Builder


A builder of Header.

Summary

Public constructors

Public methods

@NonNull Header.Builder

Adds an Action that will be displayed at the end of a header.

@NonNull Header

Constructs the component defined by this builder.

@NonNull Header.Builder

Sets the Action that will be displayed at the start of a header.

@NonNull Header.Builder

Sets the title of the component, with support for multiple length variants.

@NonNull Header.Builder

Sets the title of the component.

Public constructors

Builder

Added in 1.2.0
public Builder()

Public methods

addEndHeaderAction

Added in 1.2.0
public @NonNull Header.Builder addEndHeaderAction(@NonNull Action headerAction)

Adds an Action that will be displayed at the end of a header.

By default, a template will not have end header actions.

Requirements Up to 2 actions (which are APP_ICON, BACK or TYPE_CUSTOM with an icon) at the end of the header.

build

Added in 1.2.0
public @NonNull Header build()

Constructs the component defined by this builder.

Requirements

Either a start header Action or title must be set on the component.

Throws
java.lang.IllegalStateException

if neither a title nor start header Action is set

java.lang.IllegalArgumentException

if Actions towards the end of the header do not meet the template's requirements

setStartHeaderAction

Added in 1.2.0
public @NonNull Header.Builder setStartHeaderAction(@NonNull Action headerAction)

Sets the Action that will be displayed at the start of a header.

By default, a header will not have a start action.

Requirements Only one of APP_ICON or BACK is supported as a start header Action.
Throws
java.lang.IllegalArgumentException

if headerAction does not meet the requirements

java.lang.NullPointerException

if headerAction is null

setTitle

Added in 1.2.0
public @NonNull Header.Builder setTitle(@NonNull CarText title)

Sets the title of the component, with support for multiple length variants.

Only DistanceSpans and DurationSpans are supported in the input string.

Throws
java.lang.NullPointerException

if title is null

java.lang.IllegalArgumentException

if title contains unsupported spans

See also
CarText

setTitle

Added in 1.2.0
public @NonNull Header.Builder setTitle(@NonNull CharSequence title)

Sets the title of the component.

Only DistanceSpans and DurationSpans are supported in the input string.

Throws
java.lang.NullPointerException

if title is null

java.lang.IllegalArgumentException

if title contains unsupported spans

See also
CarText