From b60de3858b9f62f579dd309a231fb87777d1593d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Kr=C3=BCger?= Date: Tue, 3 May 2022 12:11:29 +0200 Subject: [PATCH] Catch NPE on Chat view binding MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolves: #1960 Signed-off-by: Tim Krüger --- .../nextcloud/talk/controllers/ChatController.kt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt index fb125d451..0ecc0dc29 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt +++ b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt @@ -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") } }