TemplateWrapper

@CarProtocol
class TemplateWrapper


A wrapper for mapping a Template with a unique ID used for implementing task flow restrictions.

This is what is sent to the host, so that the host can determine whether the template is a new template (e.g. a step counts toward the task limit), or an existing template update (e.g. a refresh that does not count towards the task limit), by checking whether the ID have changed.

This class is for use by host implementations and not by apps.

Summary

Public functions

java-static TemplateWrapper

Creates a copy of the given TemplateWrapper.

Int

Retrieves the current task step that the template is in.

String

Returns the ID associated with the wrapped Template.

Template

Returns the wrapped Template.

(Mutable)List<TemplateInfo!>

Returns a TemplateInfo for the last returned template for each of the screens in the screen stack managed by the screen manager.

Boolean

Returns true if the template is a refresh for the previous template.

Unit
setCurrentTaskStep(currentTaskStep: Int)

Sets the current task step that the template is in.

Unit

Updates the ID associated with the wrapped Template.

Unit
setRefresh(isRefresh: Boolean)

Sets whether the template is a refresh of the current template.

Unit
setTemplate(template: Template)

Updates the Template this TemplateWrapper instance wraps.

String
java-static TemplateWrapper
wrap(template: Template)

Creates a TemplateWrapper instance with the given Template.

java-static TemplateWrapper
wrap(template: Template, id: String)

Creates a TemplateWrapper instance with the given Template and ID.

Public functions

copyOf

Added in 1.0.0
java-static fun copyOf(source: TemplateWrapper): TemplateWrapper

Creates a copy of the given TemplateWrapper.

getCurrentTaskStep

Added in 1.0.0
fun getCurrentTaskStep(): Int

Retrieves the current task step that the template is in.

getId

Added in 1.0.0
fun getId(): String

Returns the ID associated with the wrapped Template.

getTemplate

Added in 1.0.0
fun getTemplate(): Template

Returns the wrapped Template.

getTemplateInfosForScreenStack

Added in 1.0.0
fun getTemplateInfosForScreenStack(): (Mutable)List<TemplateInfo!>

Returns a TemplateInfo for the last returned template for each of the screens in the screen stack managed by the screen manager.

The return values are in order, where position 0 is the top of the stack, and position n is the bottom of the stack given n screens on the stack.

isRefresh

Added in 1.0.0
fun isRefresh(): Boolean

Returns true if the template is a refresh for the previous template.

setCurrentTaskStep

Added in 1.0.0
fun setCurrentTaskStep(currentTaskStep: Int): Unit

Sets the current task step that the template is in.

setId

Added in 1.0.0
fun setId(id: String): Unit

Updates the ID associated with the wrapped Template.

setRefresh

Added in 1.0.0
fun setRefresh(isRefresh: Boolean): Unit

Sets whether the template is a refresh of the current template.

setTemplate

Added in 1.0.0
fun setTemplate(template: Template): Unit

Updates the Template this TemplateWrapper instance wraps.

toString

Added in 1.4.0-rc02
fun toString(): String

wrap

Added in 1.0.0
java-static fun wrap(template: Template): TemplateWrapper

Creates a TemplateWrapper instance with the given Template.

The host will treat the Template as a new task step, unless it determines through its internal logic that the Template is a refresh of the existing view, in which case the task step will remain the same.

wrap

Added in 1.0.0
java-static fun wrap(template: Template, id: String): TemplateWrapper

Creates a TemplateWrapper instance with the given Template and ID.

The ID is primarily used to inform the host that the given Template shares the same ID as a previously sent Template, even though their contents differ. In such cases, the host will reset the task step to where the previous Template was.

For example, the client sends template A (task step 1), then move forwards a screen and sends template B (task step 2). Now the client pops the screen and sends template C. By assigning the ID of template A to template C, the client library informs the host that it is a back operation and the task step should be set to 1 again.