Address another possible BetterLinkMovementMethod crash

https://github.com/SchildiChat/SchildiChat-android-rageshakes/issues/1152

Well... it says it happened on longclick, but it doesn't say if it
happened in SafeBetterLinkMovementMethod or
EvenBetterLinkMovementMethod, but since we're not using it plain as far
as I see, it should be one of these, and SafeBetterLinkMovementMethod
has it already caught?

Change-Id: Ifa171203b4e65a49a89121ddd2fb714d5bcb0d64
This commit is contained in:
SpiritCroc 2023-09-06 11:08:05 +02:00
parent 97dc744db3
commit a411437d53

View file

@ -21,6 +21,7 @@ import android.text.style.ClickableSpan
import android.text.style.URLSpan import android.text.style.URLSpan
import android.widget.TextView import android.widget.TextView
import me.saket.bettermovementmethod.BetterLinkMovementMethod import me.saket.bettermovementmethod.BetterLinkMovementMethod
import timber.log.Timber
class EvenBetterLinkMovementMethod(private val onLinkClickListener: OnLinkClickListener? = null) : BetterLinkMovementMethod() { class EvenBetterLinkMovementMethod(private val onLinkClickListener: OnLinkClickListener? = null) : BetterLinkMovementMethod() {
@ -50,4 +51,12 @@ class EvenBetterLinkMovementMethod(private val onLinkClickListener: OnLinkClickL
clickableSpan.onClick(textView) clickableSpan.onClick(textView)
} }
} }
override fun dispatchUrlLongClick(textView: TextView?, clickableSpan: ClickableSpan?) {
try {
super.dispatchUrlLongClick(textView, clickableSpan)
} catch (e: StringIndexOutOfBoundsException) {
Timber.w("BetterLinkMovement dispatchUrlLongClick StringIndexOutOfBoundsException $e")
}
}
} }