diff --git a/app/src/main/java/ani/dantotsu/download/manga/MangaDownloaderService.kt b/app/src/main/java/ani/dantotsu/download/manga/MangaDownloaderService.kt index ecf223bff11..95b3e565efc 100644 --- a/app/src/main/java/ani/dantotsu/download/manga/MangaDownloaderService.kt +++ b/app/src/main/java/ani/dantotsu/download/manga/MangaDownloaderService.kt @@ -187,7 +187,8 @@ class MangaDownloaderService : Service() { true } - val deferredList = mutableListOf>() + //val deferredList = mutableListOf>() + val deferredMap = mutableMapOf>() builder.setContentText("Downloading ${task.title} - ${task.chapter}") if (notifi) { notificationManager.notify(NOTIFICATION_ID, builder.build()) @@ -196,13 +197,12 @@ class MangaDownloaderService : Service() { // Loop through each ImageData object from the task var farthest = 0 for ((index, image) in task.imageData.withIndex()) { - if (deferredList.size >= task.simultaneousDownloads) { - deferredList.awaitAll() - deferredList.clear() + if (deferredMap.size >= task.simultaneousDownloads) { + deferredMap.values.awaitAll() + deferredMap.clear() } - val currentIndex = index // Capture the current index - val deferred = async(Dispatchers.IO) { + deferredMap[index] = async(Dispatchers.IO) { var bitmap: Bitmap? = null var retryCount = 0 @@ -216,7 +216,7 @@ class MangaDownloaderService : Service() { } if (bitmap != null) { - saveToDisk("$currentIndex.jpg", bitmap, task.title, task.chapter) + saveToDisk("$index.jpg", bitmap, task.title, task.chapter) } farthest++ builder.setProgress(task.imageData.size, farthest, false) @@ -230,12 +230,10 @@ class MangaDownloaderService : Service() { bitmap } - - deferredList.add(deferred) } // Wait for any remaining deferred to complete - deferredList.awaitAll() + deferredMap.values.awaitAll() builder.setContentText("${task.title} - ${task.chapter} Download complete") .setProgress(0, 0, false) diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index ba6b8cfcf19..adffeae90a3 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -90,74 +90,67 @@ tools:ignore="TextContrastCheck" /> - + - - - - - - - - - - - - - - - + + + + + + + + + + + + @@ -228,7 +221,7 @@ android:fontFamily="@font/poppins_bold" android:gravity="center" android:padding="16dp" - android:text="Requires Android 12+" + android:text="@string/requires_android_12" android:textColor="?attr/colorSecondary" /> Purge anime downloads Purge Manga Downloads Purge Novel Downloads + Requires Android 12+