add destruction check before accessing the binding object

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2021-05-27 00:32:46 +02:00
parent 1ebc2bac24
commit 266a9f73ee
No known key found for this signature in database
GPG Key ID: 6CADC7E3523C308B

View File

@ -773,24 +773,26 @@ class ChatController(args: Bundle) :
}
private fun setupMentionAutocomplete() {
val elevation = 6f
resources?.let {
val backgroundDrawable = ColorDrawable(it.getColor(R.color.bg_default))
val presenter = MentionAutocompletePresenter(activity, roomToken)
val callback = MentionAutocompleteCallback(
activity,
conversationUser,
binding?.messageInputView?.inputEditText
)
if (!isDestroyed && !isBeingDestroyed) {
val elevation = 6f
resources?.let {
val backgroundDrawable = ColorDrawable(it.getColor(R.color.bg_default))
val presenter = MentionAutocompletePresenter(activity, roomToken)
val callback = MentionAutocompleteCallback(
activity,
conversationUser,
binding?.messageInputView?.inputEditText
)
if (mentionAutocomplete == null && binding?.messageInputView?.inputEditText != null) {
mentionAutocomplete = Autocomplete.on<Mention>(binding?.messageInputView?.inputEditText)
.with(elevation)
.with(backgroundDrawable)
.with(MagicCharPolicy('@'))
.with(presenter)
.with(callback)
.build()
if (mentionAutocomplete == null && binding?.messageInputView?.inputEditText != null) {
mentionAutocomplete = Autocomplete.on<Mention>(binding?.messageInputView?.inputEditText)
.with(elevation)
.with(backgroundDrawable)
.with(MagicCharPolicy('@'))
.with(presenter)
.with(callback)
.build()
}
}
}
}