Skip to content

Commit afedddc

Browse files
Feature/call listener on error (#151)
* fix bug where if there was a problem with the datafile, we are not calling onStart. Always call onStart even if there was an issue so that the app can respond * added findbugs for crash on API 17. * refactor 'fix'. the stop should not call onStart. It is cleanup after onStart has been called. * remove weird extra space.
1 parent d3a8092 commit afedddc

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

android-sdk/src/main/java/com/optimizely/ab/android/sdk/OptimizelyManager.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,10 @@ public void onStartComplete(UserProfileService userProfileService) {
362362
}
363363
} catch (Exception e) {
364364
logger.error("Unable to build OptimizelyClient instance", e);
365+
if (optimizelyStartListener != null) {
366+
logger.info("Sending Optimizely instance to listener may be null on failure");
367+
optimizelyStartListener.onStart(optimizelyClient);
368+
}
365369
} catch (Error e) {
366370
logger.error("Unable to build OptimizelyClient instance", e);
367371
}

datafile-handler/src/main/java/com/optimizely/ab/android/datafile_handler/DatafileLoader.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,15 @@ protected void onPostExecute(@Nullable String dataFile) {
166166
if (dataFile == null || !dataFile.isEmpty()) {
167167
datafileLoader.notify(datafileLoadedListener, dataFile);
168168
}
169+
169170
datafileService.stop();
171+
172+
if (datafileLoader.hasNotifiedListener) {
173+
// we're done here. meaning, we have notified you of either the cache coming in or of a new file.
174+
// so, we are notifying you that the data file service has stopped.
175+
datafileLoadedListener.onStop(datafileService.getApplicationContext());
176+
}
177+
170178
}
171179
}
172180
}

shared/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ dependencies {
5656
compile "com.optimizely.ab:core-api:$java_core_ver"
5757
compile "com.google.code.gson:gson:$gson_ver"
5858
compile "com.android.support.test.espresso:espresso-idling-resource:$espresso_ver"
59+
compile group: 'com.google.code.findbugs', name: 'jsr305', version: '2.0.1'
5960
provided "com.android.support:support-annotations:$support_annotations_ver"
6061

6162
testCompile "junit:junit:$junit_ver"

0 commit comments

Comments
 (0)