Skip to content

Commit bd9530d

Browse files
committed
Merge remote-tracking branch 'orgin/BiLi_PC_Gamer' into BiLi_PC_Gamer
2 parents aa63393 + 318d8e6 commit bd9530d

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

app/src/main/java/com/hippo/ehviewer/updater/AppUpdater.kt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ class AppUpdater(private val name: String, source: BufferedSource) {
4040

4141

4242
init {
43-
val jsonObject = JSONObject.parseObject(source.readUtf8())
43+
val jsonObject: JSONObject = try {
44+
JSONObject.parseObject(source.readUtf8())
45+
} catch (e: JSONException) {
46+
JSONObject()
47+
}
4448
updateData = jsonObject
4549
}
4650

@@ -129,7 +133,7 @@ class AppUpdater(private val name: String, source: BufferedSource) {
129133
// Save new json data
130134
val tempDataFile = File(dir, "$dataName.tmp")
131135
if (!save(client, dataUrl, tempDataFile)) {
132-
if (manualChecking){
136+
if (manualChecking) {
133137
UpdateDialog(activity).showCheckFailDialog()
134138
}
135139
FileUtils.delete(tempDataFile)
@@ -154,9 +158,10 @@ class AppUpdater(private val name: String, source: BufferedSource) {
154158

155159
if (!needUpdate) {
156160
FileUtils.delete(tempDataFile)
157-
if (manualChecking){
161+
if (manualChecking) {
158162
ContextCompat.getMainExecutor(activity).execute {
159-
Toast.makeText(activity,R.string.update_to_date,Toast.LENGTH_LONG).show()
163+
Toast.makeText(activity, R.string.update_to_date, Toast.LENGTH_LONG)
164+
.show()
160165
}
161166
}
162167
return@execute

0 commit comments

Comments
 (0)