TranslationResponse.Builder


public static final class TranslationResponse.Builder
extends Object

java.lang.Object
   ↳ android.view.translation.TranslationResponse.Builder


A builder for TranslationResponse

Summary

Public constructors

Builder(int translationStatus)

Creates a new Builder.

Public methods

TranslationResponse build()

Builds the instance.

TranslationResponse.Builder setFinalResponse(boolean value)

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

TranslationResponse.Builder setTranslationResponseValue(int index, TranslationResponseValue value)

Adds TranslationResponseValue to be translated.

TranslationResponse.Builder setTranslationResponseValues(SparseArray<TranslationResponseValue> value)

List of translated TranslationResponseValues.

TranslationResponse.Builder setViewTranslationResponse(int index, ViewTranslationResponse response)

Sets the list of ViewTranslationResponse to be translated.

TranslationResponse.Builder setViewTranslationResponses(SparseArray<ViewTranslationResponse> value)

List of translated ViewTranslationResponses.

Inherited methods

Object clone()

Creates and returns a copy of this object.

boolean equals(Object obj)

Indicates whether some other object is "equal to" this one.

void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

final Class<?> getClass()

Returns the runtime class of this Object.

int hashCode()

Returns a hash code value for the object.

final void notify()

Wakes up a single thread that is waiting on this object's monitor.

final void notifyAll()

Wakes up all threads that are waiting on this object's monitor.

String toString()

Returns a string representation of the object.

final void wait(long timeoutMillis, int nanos)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait(long timeoutMillis)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait()

Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

Public constructors

Builder

Added in API level 31
public Builder (int translationStatus)

Creates a new Builder.

Public methods

build

Added in API level 31
public TranslationResponse build ()

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

Returns
TranslationResponse This value cannot be null.

setFinalResponse

Added in API level 31
public TranslationResponse.Builder setFinalResponse (boolean value)

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

This is true by default.

Parameters
value boolean

Returns
TranslationResponse.Builder This value cannot be null.

setTranslationResponseValue

Added in API level 31
public TranslationResponse.Builder setTranslationResponseValue (int index, 
                TranslationResponseValue value)

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

Parameters
index int

value TranslationResponseValue: the translated value. This value cannot be null.

Returns
TranslationResponse.Builder this Builder. This value cannot be null.

setTranslationResponseValues

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

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

Parameters
value SparseArray: This value cannot be null.

Returns
TranslationResponse.Builder This value cannot be null.

setViewTranslationResponse

Added in API level 31
public TranslationResponse.Builder setViewTranslationResponse (int index, 
                ViewTranslationResponse response)

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

Parameters
index int

response ViewTranslationResponse: the translated response. This value cannot be null.

Returns
TranslationResponse.Builder this Builder. This value cannot be null.

setViewTranslationResponses

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

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

Parameters
value SparseArray: This value cannot be null.

Returns
TranslationResponse.Builder This value cannot be null.