mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-05 01:15:14 +01:00
Implements Download next 1/5/10/all chapters for issue #42
This commit is contained in:
parent
bf1fdda651
commit
abbc7b572a
@ -27,7 +27,6 @@ import nucleus.factory.RequiresPresenter
|
||||
import rx.Observable
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
import rx.schedulers.Schedulers
|
||||
import java.util.*
|
||||
|
||||
@RequiresPresenter(ChaptersPresenter::class)
|
||||
class ChaptersFragment : BaseRxFragment<ChaptersPresenter>(), ActionMode.Callback, FlexibleViewHolder.OnListItemClickListener {
|
||||
@ -217,23 +216,41 @@ class ChaptersFragment : BaseRxFragment<ChaptersPresenter>(), ActionMode.Callbac
|
||||
|
||||
private fun showDownloadDialog() {
|
||||
// Get available modes
|
||||
val modes = listOf(getString(R.string.download_all), getString(R.string.download_unread))
|
||||
val modes = listOf(getString(R.string.download_1), getString(R.string.download_5), getString(R.string.download_10),
|
||||
getString(R.string.download_unread), getString(R.string.download_all))
|
||||
|
||||
MaterialDialog.Builder(activity)
|
||||
.title(R.string.manga_download)
|
||||
.negativeText(android.R.string.cancel)
|
||||
.items(modes)
|
||||
.itemsCallback { dialog, view, i, charSequence ->
|
||||
val chapters = ArrayList<Chapter>()
|
||||
var chapters: MutableList<Chapter> = arrayListOf()
|
||||
|
||||
// i = 0: Download 1
|
||||
// i = 1: Download 5
|
||||
// i = 2: Download 10
|
||||
// i = 3: Download unread
|
||||
// i = 4: Download all
|
||||
for (chapter in presenter.chapters) {
|
||||
if (!chapter.isDownloaded) {
|
||||
if (i == 0 || (i == 1 && !chapter.read)) {
|
||||
if (i == 4 || (i != 4 && !chapter.read)) {
|
||||
chapters.add(chapter)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (chapters.size > 0) {
|
||||
when (i) {
|
||||
// Set correct chapters size if desired
|
||||
0 -> chapters = chapters.subList(0, 1)
|
||||
1 -> {
|
||||
if (chapters.size >= 5)
|
||||
chapters = chapters.subList(0, 5)
|
||||
}
|
||||
2 -> {
|
||||
if (chapters.size >= 10)
|
||||
chapters = chapters.subList(0, 10)
|
||||
}
|
||||
}
|
||||
onDownload(Observable.from(chapters))
|
||||
}
|
||||
}
|
||||
|
@ -208,6 +208,9 @@
|
||||
<string name="show_title">Show title</string>
|
||||
<string name="show_chapter_number">Show chapter number</string>
|
||||
<string name="manga_download">Download</string>
|
||||
<string name="download_1">Download next chapter</string>
|
||||
<string name="download_5">Download next 5 chapters</string>
|
||||
<string name="download_10">Download next 10 chapters</string>
|
||||
<string name="download_all">Download all</string>
|
||||
<string name="download_unread">Download unread</string>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user