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() { private fun setupMentionAutocomplete() {
val elevation = 6f if (!isDestroyed && !isBeingDestroyed) {
resources?.let { val elevation = 6f
val backgroundDrawable = ColorDrawable(it.getColor(R.color.bg_default)) resources?.let {
val presenter = MentionAutocompletePresenter(activity, roomToken) val backgroundDrawable = ColorDrawable(it.getColor(R.color.bg_default))
val callback = MentionAutocompleteCallback( val presenter = MentionAutocompletePresenter(activity, roomToken)
activity, val callback = MentionAutocompleteCallback(
conversationUser, activity,
binding?.messageInputView?.inputEditText conversationUser,
) binding?.messageInputView?.inputEditText
)
if (mentionAutocomplete == null && binding?.messageInputView?.inputEditText != null) { if (mentionAutocomplete == null && binding?.messageInputView?.inputEditText != null) {
mentionAutocomplete = Autocomplete.on<Mention>(binding?.messageInputView?.inputEditText) mentionAutocomplete = Autocomplete.on<Mention>(binding?.messageInputView?.inputEditText)
.with(elevation) .with(elevation)
.with(backgroundDrawable) .with(backgroundDrawable)
.with(MagicCharPolicy('@')) .with(MagicCharPolicy('@'))
.with(presenter) .with(presenter)
.with(callback) .with(callback)
.build() .build()
}
} }
} }
} }