Translator
public
class
Translator
extends Object
java.lang.Object | |
↳ | android.view.translation.Translator |
The Translator
for translation, defined by a TranslationContext
.
Summary
Public methods | |
---|---|
void
|
destroy()
Destroy this Translator. |
boolean
|
isDestroyed()
Returns whether or not this Translator has been destroyed. |
void
|
translate(TranslationRequest request, CancellationSignal cancellationSignal, Executor executor, Consumer<TranslationResponse> callback)
Requests a translation for the provided |
Inherited methods | |
---|---|
Public methods
isDestroyed
public boolean isDestroyed ()
Returns whether or not this Translator has been destroyed.
Returns | |
---|---|
boolean |
See also:
translate
public void translate (TranslationRequest request, CancellationSignal cancellationSignal, Executor executor, Consumer<TranslationResponse> callback)
Requests a translation for the provided TranslationRequest
using the Translator's
source spec and destination spec.
Parameters | |
---|---|
request |
TranslationRequest : TranslationRequest request to be translate.
This value cannot be null . |
cancellationSignal |
CancellationSignal : signal to cancel the operation in progress.
This value may be null . |
executor |
Executor : Executor to run callback operations
This value cannot be null .
Callback and listener events are dispatched through this
Executor , providing an easy way to control which thread is
used. To dispatch events through the main thread of your
application, you can use
Context.getMainExecutor() .
Otherwise, provide an Executor that dispatches to an appropriate thread. |
callback |
Consumer : Consumer to receive the translation response. Multiple responses may
be received if TranslationRequest#FLAG_PARTIAL_RESPONSES is set.
This value cannot be null . |
Returns | |
---|---|
void |
This value may be null . |
Throws | |
---|---|
IllegalStateException |
if this Translator session was destroyed when called. |