fixed rare NPE cause by race

This commit is contained in:
Daniel Gultsch 2019-05-02 20:09:16 +02:00
parent 3d208e6e34
commit 818f2ab61c
1 changed files with 7 additions and 3 deletions

View File

@ -87,16 +87,20 @@ public class EditMessage extends EmojiWrapperEditText {
} }
private void triggerKeyboardEvents(final int length) { private void triggerKeyboardEvents(final int length) {
final KeyboardListener listener = this.keyboardListener;
if (listener == null) {
return;
}
this.mTypingHandler.removeCallbacks(mTypingTimeout); this.mTypingHandler.removeCallbacks(mTypingTimeout);
this.mTypingHandler.postDelayed(mTypingTimeout, Config.TYPING_TIMEOUT * 1000); this.mTypingHandler.postDelayed(mTypingTimeout, Config.TYPING_TIMEOUT * 1000);
if (!isUserTyping && length > 0) { if (!isUserTyping && length > 0) {
this.isUserTyping = true; this.isUserTyping = true;
this.keyboardListener.onTypingStarted(); listener.onTypingStarted();
} else if (length == 0) { } else if (length == 0) {
this.isUserTyping = false; this.isUserTyping = false;
this.keyboardListener.onTextDeleted(); listener.onTextDeleted();
} }
this.keyboardListener.onTextChanged(); listener.onTextChanged();
} }
public void setKeyboardListener(KeyboardListener listener) { public void setKeyboardListener(KeyboardListener listener) {