From 6cf77e3a7ddead3c1a38dda8f522c2517ed9b37c Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Sat, 4 May 2019 16:07:40 +0200 Subject: fixed rare NPE cause by race --- src/main/java/de/pixart/messenger/ui/widget/EditMessage.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/main/java/de/pixart/messenger/ui/widget/EditMessage.java b/src/main/java/de/pixart/messenger/ui/widget/EditMessage.java index bb276a182..ca61491a9 100644 --- a/src/main/java/de/pixart/messenger/ui/widget/EditMessage.java +++ b/src/main/java/de/pixart/messenger/ui/widget/EditMessage.java @@ -85,16 +85,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) { -- cgit v1.2.3