浏览代码

Catch NPE on Chat view binding

Resolves: #1960

Signed-off-by: Tim Krüger <t@timkrueger.me>
Tim Krüger 3 年之前
父节点
当前提交
b60de3858b
共有 1 个文件被更改,包括 10 次插入4 次删除
  1. 10 4
      app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt

+ 10 - 4
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")
             }
         }