Reattach after slight delay instead on every db update (#5956)
This commit is contained in:
parent
9de08c8166
commit
1ae0d1b5d0
@ -42,9 +42,12 @@ import kotlinx.coroutines.flow.launchIn
|
|||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
import reactivecircus.flowbinding.android.view.clicks
|
import reactivecircus.flowbinding.android.view.clicks
|
||||||
import reactivecircus.flowbinding.viewpager.pageSelections
|
import reactivecircus.flowbinding.viewpager.pageSelections
|
||||||
|
import rx.Observable
|
||||||
import rx.Subscription
|
import rx.Subscription
|
||||||
|
import rx.android.schedulers.AndroidSchedulers
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
class LibraryController(
|
class LibraryController(
|
||||||
bundle: Bundle? = null,
|
bundle: Bundle? = null,
|
||||||
@ -199,8 +202,10 @@ class LibraryController(
|
|||||||
is LibrarySettingsSheet.Filter.FilterGroup -> onFilterChanged()
|
is LibrarySettingsSheet.Filter.FilterGroup -> onFilterChanged()
|
||||||
is LibrarySettingsSheet.Sort.SortGroup -> onSortChanged()
|
is LibrarySettingsSheet.Sort.SortGroup -> onSortChanged()
|
||||||
is LibrarySettingsSheet.Display.DisplayGroup -> {
|
is LibrarySettingsSheet.Display.DisplayGroup -> {
|
||||||
if (!preferences.categorisedDisplaySettings().get() || activeCategory == 0) {
|
val delay = if (preferences.categorisedDisplaySettings().get()) 125L else 0L
|
||||||
// Reattach adapter when flow preference change
|
|
||||||
|
Observable.timer(delay, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread())
|
||||||
|
.subscribe {
|
||||||
reattachAdapter()
|
reattachAdapter()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -299,11 +304,6 @@ class LibraryController(
|
|||||||
.map { (it.id ?: -1) to (mangaMap[it.id]?.size ?: 0) }
|
.map { (it.id ?: -1) to (mangaMap[it.id]?.size ?: 0) }
|
||||||
.toMap()
|
.toMap()
|
||||||
|
|
||||||
if (preferences.categorisedDisplaySettings().get()) {
|
|
||||||
// Reattach adapter so it doesn't get de-synced
|
|
||||||
reattachAdapter()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Restore active category.
|
// Restore active category.
|
||||||
binding.libraryPager.setCurrentItem(activeCat, false)
|
binding.libraryPager.setCurrentItem(activeCat, false)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user