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