TabTemplate.Builder


class TabTemplate.Builder


A builder of TabTemplate.

Summary

Public constructors

Creates a TabTemplate.Builder instance using the given TabCallback.

Builder(tabTemplate: TabTemplate)

Creates a new Builder, populated from the input TabTemplate

Public functions

TabTemplate.Builder
addTab(tab: Tab)

Adds an Tab to display in the template.

TabTemplate

Constructs the template defined by this builder.

TabTemplate.Builder

Stores the given contentId as the "active tab" to show on the screen.

TabTemplate.Builder
setHeaderAction(headerAction: Action)

Sets the Action that will be displayed in the header of the template, or null to not display an action.

TabTemplate.Builder
setLoading(isLoading: Boolean)

Sets whether the template is in a loading state.

TabTemplate.Builder

Sets the TabContents to show in the template.

Public constructors

Builder

Added in 1.3.0
Builder(callback: TabTemplate.TabCallback)

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
callback: TabTemplate.TabCallback

the callback to be invoked when the user selects a new tab in the header

Builder

Added in 1.4.0
Builder(tabTemplate: TabTemplate)

Creates a new Builder, populated from the input TabTemplate

Public functions

addTab

Added in 1.3.0
fun addTab(tab: Tab): TabTemplate.Builder

Adds an Tab to display in the template.

Throws
java.lang.NullPointerException

if tab is null

build

Added in 1.3.0
fun build(): TabTemplate

Constructs the template defined by this builder.

Requirements The number of Tabs 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 Tab(s) or header Action does not meet the template's requirements

setActiveTabContentId

Added in 1.4.0
fun setActiveTabContentId(contentId: String): TabTemplate.Builder

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

Added in 1.3.0
fun setHeaderAction(headerAction: Action): TabTemplate.Builder

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 supports APP_ICON as a header Action.
Throws
java.lang.IllegalArgumentException

if headerAction does not meet the template's requirements

java.lang.NullPointerException

if headerAction is null

setLoading

Added in 1.3.0
fun setLoading(isLoading: Boolean): TabTemplate.Builder

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

Added in 1.3.0
fun setTabContents(tabContents: TabContents): TabTemplate.Builder

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 tabContents is null