From 51d12231987e780915f6c762cb5b094a6ad1fb14 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 19 May 2017 15:28:25 +0200 Subject: [PATCH] invoke statusChanged callback after syncronization --- .../conversations/xmpp/XmppConnection.java | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java index fc4bf3102..b7393231a 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java @@ -218,26 +218,30 @@ public class XmppConnection implements Runnable { mXmppConnectionService = service; } - protected synchronized void changeStatus(final Account.State nextStatus) { - if (Thread.currentThread().isInterrupted()) { - Log.d(Config.LOGTAG,account.getJid().toBareJid()+": not changing status to "+nextStatus+" because thread was interrupted"); - return; - } - if (account.getStatus() != nextStatus) { - if ((nextStatus == Account.State.OFFLINE) - && (account.getStatus() != Account.State.CONNECTING) - && (account.getStatus() != Account.State.ONLINE) - && (account.getStatus() != Account.State.DISABLED)) { + protected void changeStatus(final Account.State nextStatus) { + synchronized (this) { + if (Thread.currentThread().isInterrupted()) { + Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": not changing status to " + nextStatus + " because thread was interrupted"); return; - } - if (nextStatus == Account.State.ONLINE) { - this.attempt = 0; } - account.setStatus(nextStatus); - if (statusListener != null) { - statusListener.onStatusChanged(account); + if (account.getStatus() != nextStatus) { + if ((nextStatus == Account.State.OFFLINE) + && (account.getStatus() != Account.State.CONNECTING) + && (account.getStatus() != Account.State.ONLINE) + && (account.getStatus() != Account.State.DISABLED)) { + return; + } + if (nextStatus == Account.State.ONLINE) { + this.attempt = 0; + } + account.setStatus(nextStatus); + } else { + return; } } + if (statusListener != null) { + statusListener.onStatusChanged(account); + } } public void prepareNewConnection() {