diff options
author | Andrew Comminos <andrewcomminos@gmail.com> | 2013-12-29 14:08:10 +0400 |
---|---|---|
committer | Andrew Comminos <andrewcomminos@gmail.com> | 2013-12-29 14:08:10 +0400 |
commit | dadc4de622c14b0a050c9fd86ada28fc79f012cd (patch) | |
tree | 5b37e1427251a73c507834436a142fabf4d6b62f /src/main/java | |
parent | f9315cbf73933c39854e4a405e3970ae860553dc (diff) |
Give a nicer message for exceptions.
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/com/morlunk/jumble/JumbleService.java | 10 | ||||
-rw-r--r-- | src/main/java/com/morlunk/jumble/net/JumbleConnectionException.java | 4 |
2 files changed, 6 insertions, 8 deletions
diff --git a/src/main/java/com/morlunk/jumble/JumbleService.java b/src/main/java/com/morlunk/jumble/JumbleService.java index 7aed9fe..ec74733 100644 --- a/src/main/java/com/morlunk/jumble/JumbleService.java +++ b/src/main/java/com/morlunk/jumble/JumbleService.java @@ -596,7 +596,7 @@ public class JumbleService extends Service implements JumbleConnection.JumbleCon } public boolean isConnected() { - return mConnection != null ? mConnection.isConnected() : false; + return mConnection != null && mConnection.isConnected(); } @Override @@ -655,16 +655,14 @@ public class JumbleService extends Service implements JumbleConnection.JumbleCon } }); - mChannelHandler = null; - mUserHandler = null; mMessageLog.clear(); } @Override public void onConnectionError(final JumbleConnectionException e) { Log.e(Constants.TAG, "Connection error: "+e.getMessage()); - if(mAutoReconnect && e.isAutoReconnectAllowed()) { - mReconnecting = true; + mReconnecting = mAutoReconnect && e.isAutoReconnectAllowed(); + if(mReconnecting) { Handler mainHandler = new Handler(); mainHandler.postDelayed(new Runnable() { @Override @@ -676,7 +674,7 @@ public class JumbleService extends Service implements JumbleConnection.JumbleCon notifyObservers(new ObserverRunnable() { @Override public void run(IJumbleObserver observer) throws RemoteException { - observer.onConnectionError(e.getMessage(), e.isAutoReconnectAllowed()); + observer.onConnectionError(e.getMessage(), mReconnecting); } }); } diff --git a/src/main/java/com/morlunk/jumble/net/JumbleConnectionException.java b/src/main/java/com/morlunk/jumble/net/JumbleConnectionException.java index 7c5711b..cefb6a6 100644 --- a/src/main/java/com/morlunk/jumble/net/JumbleConnectionException.java +++ b/src/main/java/com/morlunk/jumble/net/JumbleConnectionException.java @@ -52,14 +52,14 @@ public class JumbleConnectionException extends Exception { } public JumbleConnectionException(Mumble.Reject reject) { - super(reject.getReason()); + super("Reject: "+reject.getReason()); mReject = reject; mReason = JumbleDisconnectReason.REJECT; mAutoReconnect = false; } public JumbleConnectionException(Mumble.UserRemove userRemove) { - super(userRemove.getReason()); + super((userRemove.getBan() ? "Banned: " : "Kicked: ")+userRemove.getReason()); mUserRemove = userRemove; mReason = JumbleDisconnectReason.USER_REMOVE; mAutoReconnect = false; |