This commit is contained in:
Pupil
2020-02-09 17:57:18 +09:00
parent 6172a73719
commit e810abe33a
4 changed files with 7 additions and 7 deletions

View File

@@ -20,7 +20,7 @@ android {
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 29 targetSdkVersion 29
versionCode 36 versionCode 36
versionName "5.3-beta2" versionName "5.3-beta3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true multiDexEnabled true
vectorDrawables.useSupportLibrary = true vectorDrawables.useSupportLibrary = true

View File

@@ -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":{}}] [{"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":{}}]

View File

@@ -45,7 +45,7 @@ class Cache(context: Context) : ContextWrapper(context) {
// Search in this order // Search in this order
// Download -> Cache // Download -> Cache
fun getCachedGallery(galleryID: Int) : DocumentFile? { fun getCachedGallery(galleryID: Int) : DocumentFile? {
var file = getDownloadDirectory(this)?.findFile(galleryID.toString()) var file = getDownloadDirectory(this).findFile(galleryID.toString())
if (file?.exists() == true) if (file?.exists() == true)
return file return file
@@ -192,7 +192,7 @@ class Cache(context: Context) : ContextWrapper(context) {
val images = gallery.listFiles() val images = gallery.listFiles()
return reader.galleryInfo.indices.map { index -> 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) val cache = getCachedGallery(galleryID)
if (cache != null) { if (cache != null) {
val download = getDownloadDirectory(this)!! val download = getDownloadDirectory(this)
if (!download.isParentOf(cache)) { if (!download.isParentOf(cache)) {
cache.copyRecursively(this, download) cache.copyRecursively(this, download)
cache.deleteRecursively() cache.deleteRecursively()
} }
} else } else
getDownloadDirectory(this)?.createDirectory(galleryID.toString()) getDownloadDirectory(this).createDirectory(galleryID.toString())
} }
fun isDownloading(galleryID: Int) = getCachedMetadata(galleryID)?.isDownloading == true fun isDownloading(galleryID: Int) = getCachedMetadata(galleryID)?.isDownloading == true

View File

@@ -312,7 +312,7 @@ class DownloadWorker private constructor(context: Context) : ContextWrapper(cont
val ext = val ext =
call.request().url().encodedPath().split('.').last() 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) progress[galleryID]?.set(i, Float.POSITIVE_INFINITY)
} }