offline manga order fix (again)
This commit is contained in:
parent
33bb60baad
commit
431617e6b5
3 changed files with 63 additions and 71 deletions
|
@ -187,7 +187,8 @@ class MangaDownloaderService : Service() {
|
|||
true
|
||||
}
|
||||
|
||||
val deferredList = mutableListOf<Deferred<Bitmap?>>()
|
||||
//val deferredList = mutableListOf<Deferred<Bitmap?>>()
|
||||
val deferredMap = mutableMapOf<Int, Deferred<Bitmap?>>()
|
||||
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)
|
||||
|
|
|
@ -90,74 +90,67 @@
|
|||
tools:ignore="TextContrastCheck" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/settingsThemeContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="8dp"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="8dp"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardBackgroundColor="@color/nav_bg_inv"
|
||||
app:cardCornerRadius="16dp"
|
||||
app:cardElevation="0dp">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardBackgroundColor="@color/nav_bg_inv"
|
||||
app:cardCornerRadius="16dp"
|
||||
app:cardElevation="0dp">
|
||||
<ImageButton
|
||||
android:id="@+id/settingsUiLight"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="64dp"
|
||||
android:alpha="0.33"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:src="@drawable/ic_round_brightness_high_24"
|
||||
app:tint="?attr/colorOnBackground"
|
||||
tools:ignore="ContentDescription,SpeakableTextPresentCheck,ImageContrastCheck,DuplicateSpeakableTextCheck" />
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/settingsUiLight"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="64dp"
|
||||
android:alpha="0.33"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:src="@drawable/ic_round_brightness_high_24"
|
||||
app:tint="?attr/colorOnBackground"
|
||||
tools:ignore="ContentDescription,SpeakableTextPresentCheck,ImageContrastCheck,DuplicateSpeakableTextCheck" />
|
||||
</androidx.cardview.widget.CardView>
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardBackgroundColor="@color/nav_bg_inv"
|
||||
app:cardCornerRadius="16dp"
|
||||
app:cardElevation="0dp">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardBackgroundColor="@color/nav_bg_inv"
|
||||
app:cardCornerRadius="16dp"
|
||||
app:cardElevation="0dp">
|
||||
<ImageButton
|
||||
android:id="@+id/settingsUiDark"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="64dp"
|
||||
android:alpha="0.33"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:scaleX="-1"
|
||||
android:src="@drawable/ic_round_brightness_4_24"
|
||||
app:tint="?attr/colorOnBackground"
|
||||
tools:ignore="ContentDescription,SpeakableTextPresentCheck,ImageContrastCheck" />
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/settingsUiDark"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="64dp"
|
||||
android:alpha="0.33"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:scaleX="-1"
|
||||
android:src="@drawable/ic_round_brightness_4_24"
|
||||
app:tint="?attr/colorOnBackground"
|
||||
tools:ignore="ContentDescription,SpeakableTextPresentCheck,ImageContrastCheck" />
|
||||
</androidx.cardview.widget.CardView>
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardBackgroundColor="@color/nav_bg_inv"
|
||||
app:cardCornerRadius="16dp"
|
||||
app:cardElevation="0dp">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardBackgroundColor="@color/nav_bg_inv"
|
||||
app:cardCornerRadius="16dp"
|
||||
app:cardElevation="0dp">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/settingsUiAuto"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="64dp"
|
||||
android:alpha="0.33"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:src="@drawable/ic_round_brightness_auto_24"
|
||||
app:tint="?attr/colorOnBackground"
|
||||
tools:ignore="ContentDescription,SpeakableTextPresentCheck,ImageContrastCheck" />
|
||||
</androidx.cardview.widget.CardView>
|
||||
</LinearLayout>
|
||||
<ImageButton
|
||||
android:id="@+id/settingsUiAuto"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="64dp"
|
||||
android:alpha="0.33"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:src="@drawable/ic_round_brightness_auto_24"
|
||||
app:tint="?attr/colorOnBackground"
|
||||
tools:ignore="ContentDescription,SpeakableTextPresentCheck,ImageContrastCheck" />
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -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" />
|
||||
|
||||
<com.google.android.material.materialswitch.MaterialSwitch
|
||||
|
@ -768,10 +761,10 @@
|
|||
android:text="@string/downloadInSd"
|
||||
android:textAlignment="viewStart"
|
||||
android:textColor="?attr/colorOnBackground"
|
||||
android:visibility="gone"
|
||||
app:cornerRadius="0dp"
|
||||
app:drawableTint="?attr/colorPrimary"
|
||||
app:showText="false"
|
||||
android:visibility="gone"
|
||||
app:thumbTint="@color/button_switch_track" />
|
||||
|
||||
<View
|
||||
|
|
|
@ -650,5 +650,6 @@
|
|||
<string name="purge_anime_downloads">Purge anime downloads</string>
|
||||
<string name="purge_manga_downloads">Purge Manga Downloads</string>
|
||||
<string name="purge_novel_downloads">Purge Novel Downloads</string>
|
||||
<string name="requires_android_12">Requires Android 12+</string>
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue