add start download now (#5386)

* add start download now

download now for selected chapter
from j2k

Co-Authored-By: Jays2Kings <jays@outlook.com>

* change string to action

* move to bottom

* oopsie

Co-authored-by: Jays2Kings <jays@outlook.com>
This commit is contained in:
Riztard Lanthorn
2021-06-19 23:36:29 +07:00
committed by GitHub
parent 848d387ec4
commit 05771ddf6d
11 changed files with 66 additions and 1 deletions
@@ -1057,6 +1057,11 @@ class MangaController :
Timber.e(error)
}
override fun startDownloadNow(position: Int) {
val chapter = chaptersAdapter?.getItem(position) ?: return
presenter.startDownloadingNow(chapter)
}
// OVERFLOW MENU DIALOGS
private fun downloadChapters(choice: Int) {
@@ -517,6 +517,10 @@ class MangaPresenter(
}
}
fun startDownloadingNow(chapter: Chapter) {
downloadManager.startDownloadNow(chapter)
}
/**
* Mark the selected chapter list as read/unread.
* @param selectedChapters the list of selected chapters.
@@ -26,9 +26,16 @@ open class BaseChapterHolder(
// Download.State.DOWNLOADING, Download.State.QUEUE
findItem(R.id.cancel_download).isVisible = item.status != Download.State.DOWNLOADED
// Download.State.QUEUE
findItem(R.id.start_download).isVisible = item.status == Download.State.QUEUE
},
onMenuItemClick = {
adapter.clickListener.deleteChapter(position)
if (itemId == R.id.start_download) {
adapter.clickListener.startDownloadNow(position)
} else {
adapter.clickListener.deleteChapter(position)
}
}
)
}
@@ -18,5 +18,6 @@ abstract class BaseChaptersAdapter<T : IFlexible<*>>(
interface OnChapterClickListener {
fun downloadChapter(position: Int)
fun deleteChapter(position: Int)
fun startDownloadNow(position: Int)
}
}