From 818f2ab61c67649d076d4f7d899cf5eb4790d43d Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 2 May 2019 20:09:16 +0200 Subject: [PATCH] fixed rare NPE cause by race --- .../eu/siacs/conversations/ui/widget/EditMessage.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/widget/EditMessage.java b/src/main/java/eu/siacs/conversations/ui/widget/EditMessage.java index 1ce695ab3..342867576 100644 --- a/src/main/java/eu/siacs/conversations/ui/widget/EditMessage.java +++ b/src/main/java/eu/siacs/conversations/ui/widget/EditMessage.java @@ -87,16 +87,20 @@ public class EditMessage extends EmojiWrapperEditText { } private void triggerKeyboardEvents(final int length) { + final KeyboardListener listener = this.keyboardListener; + if (listener == null) { + return; + } this.mTypingHandler.removeCallbacks(mTypingTimeout); this.mTypingHandler.postDelayed(mTypingTimeout, Config.TYPING_TIMEOUT * 1000); if (!isUserTyping && length > 0) { this.isUserTyping = true; - this.keyboardListener.onTypingStarted(); + listener.onTypingStarted(); } else if (length == 0) { this.isUserTyping = false; - this.keyboardListener.onTextDeleted(); + listener.onTextDeleted(); } - this.keyboardListener.onTextChanged(); + listener.onTextChanged(); } public void setKeyboardListener(KeyboardListener listener) {