SignInTemplate.Builder
@RequiresCarApi(value = 2)
public final class SignInTemplate.Builder
A builder of SignInTemplate.
Summary
Public constructors |
|---|
Builder(@NonNull SignInTemplate.SignInMethod signInMethod)Returns a |
Public methods |
|
|---|---|
@NonNull SignInTemplate.Builder |
Adds an |
@NonNull SignInTemplate |
build()Constructs the template defined by this builder. |
@NonNull SignInTemplate.Builder |
setActionStrip(@NonNull ActionStrip actionStrip)Sets the |
@NonNull SignInTemplate.Builder |
setAdditionalText(@NonNull CharSequence additionalText)Sets additional text, such as disclaimers, links to terms of services, to show in the template. |
@NonNull SignInTemplate.Builder |
setHeaderAction(@NonNull Action headerAction)Sets the |
@NonNull SignInTemplate.Builder |
setInstructions(@NonNull CharSequence instructions)Sets the text to show as instructions of the template. |
@NonNull SignInTemplate.Builder |
setLoading(boolean isLoading)Sets whether the template is in a loading state. |
@NonNull SignInTemplate.Builder |
setTitle(@NonNull CharSequence title)Sets the title of the template. |
Public constructors
Builder
public Builder(@NonNull SignInTemplate.SignInMethod signInMethod)
Returns a Builder instance.
| Parameters | |
|---|---|
@NonNull SignInTemplate.SignInMethod signInMethod |
the sign-in method to use in this template |
| Throws | |
|---|---|
java.lang.NullPointerException |
if the |
Public methods
addAction
public @NonNull SignInTemplate.Builder addAction(@NonNull Action action)
Adds an Action to display alongside the sign-in content.
Actions in its body, and they must use a androidx.car.app.model.ParkedOnlyOnClickListener.
Each action's title color can be customized with ForegroundCarColorSpan instances. Any other span is not supported.
| Throws | |
|---|---|
java.lang.NullPointerException |
if |
java.lang.IllegalArgumentException |
if |
build
public @NonNull SignInTemplate build()
Constructs the template defined by this builder.
RequirementsIf none of the header Action, the header title or the action strip have been set on the template, the header is hidden.
| Throws | |
|---|---|
java.lang.IllegalStateException |
if the template does not have either a title or header |
setActionStrip
public @NonNull SignInTemplate.Builder setActionStrip(@NonNull ActionStrip actionStrip)
Sets the ActionStrip for this template.
Unless set with this method, the template will not have an action strip.
Requirements This template allows up to 2Actions in its ActionStrip. Of the 2 allowed Actions, one of them can contain a title as set via setTitle. Otherwise, only Actions with icons are allowed.
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
if |
java.lang.NullPointerException |
if |
setAdditionalText
public @NonNull SignInTemplate.Builder setAdditionalText(@NonNull CharSequence additionalText)
Sets additional text, such as disclaimers, links to terms of services, to show in the template.
Unless set with this method, the template will not have additional text.
androidx.car.app.model.ClickableSpan, androidx.car.app.model.DistanceSpan, and androidx.car.app.model.DurationSpan are supported in the input string.
| Throws | |
|---|---|
java.lang.NullPointerException |
if |
java.lang.IllegalArgumentException |
if |
| See also | |
|---|---|
CarText |
setHeaderAction
public @NonNull SignInTemplate.Builder setHeaderAction(@NonNull Action headerAction)
Sets the Action that will be displayed in the header of the template.
Unless set with this method, the template will not have a header action.
Requirements This template only supports either one ofAPP_ICON and BACK as a header Action.
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
if |
java.lang.NullPointerException |
if |
setInstructions
public @NonNull SignInTemplate.Builder setInstructions(@NonNull CharSequence instructions)
Sets the text to show as instructions of the template.
Unless set with this method, the template will not have instructions.
androidx.car.app.model.DistanceSpan, androidx.car.app.model.DurationSpan, and androidx.car.app.model.ForegroundCarColorSpan are supported in the input string.
| Throws | |
|---|---|
java.lang.NullPointerException |
if |
java.lang.IllegalArgumentException |
if |
| See also | |
|---|---|
CarText |
for details on text handling and span support. |
setLoading
public @NonNull SignInTemplate.Builder setLoading(boolean isLoading)
Sets whether the template is in a loading state.
If set to true, the UI will display a loading indicator instead of the SignInMethod. The caller is expected to call invalidate once loading is complete.
setTitle
public @NonNull SignInTemplate.Builder setTitle(@NonNull CharSequence title)
Sets the title of the template.
Unless set with this method, the template will not have a title.
Only DistanceSpans and DurationSpans are supported in the input string.
| Throws | |
|---|---|
java.lang.NullPointerException |
if |
java.lang.IllegalArgumentException |
if |