Skip to content

Commit

Permalink
修复RuntimeInfo初始化失败
Browse files Browse the repository at this point in the history
  • Loading branch information
constanline committed Oct 11, 2023
1 parent ebbc54c commit 9050380
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
minSdk 21
//noinspection ExpiredTargetSdkVersion
targetSdk 29
versionCode 69
versionName "1.2.2"
versionCode 70
versionName "1.2.2-fix1"
}
buildTypes {
release {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,20 @@ private RuntimeInfo() {
String content = FileUtils.readFromFile(FileUtils.runtimeInfoFile());
try {
joAll = new JSONObject(content);
} catch (Exception ignored) {
joAll = new JSONObject();
}
try {
if (!joAll.has(userId)) {
joAll.put(userId, new JSONObject());
}
} catch (Exception ignored) {
}
try {
joCurrent = joAll.getJSONObject(userId);
} catch (Exception ignored) { }
} catch (Exception ignored) {
joCurrent = new JSONObject();
}
}

public void save() {
Expand All @@ -66,6 +75,7 @@ public Long getLong(RuntimeInfoKey key) {
public void put(RuntimeInfoKey key, Object value) {
try {
joCurrent.put(key.name(), value);
joAll.put(userId, joCurrent);
} catch (JSONException e) {
Log.i(TAG, "put err:");
Log.printStackTrace(TAG, e);
Expand Down

0 comments on commit 9050380

Please sign in to comment.