package androidx.appcompat.widget; import android.view.textclassifier.TextClassificationManager; import android.view.textclassifier.TextClassifier; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.RequiresApi; import androidx.core.util.Preconditions; public final class AppCompatTextClassifierHelper { @Nullable private TextClassifier mTextClassifier; @NonNull private TextView mTextView; public AppCompatTextClassifierHelper(@NonNull TextView textView) { this.mTextView = (TextView) Preconditions.checkNotNull(textView); } @NonNull @RequiresApi(api = 26) public TextClassifier getTextClassifier() { TextClassifier textClassifier = this.mTextClassifier; if (textClassifier != null) { return textClassifier; } TextClassificationManager textClassificationManager = (TextClassificationManager) this.mTextView.getContext().getSystemService(TextClassificationManager.class); return textClassificationManager != null ? textClassificationManager.getTextClassifier() : TextClassifier.NO_OP; } @RequiresApi(api = 26) public void setTextClassifier(@Nullable TextClassifier textClassifier) { this.mTextClassifier = textClassifier; } }