diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersAdapter.kt index dd2ffc7c0..b53bc2d24 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersAdapter.kt @@ -11,6 +11,13 @@ class ChaptersAdapter(val fragment: ChaptersFragment) : FlexibleAdapter + get() = mItems + set(value) { + mItems = value + notifyDataSetChanged() + } + override fun updateDataSet(param: String) { } @@ -32,8 +39,4 @@ class ChaptersAdapter(val fragment: ChaptersFragment) : FlexibleAdapter) { - mItems = chapters - notifyDataSetChanged() - } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersFragment.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersFragment.kt index 39458dba7..381bf33ce 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersFragment.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersFragment.kt @@ -182,7 +182,7 @@ class ChaptersFragment : BaseRxFragment(), ActionMode.Callbac initialFetchChapters() destroyActionModeIfNeeded() - adapter.setItems(chapters) + adapter.items = chapters } private fun initialFetchChapters() { @@ -360,7 +360,11 @@ class ChaptersFragment : BaseRxFragment(), ActionMode.Callbac } fun markPreviousAsRead(chapter: ChapterModel) { - presenter.markPreviousChaptersAsRead(chapter) + val chapters = if (presenter.sortDescending()) adapter.items.reversed() else adapter.items + val chapterPos = chapters.indexOf(chapter) + if (chapterPos != -1) { + presenter.markChaptersRead(chapters.take(chapterPos), true) + } } fun downloadChapters(chapters: List) { @@ -370,7 +374,7 @@ class ChaptersFragment : BaseRxFragment(), ActionMode.Callbac fun bookmarkChapters(chapters: List, bookmarked: Boolean) { destroyActionModeIfNeeded() - presenter.bookmarkChapters(chapters,bookmarked) + presenter.bookmarkChapters(chapters, bookmarked) } fun deleteChapters(chapters: List) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersPresenter.kt index b98d6e200..3d8be2801 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersPresenter.kt @@ -288,19 +288,6 @@ class ChaptersPresenter : BasePresenter() { .subscribe() } - /** - * Mark the previous chapters to the selected one as read. - * @param chapter the selected chapter. - */ - fun markPreviousChaptersAsRead(chapter: ChapterModel) { - Observable.from(chapters) - .filter { it.isRecognizedNumber && it.chapter_number < chapter.chapter_number } - .doOnNext { it.read = true } - .toList() - .flatMap { db.updateChaptersProgress(it).asRxObservable() } - .subscribe() - } - /** * Downloads the given list of chapters with the manager. * @param chapters the list of chapters to download.