From 49fdb34a5cddb965af0458113f17ede09bcfea9c Mon Sep 17 00:00:00 2001 From: maxli Date: Thu, 22 Aug 2024 14:38:16 +0800 Subject: [PATCH] fix(android): use Spanned to getSpans --- .../java/com/tencent/renderer/component/Component.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/renderer/native/android/src/main/java/com/tencent/renderer/component/Component.java b/renderer/native/android/src/main/java/com/tencent/renderer/component/Component.java index 69c9b60d252..73e66202029 100644 --- a/renderer/native/android/src/main/java/com/tencent/renderer/component/Component.java +++ b/renderer/native/android/src/main/java/com/tencent/renderer/component/Component.java @@ -29,6 +29,7 @@ import android.text.Layout; import android.text.Spannable; +import android.text.Spanned; import androidx.annotation.ColorInt; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -336,10 +337,10 @@ public void setTextLayout(@NonNull Object layout) { assert mTextDrawable != null; if (mTextDrawable.getTextLayout() != null) { CharSequence textSequence = mTextDrawable.getTextLayout().getText(); - if (textSequence instanceof Spannable) { - Spannable spannable = (Spannable) textSequence; - TextGestureSpan[] spans = spannable - .getSpans(0, spannable.length(), TextGestureSpan.class); + if (textSequence instanceof Spanned) { + Spanned spannedText = (Spanned) textSequence; + TextGestureSpan[] spans = spannedText + .getSpans(0, spannedText.length(), TextGestureSpan.class); setGestureEnable((spans != null && spans.length > 0)); } }