Bug fix
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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":{}}]
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user