Skip to content

Commit

Permalink
fix(android): use Spanned to getSpans
Browse files Browse the repository at this point in the history
  • Loading branch information
siguangli2018 authored and siguangli committed Aug 22, 2024
1 parent 269c33d commit 49fdb34
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}
}
Expand Down

0 comments on commit 49fdb34

Please sign in to comment.