TabTemplate.Builder
public final class TabTemplate.Builder
A builder of TabTemplate.
Summary
Public constructors |
|---|
Builder(@NonNull TabTemplate.TabCallback callback)Creates a |
Builder(@NonNull TabTemplate tabTemplate)Creates a new |
Public methods |
|
|---|---|
@NonNull TabTemplate.Builder |
Adds an |
@NonNull TabTemplate |
build()Constructs the template defined by this builder. |
@NonNull TabTemplate.Builder |
setActiveTabContentId(@NonNull String contentId)Stores the given |
@NonNull TabTemplate.Builder |
setHeaderAction(@NonNull Action headerAction)Sets the |
@NonNull TabTemplate.Builder |
setLoading(boolean isLoading)Sets whether the template is in a loading state. |
@NonNull TabTemplate.Builder |
setTabContents(@NonNull TabContents tabContents)Sets the |
Public constructors
Builder
public Builder(@NonNull TabTemplate.TabCallback callback)
Creates a TabTemplate.Builder instance using the given TabCallback.
Note that the callback relates to UI events and will be executed on the main thread using getMainLooper.
| Parameters | |
|---|---|
@NonNull TabTemplate.TabCallback callback |
the callback to be invoked when the user selects a new tab in the header |
Builder
public Builder(@NonNull TabTemplate tabTemplate)
Creates a new Builder, populated from the input TabTemplate
Public methods
addTab
public @NonNull TabTemplate.Builder addTab(@NonNull Tab tab)
Adds an Tab to display in the template.
| Throws | |
|---|---|
java.lang.NullPointerException |
if |
build
public @NonNull TabTemplate build()
Constructs the template defined by this builder.
Requirements The number ofTabs provided in the template should be between 2 and 4, with only one tab marked as active.
A header Action of type TYPE_APP_ICON is required.
| Throws | |
|---|---|
java.lang.IllegalStateException |
if the template is in a loading state but there are tabs added or vice versa |
java.lang.IllegalArgumentException |
if the added |
setActiveTabContentId
public @NonNull TabTemplate.Builder setActiveTabContentId(@NonNull String contentId)
Stores the given contentId as the "active tab" to show on the screen. The given ID must match a tab that was added by addTab.
setHeaderAction
public @NonNull TabTemplate.Builder setHeaderAction(@NonNull Action headerAction)
Sets the Action that will be displayed in the header of the template, or null to not display an action.
Unless set with this method, the template will not have a header action.
Requirements This template only supportsAPP_ICON as a header Action.
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
if |
java.lang.NullPointerException |
if |
setLoading
public @NonNull TabTemplate.Builder setLoading(boolean isLoading)
Sets whether the template is in a loading state.
If set to true, the UI will display a loading indicator where the content would be otherwise. The caller is expected to call invalidate and send the new template content to the host once the data is ready.
If set to false, the UI will display the contents of the template.
setTabContents
public @NonNull TabTemplate.Builder setTabContents(@NonNull TabContents tabContents)
Sets the TabContents to show in the template. Note that only certain templates may be used as content. See Builder for more details.
| Throws | |
|---|---|
java.lang.NullPointerException |
if |