TextLinks.DefaultTextLinkSpan

class TextLinks.DefaultTextLinkSpan : TextLinks.TextLinkSpan


The default implementation of TextLinkSpan.

When this span is clicked, text classifier will be used to classify the text in the span and suggest possible actions. The suggested actions will be presented to users eventually. You can change the way how the suggested actions are presented to user by overriding onTextClassificationResult.

Summary

Public constructors

Constructs a DefaultTextLinkSpan.

Public functions

Unit

Performs the click action associated with this span.

Unit
@UiThread
onTextClassificationResult(
    textView: TextView,
    textClassification: TextClassification
)

Invoked when the classification of the text of this span is available.

Public constructors

DefaultTextLinkSpan

DefaultTextLinkSpan(textLinkSpanData: TextLinks.TextLinkSpanData)

Constructs a DefaultTextLinkSpan.

Parameters
textLinkSpanData: TextLinks.TextLinkSpanData

The data object that contains data of this span, like the text link.

Public functions

onClick

@CallSuper
fun onClick(widget: View): Unit

Performs the click action associated with this span.

Subclass implementations should always call through to the superclass implementation.

onTextClassificationResult

@UiThread
fun onTextClassificationResult(
    textView: TextView,
    textClassification: TextClassification
): Unit

Invoked when the classification of the text of this span is available.

When user clicks on this span, text classifier will be used to classify the text of this span. Once text classifier has the result, this callback will be invoked. If the text in the textview is changed during the text classification, this won't be invoked.

You can change the way how the suggested actions are presented to user by overriding this function.

Parameters
textView: TextView

the textview that this span is attached to

textClassification: TextClassification

the text classification result of the text in this span.