Skip to content

Commit

Permalink
Address another possible BetterLinkMovementMethod crash
Browse files Browse the repository at this point in the history
SchildiChat/SchildiChat-android-rageshakes#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
  • Loading branch information
SpiritCroc committed Sep 10, 2023
1 parent 97dc744 commit a411437
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import android.text.style.ClickableSpan
import android.text.style.URLSpan
import android.widget.TextView
import me.saket.bettermovementmethod.BetterLinkMovementMethod
import timber.log.Timber

class EvenBetterLinkMovementMethod(private val onLinkClickListener: OnLinkClickListener? = null) : BetterLinkMovementMethod() {

Expand Down Expand Up @@ -50,4 +51,12 @@ class EvenBetterLinkMovementMethod(private val onLinkClickListener: OnLinkClickL
clickableSpan.onClick(textView)
}
}

override fun dispatchUrlLongClick(textView: TextView?, clickableSpan: ClickableSpan?) {
try {
super.dispatchUrlLongClick(textView, clickableSpan)
} catch (e: StringIndexOutOfBoundsException) {
Timber.w("BetterLinkMovement dispatchUrlLongClick StringIndexOutOfBoundsException $e")
}
}
}

0 comments on commit a411437

Please sign in to comment.