diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2014-03-06 03:57:29 +0100 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2014-03-06 03:57:29 +0100 |
commit | ac93f7419a40d9f94203d58dc00a5b51bea42ba5 (patch) | |
tree | eb0981a42c3e36c49296555f0684390099a295ac /src/eu/siacs/conversations/xmpp | |
parent | 2f0b2b865e4ec1b34d37120f085a9841ea11d1ed (diff) |
bug fixes. stuff more smoother
Diffstat (limited to 'src/eu/siacs/conversations/xmpp')
-rw-r--r-- | src/eu/siacs/conversations/xmpp/XmppConnection.java | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/eu/siacs/conversations/xmpp/XmppConnection.java b/src/eu/siacs/conversations/xmpp/XmppConnection.java index 3b3faaed..ec395de3 100644 --- a/src/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/eu/siacs/conversations/xmpp/XmppConnection.java @@ -66,10 +66,17 @@ public class XmppConnection implements Runnable { tagReader = new XmlReader(wakeLock); tagWriter = new TagWriter(); } + + protected void changeStatus(int nextStatus) { + account.setStatus(nextStatus); + if (statusListener != null) { + statusListener.onStatusChanged(account); + } + } protected void connect() { try { - account.setStatus(Account.STATUS_CONNECTING); + this.changeStatus(Account.STATUS_CONNECTING); Bundle namePort = DNSHelper.getSRVRecord(account.getServer()); String srvRecordServer = namePort.getString("name"); int srvRecordPort = namePort.getInt("port"); @@ -100,24 +107,19 @@ public class XmppConnection implements Runnable { socket.close(); } } catch (UnknownHostException e) { - account.setStatus(Account.STATUS_SERVER_NOT_FOUND); - if (statusListener != null) { - statusListener.onStatusChanged(account); - } + this.changeStatus(Account.STATUS_SERVER_NOT_FOUND); if (wakeLock.isHeld()) { wakeLock.release(); } return; } catch (IOException e) { - account.setStatus(Account.STATUS_OFFLINE); - if (statusListener != null) { - statusListener.onStatusChanged(account); - } + this.changeStatus(Account.STATUS_OFFLINE); if (wakeLock.isHeld()) { wakeLock.release(); } return; } catch (XmlPullParserException e) { + this.changeStatus(Account.STATUS_OFFLINE); Log.d(LOGTAG, "xml exception " + e.getMessage()); if (wakeLock.isHeld()) { wakeLock.release(); |