mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-07 19:27:25 +01:00
Add parent class for view configs
This commit is contained in:
parent
d9f44c1f7d
commit
678c004a64
@ -0,0 +1,24 @@
|
|||||||
|
package eu.kanade.tachiyomi.ui.reader.viewer
|
||||||
|
|
||||||
|
import com.tfcporciuncula.flow.Preference
|
||||||
|
import eu.kanade.tachiyomi.util.lang.launchInUI
|
||||||
|
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||||
|
import kotlinx.coroutines.flow.drop
|
||||||
|
import kotlinx.coroutines.flow.onEach
|
||||||
|
|
||||||
|
abstract class ViewerConfig {
|
||||||
|
|
||||||
|
var imagePropertyChangedListener: (() -> Unit)? = null
|
||||||
|
|
||||||
|
fun <T> Preference<T>.register(
|
||||||
|
valueAssignment: (T) -> Unit,
|
||||||
|
onChanged: (T) -> Unit = {}
|
||||||
|
) {
|
||||||
|
asFlow()
|
||||||
|
.onEach { valueAssignment(it) }
|
||||||
|
.drop(1)
|
||||||
|
.distinctUntilChanged()
|
||||||
|
.onEach { onChanged(it) }
|
||||||
|
.launchInUI()
|
||||||
|
}
|
||||||
|
}
|
@ -4,17 +4,17 @@ import com.f2prateek.rx.preferences.Preference
|
|||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.util.lang.addTo
|
import eu.kanade.tachiyomi.util.lang.addTo
|
||||||
import rx.subscriptions.CompositeSubscription
|
import rx.subscriptions.CompositeSubscription
|
||||||
|
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerConfig
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration used by pager viewers.
|
* Configuration used by pager viewers.
|
||||||
*/
|
*/
|
||||||
class PagerConfig(private val viewer: PagerViewer, preferences: PreferencesHelper = Injekt.get()) {
|
|
||||||
|
|
||||||
private val subscriptions = CompositeSubscription()
|
private val subscriptions = CompositeSubscription()
|
||||||
|
class PagerConfig(private val viewer: PagerViewer, preferences: PreferencesHelper = Injekt.get()) :
|
||||||
var imagePropertyChangedListener: (() -> Unit)? = null
|
ViewerConfig() {
|
||||||
|
|
||||||
var tappingEnabled = true
|
var tappingEnabled = true
|
||||||
private set
|
private set
|
||||||
|
@ -4,17 +4,16 @@ import com.f2prateek.rx.preferences.Preference
|
|||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.util.lang.addTo
|
import eu.kanade.tachiyomi.util.lang.addTo
|
||||||
import rx.subscriptions.CompositeSubscription
|
import rx.subscriptions.CompositeSubscription
|
||||||
|
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerConfig
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration used by webtoon viewers.
|
* Configuration used by webtoon viewers.
|
||||||
*/
|
*/
|
||||||
class WebtoonConfig(preferences: PreferencesHelper = Injekt.get()) {
|
|
||||||
|
|
||||||
private val subscriptions = CompositeSubscription()
|
private val subscriptions = CompositeSubscription()
|
||||||
|
class WebtoonConfig(preferences: PreferencesHelper = Injekt.get()) : ViewerConfig() {
|
||||||
var imagePropertyChangedListener: (() -> Unit)? = null
|
|
||||||
|
|
||||||
var tappingEnabled = true
|
var tappingEnabled = true
|
||||||
private set
|
private set
|
||||||
|
Loading…
Reference in New Issue
Block a user