Fix library column setting jumping in
This commit is contained in:
@@ -32,6 +32,7 @@ import eu.kanade.tachiyomi.ui.main.MainActivity
|
||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||
import eu.kanade.tachiyomi.util.lang.launchUI
|
||||
import eu.kanade.tachiyomi.util.preference.asHotFlow
|
||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
import eu.kanade.tachiyomi.util.system.openInBrowser
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
@@ -71,14 +72,8 @@ class LibraryController(
|
||||
*/
|
||||
private var actionMode: ActionModeWithToolbar? = null
|
||||
|
||||
/**
|
||||
* Relay to notify the library's viewpager for updates.
|
||||
*/
|
||||
val libraryMangaRelay: BehaviorRelay<LibraryMangaEvent> = BehaviorRelay.create()
|
||||
private var mangaMap: LibraryMap = emptyMap()
|
||||
|
||||
/**
|
||||
* Adapter of the view pager.
|
||||
*/
|
||||
private var adapter: LibraryAdapter? = null
|
||||
|
||||
/**
|
||||
@@ -121,11 +116,9 @@ class LibraryController(
|
||||
currentCategory?.name
|
||||
}
|
||||
|
||||
if (preferences.categoryNumberOfItems().get() && libraryMangaRelay.hasValue()) {
|
||||
libraryMangaRelay.value.mangas.let { mangaMap ->
|
||||
if (!showCategoryTabs || adapter?.categories?.size == 1) {
|
||||
title += " (${mangaMap[currentCategory?.id]?.size ?: 0})"
|
||||
}
|
||||
if (preferences.categoryNumberOfItems().get()) {
|
||||
if (!showCategoryTabs || adapter?.categories?.size == 1) {
|
||||
title += " (${mangaMap[currentCategory?.id]?.size ?: 0})"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,8 +142,7 @@ class LibraryController(
|
||||
)
|
||||
|
||||
getColumnsPreferenceForCurrentOrientation()
|
||||
.asFlow()
|
||||
.onEach { presenter.columns = it }
|
||||
.asHotFlow { presenter.columns = it }
|
||||
.launchIn(viewScope)
|
||||
|
||||
binding.libraryPager.adapter = adapter
|
||||
@@ -299,7 +291,7 @@ class LibraryController(
|
||||
presenter.loadedMangaFlow.value = presenter.loadedManga
|
||||
|
||||
// Send the manga map to child fragments after the adapter is updated.
|
||||
libraryMangaRelay.call(LibraryMangaEvent(mangaMap))
|
||||
this.mangaMap = mangaMap
|
||||
|
||||
// Finally update the title
|
||||
updateTitle()
|
||||
@@ -322,9 +314,6 @@ class LibraryController(
|
||||
updateTitle()
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the sorting mode is changed.
|
||||
*/
|
||||
private fun onSortChanged() {
|
||||
presenter.requestSortUpdate()
|
||||
}
|
||||
@@ -343,9 +332,6 @@ class LibraryController(
|
||||
adapter.recycle = true
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the action mode if it's not created already.
|
||||
*/
|
||||
fun createActionModeIfNeeded() {
|
||||
val activity = activity
|
||||
if (actionMode == null && activity is MainActivity) {
|
||||
@@ -354,9 +340,6 @@ class LibraryController(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys the action mode.
|
||||
*/
|
||||
private fun destroyActionModeIfNeeded() {
|
||||
actionMode?.finish()
|
||||
}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
package eu.kanade.tachiyomi.ui.library
|
||||
|
||||
class LibraryMangaEvent(val mangas: LibraryMap)
|
||||
@@ -44,9 +44,6 @@ import eu.kanade.tachiyomi.util.lang.launchIO
|
||||
import eu.kanade.tachiyomi.util.removeCovers
|
||||
import eu.kanade.tachiyomi.widget.ExtendedNavigationView.Item.TriStateGroup.State
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.drop
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import rx.Observable
|
||||
import rx.Subscription
|
||||
@@ -126,20 +123,10 @@ class LibraryPresenter(
|
||||
*/
|
||||
private val sortTriggerRelay = BehaviorRelay.create(Unit)
|
||||
|
||||
/**
|
||||
* Library subscription.
|
||||
*/
|
||||
private var librarySubscription: Subscription? = null
|
||||
|
||||
override fun onCreate(savedState: Bundle?) {
|
||||
super.onCreate(savedState)
|
||||
preferences.libraryDisplayMode()
|
||||
.asFlow()
|
||||
.drop(1)
|
||||
.onEach {
|
||||
currentDisplayMode = it
|
||||
}
|
||||
.launchIn(presenterScope)
|
||||
|
||||
subscribeLibrary()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user