fix NPE for binding in onEmojiClickListener

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2022-07-11 19:03:00 +02:00 committed by Marcel Hibbe (Rebase PR Action)
parent 981b64c9b7
commit 1f5807b8de

View File

@ -1679,6 +1679,7 @@ class ChatController(args: Bundle) :
currentConversation?.sessionId != "0" currentConversation?.sessionId != "0"
} }
@Suppress("Detekt.TooGenericExceptionCaught")
override fun onAttach(view: View) { override fun onAttach(view: View) {
super.onAttach(view) super.onAttach(view)
Log.d( Log.d(
@ -1718,7 +1719,13 @@ class ChatController(args: Bundle) :
) )
}, },
onEmojiClickListener = { onEmojiClickListener = {
binding.messageInputView.inputEditText?.editableText?.append(" ") try {
binding.messageInputView.inputEditText?.editableText?.append(" ")
} catch (npe: NullPointerException) {
// view binding can be null
// since this is called asynchronously and UI might have been destroyed in the meantime
Log.i(WebViewLoginController.TAG, "UI destroyed - view binding already gone")
}
} }
) )
} }