From dbd14c6daca3bd058c824300c414a924a7ac5063 Mon Sep 17 00:00:00 2001 From: arkon Date: Tue, 5 May 2020 17:45:07 -0400 Subject: [PATCH] Refresh page on 32-bit color setting change --- .../tachiyomi/ui/reader/viewer/ViewerConfig.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ViewerConfig.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ViewerConfig.kt index fab295831..752045821 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ViewerConfig.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ViewerConfig.kt @@ -5,6 +5,7 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job +import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach @@ -22,6 +23,7 @@ abstract class ViewerConfig(preferences: PreferencesHelper) { var doubleTapAnimDuration = 500 var volumeKeysEnabled = false var volumeKeysInverted = false + var trueColor = false var alwaysShowChapterTransition = true init { @@ -40,6 +42,9 @@ abstract class ViewerConfig(preferences: PreferencesHelper) { preferences.readWithVolumeKeysInverted() .register({ volumeKeysInverted = it }) + preferences.trueColor() + .register({ trueColor = it }, { imagePropertyChangedListener?.invoke() }) + preferences.alwaysShowChapterTransition() .register({ alwaysShowChapterTransition = it }) } @@ -49,10 +54,9 @@ abstract class ViewerConfig(preferences: PreferencesHelper) { onChanged: (T) -> Unit = {} ) { asFlow() - .onEach { - valueAssignment(it) - onChanged(it) - } + .onEach { valueAssignment(it) } + .distinctUntilChanged() + .onEach { onChanged(it) } .launchIn(scope) } }