From 9e36dccf4d6e04df349c6e017d1ff199d8310788 Mon Sep 17 00:00:00 2001 From: Jay Date: Sun, 9 Feb 2020 22:16:08 -0800 Subject: [PATCH] Recent Read Controller is no longer Rx Unfortunately to fix #72, an rx observer is needed since the reader adds to the db after the recents is back in view --- .../tachiyomi/ui/recently_read/RecentlyReadController.kt | 8 +++++--- .../tachiyomi/ui/recently_read/RecentlyReadPresenter.kt | 5 ++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadController.kt index 983cc5ab1e..cbea59b673 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadController.kt @@ -105,16 +105,18 @@ class RecentlyReadController(bundle: Bundle? = null) : BaseController(bundle), * * @param mangaHistory list of manga history */ - fun onNextManga(mangaHistory: List) { + fun onNextManga(mangaHistory: List, freshList:Boolean = false) { val adapter = adapter ?: return adapter.updateDataSet(mangaHistory) adapter.onLoadMoreComplete(null) - if (recentItems == null) + if (recentItems == null || adapter.endlessTargetCount == 1) resetProgressItem() + else if (freshList && mangaHistory.size == recentItems!!.size) + onAddPageError() recentItems = mangaHistory.toMutableList() } - fun onAddPageError() { + private fun onAddPageError() { adapter?.onLoadMoreComplete(null) adapter?.endlessTargetCount = 1 } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadPresenter.kt index bcf73ba09b..30c0fbbb99 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadPresenter.kt @@ -55,14 +55,13 @@ class RecentlyReadPresenter(private val view: RecentlyReadController) { } fun observe() { - readerSubscription?.unsubscribe() val cal = Calendar.getInstance() cal.time = Date() cal.add(Calendar.YEAR, -50) - readerSubscription = db.getRecentMangaLimit(cal.time, lastCount, "").asRxObservable().map { + db.getRecentMangaLimit(cal.time, lastCount, "").asRxObservable().map { val items = it.map(::RecentlyReadItem) launchUI { - view.onNextManga(items) + view.onNextManga(items, false) } }.observeOn(Schedulers.io()).skip(1).take(1).subscribe() }