For safety

This commit is contained in:
ThomasSession 2024-08-28 15:25:03 +10:00
parent 0b1a71a582
commit 116bef3c71
2 changed files with 4 additions and 4 deletions

View File

@ -87,8 +87,8 @@ class LinkPreviewView : LinearLayout {
// Method to show the open or copy URL dialog
private fun openURL() {
val url = this.url ?: return Log.w("LinkPreviewView", "Cannot open a null URL")
val activity = context as ConversationActivityV2
activity.showOpenUrlDialog(url)
val activity = context as? ConversationActivityV2
activity?.showOpenUrlDialog(url)
}
// endregion
}

View File

@ -287,8 +287,8 @@ class VisibleMessageContentView : ConstraintLayout {
body.getSpans<URLSpan>(0, body.length).toList().forEach { urlSpan ->
val updatedUrl = urlSpan.url.let { it.toHttpUrlOrNull().toString() }
val replacementSpan = ModalURLSpan(updatedUrl) { url ->
val activity = context as ConversationActivityV2
activity.showOpenUrlDialog(url)
val activity = context as? ConversationActivityV2
activity?.showOpenUrlDialog(url)
}
val start = body.getSpanStart(urlSpan)
val end = body.getSpanEnd(urlSpan)