Catch NPE on Chat view binding

Resolves: #1960

Signed-off-by: Tim Krüger <t@timkrueger.me>
This commit is contained in:
Tim Krüger 2022-05-03 12:11:29 +02:00 committed by Marcel Hibbe
parent 5cb36d0801
commit b60de3858b
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B

View File

@ -701,10 +701,16 @@ class ChatController(args: Bundle) :
showMicrophoneButton(true)
binding.messageInputView.messageInput.doAfterTextChanged {
if (binding.messageInputView.messageInput.text.isEmpty()) {
showMicrophoneButton(true)
} else {
showMicrophoneButton(false)
try {
if (binding.messageInputView.messageInput.text.isEmpty()) {
showMicrophoneButton(true)
} else {
showMicrophoneButton(false)
}
} catch (npe: NullPointerException) {
// view binding can be null
// since this is called asynchronously and UI might have been destroyed in the meantime
Log.i(TAG, "UI destroyed - view binding already gone")
}
}