Refresh page on 32-bit color setting change

This commit is contained in:
arkon 2020-05-05 17:45:07 -04:00
parent 5977fca6b9
commit dbd14c6dac

View file

@ -5,6 +5,7 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onEach
@ -22,6 +23,7 @@ abstract class ViewerConfig(preferences: PreferencesHelper) {
var doubleTapAnimDuration = 500 var doubleTapAnimDuration = 500
var volumeKeysEnabled = false var volumeKeysEnabled = false
var volumeKeysInverted = false var volumeKeysInverted = false
var trueColor = false
var alwaysShowChapterTransition = true var alwaysShowChapterTransition = true
init { init {
@ -40,6 +42,9 @@ abstract class ViewerConfig(preferences: PreferencesHelper) {
preferences.readWithVolumeKeysInverted() preferences.readWithVolumeKeysInverted()
.register({ volumeKeysInverted = it }) .register({ volumeKeysInverted = it })
preferences.trueColor()
.register({ trueColor = it }, { imagePropertyChangedListener?.invoke() })
preferences.alwaysShowChapterTransition() preferences.alwaysShowChapterTransition()
.register({ alwaysShowChapterTransition = it }) .register({ alwaysShowChapterTransition = it })
} }
@ -49,10 +54,9 @@ abstract class ViewerConfig(preferences: PreferencesHelper) {
onChanged: (T) -> Unit = {} onChanged: (T) -> Unit = {}
) { ) {
asFlow() asFlow()
.onEach { .onEach { valueAssignment(it) }
valueAssignment(it) .distinctUntilChanged()
onChanged(it) .onEach { onChanged(it) }
}
.launchIn(scope) .launchIn(scope)
} }
} }