Skip to content

Commit 0ee8c80

Browse files
Hike background test fix
1 parent 3903904 commit 0ee8c80

File tree

1 file changed

+36
-37
lines changed

1 file changed

+36
-37
lines changed

AndroidSDKCore/src/main/java/com/leanplum/Leanplum.java

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -552,48 +552,47 @@ static synchronized void start(final Context context, final String userId,
552552
}
553553
return;
554554
}
555-
556-
initializedMessageTemplates = true;
557-
MessageTemplates.register(Leanplum.getContext());
558-
559-
LeanplumInternal.setStartedInBackground(actuallyInBackground);
560-
561-
final Map<String, ?> validAttributes = LeanplumInternal.validateAttributes(attributes,
562-
"userAttributes", true);
563-
LeanplumInternal.setCalledStart(true);
564-
565-
if (validAttributes != null) {
566-
LeanplumInternal.getUserAttributeChanges().add(validAttributes);
567-
}
568-
569-
RequestOld.loadToken();
570-
VarCache.setSilent(true);
571-
VarCache.loadDiffs();
572-
VarCache.setSilent(false);
573-
LeanplumInbox.getInstance().load();
574-
575-
// Setup class members.
576-
VarCache.onUpdate(new CacheUpdateBlock() {
577-
@Override
578-
public void updateCache() {
579-
triggerVariablesChanged();
580-
if (RequestOld.numPendingDownloads() == 0) {
581-
triggerVariablesChangedAndNoDownloadsPending();
582-
}
583-
}
584-
});
585-
RequestOld.onNoPendingDownloads(new RequestOld.NoPendingDownloadsCallback() {
586-
@Override
587-
public void noPendingDownloads() {
588-
triggerVariablesChangedAndNoDownloadsPending();
589-
}
590-
});
591-
592555
// Reduce latency by running the rest of the start call in a background thread.
593556
Util.executeAsyncTask(true, new AsyncTask<Void, Void, Void>() {
594557
@Override
595558
protected Void doInBackground(Void... params) {
596559
try {
560+
initializedMessageTemplates = true;
561+
MessageTemplates.register(Leanplum.getContext());
562+
563+
LeanplumInternal.setStartedInBackground(actuallyInBackground);
564+
565+
final Map<String, ?> validAttributes = LeanplumInternal.validateAttributes(attributes,
566+
"userAttributes", true);
567+
LeanplumInternal.setCalledStart(true);
568+
569+
if (validAttributes != null) {
570+
LeanplumInternal.getUserAttributeChanges().add(validAttributes);
571+
}
572+
573+
RequestOld.loadToken();
574+
VarCache.setSilent(true);
575+
VarCache.loadDiffs();
576+
VarCache.setSilent(false);
577+
LeanplumInbox.getInstance().load();
578+
579+
// Setup class members.
580+
VarCache.onUpdate(new CacheUpdateBlock() {
581+
@Override
582+
public void updateCache() {
583+
triggerVariablesChanged();
584+
if (RequestOld.numPendingDownloads() == 0) {
585+
triggerVariablesChangedAndNoDownloadsPending();
586+
}
587+
}
588+
});
589+
RequestOld.onNoPendingDownloads(new RequestOld.NoPendingDownloadsCallback() {
590+
@Override
591+
public void noPendingDownloads() {
592+
triggerVariablesChangedAndNoDownloadsPending();
593+
}
594+
});
595+
597596
startHelper(userId, validAttributes, actuallyInBackground);
598597
} catch (Throwable t) {
599598
Util.handleException(t);

0 commit comments

Comments
 (0)