TextLinks.DefaultTextLinkSpan


public class TextLinks.DefaultTextLinkSpan extends 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 methods

void

Performs the click action associated with this span.

void
@UiThread
onTextClassificationResult(
    @NonNull TextView textView,
    @NonNull TextClassification textClassification
)

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

Public constructors

DefaultTextLinkSpan

public DefaultTextLinkSpan(
    @NonNull TextLinks.TextLinkSpanData textLinkSpanData
)

Constructs a DefaultTextLinkSpan.

Parameters
@NonNull TextLinks.TextLinkSpanData textLinkSpanData

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

Public methods

onClick

@CallSuper
public void onClick(@NonNull View widget)

Performs the click action associated with this span.

Subclass implementations should always call through to the superclass implementation.

onTextClassificationResult

@UiThread
public void onTextClassificationResult(
    @NonNull TextView textView,
    @NonNull TextClassification textClassification
)

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
@NonNull TextView textView

the textview that this span is attached to

@NonNull TextClassification textClassification

the text classification result of the text in this span.