From 830f79282452eb59bb5ba64b1669766f63fc3ea8 Mon Sep 17 00:00:00 2001 From: len Date: Tue, 22 Nov 2016 16:06:02 +0100 Subject: [PATCH] Fix #541 --- .../tachiyomi/ui/manga/chapter/ChaptersAdapter.kt | 11 +++++++---- .../tachiyomi/ui/manga/chapter/ChaptersFragment.kt | 10 +++++++--- .../tachiyomi/ui/manga/chapter/ChaptersPresenter.kt | 13 ------------- 3 files changed, 14 insertions(+), 20 deletions(-) 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 dd2ffc7c06..b53bc2d248 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 39458dba7c..381bf33ce3 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 b98d6e200c..3d8be2801b 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.