From 799ac037e64817ec48a085ad9f81012b715c79b4 Mon Sep 17 00:00:00 2001 From: Jays2Kings Date: Mon, 3 May 2021 13:37:21 -0400 Subject: [PATCH] Fix hideStartReadingButton setting not updating in real time --- .../tachiyomi/data/preference/PreferencesHelper.kt | 2 +- .../kanade/tachiyomi/ui/library/LibraryController.kt | 11 ++++++++--- .../eu/kanade/tachiyomi/ui/library/LibraryItem.kt | 3 +-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt index 0796596797..f16b80a454 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt @@ -357,7 +357,7 @@ class PreferencesHelper(val context: Context) { fun unreadBadgeType() = flowPrefs.getInt("unread_badge_type", 2) - fun hideStartReadingButton() = rxPrefs.getBoolean("hide_reading_button", false) + fun hideStartReadingButton() = flowPrefs.getBoolean("hide_reading_button", false) fun alwaysShowChapterTransition() = flowPrefs.getBoolean(Keys.alwaysShowChapterTransition, true) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt index ee71edfa7e..abcb752a75 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt @@ -832,8 +832,7 @@ class LibraryController( listOf( preferences.libraryLayout(), preferences.uniformGrid(), - preferences.gridSize(), - preferences.unreadBadgeType() + preferences.gridSize() ).forEach { it.asFlow() .drop(1) @@ -842,6 +841,12 @@ class LibraryController( } .launchIn(viewScope) } + preferences.hideStartReadingButton().asFlow() + .drop(1) + .onEach { + adapter.notifyDataSetChanged() + } + .launchIn(viewScope) } override fun onChangeStarted(handler: ControllerChangeHandler, type: ControllerChangeType) { @@ -1081,7 +1086,7 @@ class LibraryController( destroyActionModeIfNeeded() } - fun reattachAdapter() { + private fun reattachAdapter() { libraryLayout = preferences.libraryLayout().get() setRecyclerLayout() val position = diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryItem.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryItem.kt index c435895279..6d981e4139 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryItem.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryItem.kt @@ -15,7 +15,6 @@ import eu.davidea.flexibleadapter.items.IFlexible import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.models.LibraryManga import eu.kanade.tachiyomi.data.preference.PreferencesHelper -import eu.kanade.tachiyomi.data.preference.getOrDefault import eu.kanade.tachiyomi.databinding.MangaGridItemBinding import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.util.system.dpToPx @@ -43,7 +42,7 @@ class LibraryItem( get() = preferences.libraryLayout().get() val hideReadingButton: Boolean - get() = preferences.hideStartReadingButton().getOrDefault() + get() = preferences.hideStartReadingButton().get() override fun getLayoutRes(): Int { return if (libraryLayout == 0 || manga.isBlank()) {