From 0fefada982f63054f8fcf9dd3c7b53d00cc81e4a Mon Sep 17 00:00:00 2001 From: ChronosX88 Date: Thu, 23 May 2019 16:41:52 +0400 Subject: [PATCH] Fixed some bug with null thread handler in XMPPConnectionService. --- .../influence/XMPPConnectionService.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/io/github/chronosx88/influence/XMPPConnectionService.java b/app/src/main/java/io/github/chronosx88/influence/XMPPConnectionService.java index 99247ee..96730b4 100644 --- a/app/src/main/java/io/github/chronosx88/influence/XMPPConnectionService.java +++ b/app/src/main/java/io/github/chronosx88/influence/XMPPConnectionService.java @@ -70,14 +70,16 @@ public class XMPPConnectionService extends Service { private void onServiceStop() { isThreadAlive = false; - threadHandler.post(() -> { - if(connection != null) { - thread.interrupt(); - thread = null; - connection.disconnect(); - connection = null; - } - }); + if(threadHandler != null) { + threadHandler.post(() -> { + if(connection != null) { + thread.interrupt(); + thread = null; + connection.disconnect(); + connection = null; + } + }); + } } private void createConnection() {