From e810abe33a4c7302268ec42f7551ce559f4afaa8 Mon Sep 17 00:00:00 2001 From: Pupil Date: Sun, 9 Feb 2020 17:57:18 +0900 Subject: [PATCH] Bug fix --- app/build.gradle | 2 +- app/release/output.json | 2 +- app/src/main/java/xyz/quaver/pupil/util/download/Cache.kt | 8 ++++---- .../java/xyz/quaver/pupil/util/download/DownloadWorker.kt | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index fb5a1b75..bde1eed9 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -20,7 +20,7 @@ android { minSdkVersion 16 targetSdkVersion 29 versionCode 36 - versionName "5.3-beta2" + versionName "5.3-beta3" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" multiDexEnabled true vectorDrawables.useSupportLibrary = true diff --git a/app/release/output.json b/app/release/output.json index 29ec4809..92ee5919 100644 --- a/app/release/output.json +++ b/app/release/output.json @@ -1 +1 @@ -[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":36,"versionName":"5.3-beta2","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}] \ No newline at end of file +[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":36,"versionName":"5.3-beta3","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}] \ No newline at end of file diff --git a/app/src/main/java/xyz/quaver/pupil/util/download/Cache.kt b/app/src/main/java/xyz/quaver/pupil/util/download/Cache.kt index 3fc23428..fdbf3019 100644 --- a/app/src/main/java/xyz/quaver/pupil/util/download/Cache.kt +++ b/app/src/main/java/xyz/quaver/pupil/util/download/Cache.kt @@ -45,7 +45,7 @@ class Cache(context: Context) : ContextWrapper(context) { // Search in this order // Download -> Cache fun getCachedGallery(galleryID: Int) : DocumentFile? { - var file = getDownloadDirectory(this)?.findFile(galleryID.toString()) + var file = getDownloadDirectory(this).findFile(galleryID.toString()) if (file?.exists() == true) return file @@ -192,7 +192,7 @@ class Cache(context: Context) : ContextWrapper(context) { val images = gallery.listFiles() return reader.galleryInfo.indices.map { index -> - images.firstOrNull { file -> file.name?.startsWith(index.toString()) == true } + images.firstOrNull { file -> file.name?.startsWith("%05d".format(index)) == true } } } @@ -213,14 +213,14 @@ class Cache(context: Context) : ContextWrapper(context) { val cache = getCachedGallery(galleryID) if (cache != null) { - val download = getDownloadDirectory(this)!! + val download = getDownloadDirectory(this) if (!download.isParentOf(cache)) { cache.copyRecursively(this, download) cache.deleteRecursively() } } else - getDownloadDirectory(this)?.createDirectory(galleryID.toString()) + getDownloadDirectory(this).createDirectory(galleryID.toString()) } fun isDownloading(galleryID: Int) = getCachedMetadata(galleryID)?.isDownloading == true diff --git a/app/src/main/java/xyz/quaver/pupil/util/download/DownloadWorker.kt b/app/src/main/java/xyz/quaver/pupil/util/download/DownloadWorker.kt index d8852d37..647571b3 100644 --- a/app/src/main/java/xyz/quaver/pupil/util/download/DownloadWorker.kt +++ b/app/src/main/java/xyz/quaver/pupil/util/download/DownloadWorker.kt @@ -312,7 +312,7 @@ class DownloadWorker private constructor(context: Context) : ContextWrapper(cont val ext = call.request().url().encodedPath().split('.').last() - Cache(this@DownloadWorker).putImage(galleryID, "$i.$ext", res) + Cache(this@DownloadWorker).putImage(galleryID, "%05d.%s".format(i, ext), res) progress[galleryID]?.set(i, Float.POSITIVE_INFINITY) }