mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
Add custom range for remove downloads in manga details (#1388)
* Add custom range for remove downloads in manga details * Add remove custom range to onLongClick
This commit is contained in:
parent
335242741d
commit
655ac93a56
2 changed files with 18 additions and 2 deletions
|
@ -798,6 +798,10 @@ class MangaDetailsController :
|
|||
}
|
||||
when (rangeMode) {
|
||||
RangeMode.Download -> downloadChapters(chapterList)
|
||||
RangeMode.RemoveDownload -> massDeleteChapters(
|
||||
chapterList.filter { it.status != Download.State.NOT_DOWNLOADED },
|
||||
false,
|
||||
)
|
||||
RangeMode.Read -> markAsRead(chapterList)
|
||||
RangeMode.Unread -> markAsUnread(chapterList)
|
||||
}
|
||||
|
@ -1082,7 +1086,7 @@ class MangaDetailsController :
|
|||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.show()
|
||||
}
|
||||
R.id.remove_all, R.id.remove_read, R.id.remove_non_bookmarked -> massDeleteChapters(item.itemId)
|
||||
R.id.remove_all, R.id.remove_read, R.id.remove_non_bookmarked, R.id.remove_custom -> massDeleteChapters(item.itemId)
|
||||
R.id.action_mark_all_as_unread -> {
|
||||
activity!!.materialAlertDialog()
|
||||
.setMessage(R.string.mark_all_chapters_as_unread)
|
||||
|
@ -1180,6 +1184,11 @@ class MangaDetailsController :
|
|||
R.id.remove_all -> presenter.allChapters
|
||||
R.id.remove_non_bookmarked -> presenter.allChapters.filter { !it.bookmark }
|
||||
R.id.remove_read -> presenter.allChapters.filter { it.read }
|
||||
R.id.remove_custom -> {
|
||||
createActionModeIfNeeded()
|
||||
rangeMode = RangeMode.RemoveDownload
|
||||
return
|
||||
}
|
||||
else -> emptyList()
|
||||
}.filter { it.isDownloaded }
|
||||
if (chaptersToDelete.isNotEmpty() || choice == R.id.remove_all) {
|
||||
|
@ -1314,7 +1323,10 @@ class MangaDetailsController :
|
|||
|
||||
override fun startDownloadRange(position: Int) {
|
||||
createActionModeIfNeeded()
|
||||
rangeMode = RangeMode.Download
|
||||
val chapterItem = (adapter?.getItem(position) as? ChapterItem) ?: return
|
||||
rangeMode = if (chapterItem.status in listOf(Download.State.NOT_DOWNLOADED, Download.State.ERROR)) {
|
||||
RangeMode.Download
|
||||
} else RangeMode.RemoveDownload
|
||||
onItemClick(null, position)
|
||||
}
|
||||
|
||||
|
@ -1722,6 +1734,7 @@ class MangaDetailsController :
|
|||
|
||||
private enum class RangeMode {
|
||||
Download,
|
||||
RemoveDownload,
|
||||
Read,
|
||||
Unread
|
||||
}
|
||||
|
|
|
@ -64,6 +64,9 @@
|
|||
<item
|
||||
android:id="@+id/remove_read"
|
||||
android:title="@string/all_read_chapters" />
|
||||
<item
|
||||
android:id="@+id/remove_custom"
|
||||
android:title="@string/custom_range" />
|
||||
</menu>
|
||||
</item>
|
||||
<item
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue