diff --git a/example/src/main/java/com/launchdarkly/example/MainActivity.java b/example/src/main/java/com/launchdarkly/example/MainActivity.java index 7463866b..c314a334 100644 --- a/example/src/main/java/com/launchdarkly/example/MainActivity.java +++ b/example/src/main/java/com/launchdarkly/example/MainActivity.java @@ -58,7 +58,7 @@ public void run() { connectionInformation.getConnectionMode().toString(), lastSuccess == null ? "Never" : new Date(lastSuccess).toString(), lastFailure == null ? "Never" : new Date(lastFailure).toString(), - lastFailure != null ? + connectionInformation.getLastFailure() != null ? connectionInformation.getLastFailure().getFailureType() : ""); connection.setText(result); diff --git a/launchdarkly-android-client-sdk/build.gradle b/launchdarkly-android-client-sdk/build.gradle index 7dc41c16..df709caf 100644 --- a/launchdarkly-android-client-sdk/build.gradle +++ b/launchdarkly-android-client-sdk/build.gradle @@ -40,11 +40,6 @@ android { execution 'ANDROID_TEST_ORCHESTRATOR' } - lintOptions { - // TODO: fix things and set this to true - abortOnError false - } - configurations { javadocDeps } diff --git a/launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/android/ConnectivityManager.java b/launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/android/ConnectivityManager.java index 4aac374b..8a23461a 100644 --- a/launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/android/ConnectivityManager.java +++ b/launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/android/ConnectivityManager.java @@ -184,7 +184,15 @@ private void startBackgroundPolling() { private void stopStreaming() { if (streamUpdateProcessor != null) { - streamUpdateProcessor.stop(); + streamUpdateProcessor.stop(null); + } + } + + private void stopStreaming(final Util.ResultCallback onCompleteListener) { + if (streamUpdateProcessor != null) { + streamUpdateProcessor.stop(onCompleteListener); + } else { + onCompleteListener.onSuccess(null); } } @@ -318,13 +326,22 @@ boolean isOffline() { return setOffline; } - synchronized void reloadUser(Util.ResultCallback onCompleteListener) { + synchronized void reloadUser(final Util.ResultCallback onCompleteListener) { throttler.cancel(); removeForegroundListener(); removeNetworkListener(); stopPolling(); - stopStreaming(); - startUp(onCompleteListener); + stopStreaming(new Util.ResultCallback() { + @Override + public void onSuccess(Void result) { + startUp(onCompleteListener); + } + + @Override + public void onError(Throwable e) { + startUp(onCompleteListener); + } + }); } private synchronized void updateConnectionMode(ConnectionMode connectionMode) { diff --git a/launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/android/StreamUpdateProcessor.java b/launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/android/StreamUpdateProcessor.java index 1bd89dc8..caebf2af 100644 --- a/launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/android/StreamUpdateProcessor.java +++ b/launchdarkly-android-client-sdk/src/main/java/com/launchdarkly/android/StreamUpdateProcessor.java @@ -51,7 +51,6 @@ class StreamUpdateProcessor { synchronized void start() { if (!running && !connection401Error) { - stop(); Timber.d("Starting."); Headers headers = new Headers.Builder() .add("Authorization", LDConfig.AUTH_SCHEME + config.getMobileKeys().get(environmentName)) @@ -99,7 +98,7 @@ public void onError(Throwable t) { Timber.e(e, "Client unavailable to be set offline"); } } - stop(); + stop(null); } else { notifier.onError(new LDInvalidResponseCodeFailure("Unexpected Response Code From Stream Connection", t, code, true)); } @@ -170,7 +169,7 @@ public Void call() { } } - synchronized void stop() { + synchronized void stop(final Util.ResultCallback onCompleteListener) { Timber.d("Stopping."); if (es != null) { // We do this in a separate thread because closing the stream involves a network @@ -179,6 +178,9 @@ synchronized void stop() { @Override public void run() { stopSync(); + if (onCompleteListener != null) { + onCompleteListener.onSuccess(null); + } } }); } @@ -192,15 +194,4 @@ private synchronized void stopSync() { es = null; Timber.d("Stopped."); } - - synchronized void restart() { - executor.execute(new Runnable() { - @Override - public void run() { - StreamUpdateProcessor.this.stopSync(); - StreamUpdateProcessor.this.start(); - } - }); - } - -} +} \ No newline at end of file