App crash fix
This commit is contained in:
@@ -13,8 +13,8 @@ android {
|
|||||||
applicationId "xyz.quaver.pupil"
|
applicationId "xyz.quaver.pupil"
|
||||||
minSdkVersion 16
|
minSdkVersion 16
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
versionCode 21
|
versionCode 22
|
||||||
versionName "3.0"
|
versionName "3.0.1"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
vectorDrawables.useSupportLibrary = true
|
vectorDrawables.useSupportLibrary = true
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":21,"versionName":"3.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
|
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":22,"versionName":"3.0.1","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
|
||||||
@@ -95,6 +95,13 @@ class GalleryBlockAdapter(private val galleries: List<Pair<GalleryBlock, Deferre
|
|||||||
val readerCache = { File(getCachedGallery(context, galleryBlock.id), "reader.json") }
|
val readerCache = { File(getCachedGallery(context, galleryBlock.id), "reader.json") }
|
||||||
val imageCache = { File(getCachedGallery(context, galleryBlock.id), "images") }
|
val imageCache = { File(getCachedGallery(context, galleryBlock.id), "images") }
|
||||||
|
|
||||||
|
try {
|
||||||
|
Json(JsonConfiguration.Stable)
|
||||||
|
.parse(Reader.serializer(), readerCache.invoke().readText())
|
||||||
|
} catch(e: Exception) {
|
||||||
|
readerCache.invoke().delete()
|
||||||
|
}
|
||||||
|
|
||||||
if (readerCache.invoke().exists()) {
|
if (readerCache.invoke().exists()) {
|
||||||
val reader = Json(JsonConfiguration.Stable)
|
val reader = Json(JsonConfiguration.Stable)
|
||||||
.parse(Reader.serializer(), readerCache.invoke().readText())
|
.parse(Reader.serializer(), readerCache.invoke().readText())
|
||||||
@@ -146,8 +153,6 @@ class GalleryBlockAdapter(private val galleries: List<Pair<GalleryBlock, Deferre
|
|||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
view.galleryblock_progress_complete.visibility = View.INVISIBLE
|
view.galleryblock_progress_complete.visibility = View.INVISIBLE
|
||||||
|
|
||||||
null
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,6 +110,12 @@ class GalleryDownloader(
|
|||||||
//Check cache
|
//Check cache
|
||||||
val cache = File(getCachedGallery(this@GalleryDownloader, galleryID), "reader.json")
|
val cache = File(getCachedGallery(this@GalleryDownloader, galleryID), "reader.json")
|
||||||
|
|
||||||
|
try {
|
||||||
|
json.parse(serializer, cache.readText())
|
||||||
|
} catch(e: Exception) {
|
||||||
|
cache.delete()
|
||||||
|
}
|
||||||
|
|
||||||
if (cache.exists()) {
|
if (cache.exists()) {
|
||||||
val cached = json.parse(serializer, cache.readText())
|
val cached = json.parse(serializer, cache.readText())
|
||||||
|
|
||||||
|
|||||||
@@ -40,19 +40,25 @@ fun checkUpdate(url: String) : JsonObject? {
|
|||||||
|
|
||||||
return releases.firstOrNull {
|
return releases.firstOrNull {
|
||||||
if (BuildConfig.PRERELEASE) {
|
if (BuildConfig.PRERELEASE) {
|
||||||
BuildConfig.VERSION_NAME != it.jsonObject["tag_name"]?.content
|
true
|
||||||
} else {
|
} else {
|
||||||
it.jsonObject["prerelease"]?.boolean == false &&
|
it.jsonObject["prerelease"]?.boolean == false
|
||||||
BuildConfig.VERSION_NAME != (it.jsonObject["tag_name"]?.content ?: "")
|
|
||||||
}
|
}
|
||||||
}?.jsonObject
|
}?.let {
|
||||||
|
if (it.jsonObject["tag_name"]?.content == BuildConfig.VERSION_NAME)
|
||||||
|
null
|
||||||
|
else
|
||||||
|
it.jsonObject
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getApkUrl(releases: JsonObject) : Pair<String?, String?>? {
|
fun getApkUrl(releases: JsonObject) : Pair<String?, String?>? {
|
||||||
releases["assets"]?.jsonArray?.forEach {
|
return releases["assets"]?.jsonArray?.firstOrNull {
|
||||||
if (Regex("Pupil-v(\\d+\\.)+\\d+\\.apk").matches(it.jsonObject["name"]?.content ?: ""))
|
Regex("Pupil-v(\\d+\\.)+\\d+\\.apk").matches(it.jsonObject["name"]?.content ?: "")
|
||||||
return Pair(it.jsonObject["browser_download_url"]?.content, it.jsonObject["name"]?.content)
|
}.let {
|
||||||
|
if (it == null)
|
||||||
|
null
|
||||||
|
else
|
||||||
|
Pair(it.jsonObject["browser_download_url"]?.content, it.jsonObject["name"]?.content)
|
||||||
}
|
}
|
||||||
|
|
||||||
return null
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user