Skip to content

Commit b8c5225

Browse files
committed
parse version earlier
1 parent 9d03023 commit b8c5225

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

core/src/main/java/io/snabble/sdk/Snabble.java

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,22 @@ public void setup(Application app, Config config, final SetupCompletionListener
5454
return;
5555
}
5656

57+
String version = config.versionName;
58+
if (version == null) {
59+
try {
60+
PackageInfo pInfo = app.getPackageManager().getPackageInfo(app.getPackageName(), 0);
61+
if (pInfo != null && pInfo.versionName != null) {
62+
version = pInfo.versionName.toLowerCase(Locale.ROOT).replace(" ", "");
63+
} else {
64+
version = "1.0";
65+
}
66+
} catch (PackageManager.NameNotFoundException e) {
67+
version = "1.0";
68+
}
69+
}
70+
71+
versionName = version;
72+
5773
okHttpClient = OkHttpClientFactory.createOkHttpClient(app, null);
5874
tokenRegistry = new TokenRegistry(okHttpClient, config.appId, config.secret);
5975

@@ -71,21 +87,6 @@ public void setup(Application app, Config config, final SetupCompletionListener
7187
config.endpointBaseUrl = "https://" + config.endpointBaseUrl;
7288
}
7389

74-
String version = config.versionName;
75-
if (version == null) {
76-
try {
77-
PackageInfo pInfo = app.getPackageManager().getPackageInfo(app.getPackageName(), 0);
78-
if (pInfo != null && pInfo.versionName != null) {
79-
version = pInfo.versionName.toLowerCase(Locale.ROOT).replace(" ", "");
80-
} else {
81-
version = "1.0";
82-
}
83-
} catch (PackageManager.NameNotFoundException e) {
84-
version = "1.0";
85-
}
86-
}
87-
88-
versionName = version;
8990
metadataUrl = absoluteUrl("/metadata/app/" + config.appId + "/android/" + version);
9091

9192
this.metadataDownloader = new MetadataDownloader(okHttpClient, config.bundledMetadataAssetPath);

sample/src/main/java/io/snabble/testapp/App.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public void init(final InitCallback callback) {
5959
snabble.setup(this, config, new Snabble.SetupCompletionListener() {
6060
@Override
6161
public void onReady() {
62-
project = snabble.getProjects().get(2);
62+
project = snabble.getProjects().get(0);
6363

6464
// registers this sdk instance globally for use with ui components
6565
SnabbleUI.useProject(project);

0 commit comments

Comments
 (0)