Added in API level 31

Builder


class Builder
kotlin.Any
   ↳ android.view.translation.TranslationResponse.Builder

A builder for TranslationResponse

Summary

Public constructors
Builder(translationStatus: Int)

Creates a new Builder.

Public methods
TranslationResponse

Builds the instance.

TranslationResponse.Builder

Whether this response contains complete translated values, or is the final response in a series of partial responses.

TranslationResponse.Builder

Adds TranslationResponseValue to be translated.

TranslationResponse.Builder

List of translated TranslationResponseValues.

TranslationResponse.Builder

Sets the list of ViewTranslationResponse to be translated.

TranslationResponse.Builder

List of translated ViewTranslationResponses.

Public constructors

Public methods

build

Added in API level 31
fun build(): TranslationResponse

Builds the instance. This builder should not be touched after calling this!

Return
TranslationResponse This value cannot be null.

setFinalResponse

Added in API level 31
fun setFinalResponse(value: Boolean): TranslationResponse.Builder

Whether this response contains complete translated values, or is the final response in a series of partial responses.

This is true by default.

Return
TranslationResponse.Builder This value cannot be null.

setTranslationResponseValue

Added in API level 31
fun setTranslationResponseValue(
    index: Int,
    value: TranslationResponseValue
): TranslationResponse.Builder

Adds TranslationResponseValue to be translated. The input TranslationResponseValue format should match those provided by the android.view.translation.Translator's targetSpec.

Parameters
value TranslationResponseValue: the translated value. This value cannot be null.
Return
TranslationResponse.Builder this Builder. This value cannot be null.

setTranslationResponseValues

Added in API level 31
fun setTranslationResponseValues(value: SparseArray<TranslationResponseValue!>): TranslationResponse.Builder

List of translated TranslationResponseValues. The key of entries in this list will be their respective index in TranslationRequest#getTranslationRequestValues().

Parameters
value SparseArray<TranslationResponseValue!>: This value cannot be null.
Return
TranslationResponse.Builder This value cannot be null.

setViewTranslationResponse

Added in API level 31
fun setViewTranslationResponse(
    index: Int,
    response: ViewTranslationResponse
): TranslationResponse.Builder

Sets the list of ViewTranslationResponse to be translated. The input ViewTranslationResponse contains TranslationResponseValues whose format should match those provided by the android.view.translation.Translator's targetSpec.

Parameters
response ViewTranslationResponse: the translated response. This value cannot be null.
Return
TranslationResponse.Builder this Builder. This value cannot be null.

setViewTranslationResponses

Added in API level 31
fun setViewTranslationResponses(value: SparseArray<ViewTranslationResponse!>): TranslationResponse.Builder

List of translated ViewTranslationResponses. The key of entries in this list will be their respective index in TranslationRequest#getViewTranslationRequests().

Parameters
value SparseArray<ViewTranslationResponse!>: This value cannot be null.
Return
TranslationResponse.Builder This value cannot be null.