Fixed SourceManager creating sources multiple times on app launch.
This commit is contained in:
parent
38a15d4158
commit
fa6790856d
@ -23,7 +23,7 @@ import eu.kanade.tachiyomi.source.online.russian.Readmanga
|
|||||||
import eu.kanade.tachiyomi.util.hasPermission
|
import eu.kanade.tachiyomi.util.hasPermission
|
||||||
import exh.*
|
import exh.*
|
||||||
import org.yaml.snakeyaml.Yaml
|
import org.yaml.snakeyaml.Yaml
|
||||||
import rx.functions.Action1
|
import rx.Observable
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
import java.io.File
|
import java.io.File
|
||||||
@ -35,21 +35,20 @@ open class SourceManager(private val context: Context) {
|
|||||||
private val sourcesMap = mutableMapOf<Long, Source>()
|
private val sourcesMap = mutableMapOf<Long, Source>()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
createSources()
|
//Recreate sources when they change
|
||||||
|
val prefEntries = arrayOf(
|
||||||
|
prefs.enableExhentai(),
|
||||||
|
prefs.imageQuality(),
|
||||||
|
prefs.useHentaiAtHome(),
|
||||||
|
prefs.useJapaneseTitle(),
|
||||||
|
prefs.ehSearchSize(),
|
||||||
|
prefs.thumbnailRows()
|
||||||
|
).map { it.asObservable() }
|
||||||
|
|
||||||
//Rebuild sources when settings change
|
Observable.merge(prefEntries).skip(prefEntries.size - 1).subscribe {
|
||||||
val action: Action1<Any> = Action1 {
|
|
||||||
sourcesMap.clear()
|
sourcesMap.clear()
|
||||||
createSources()
|
createSources()
|
||||||
}
|
}
|
||||||
prefs.enableExhentai().asObservable().subscribe(action)
|
|
||||||
prefs.imageQuality().asObservable().subscribe (action)
|
|
||||||
prefs.useHentaiAtHome().asObservable().subscribe(action)
|
|
||||||
prefs.useJapaneseTitle().asObservable().subscribe {
|
|
||||||
action.call(null)
|
|
||||||
}
|
|
||||||
prefs.ehSearchSize().asObservable().subscribe (action)
|
|
||||||
prefs.thumbnailRows().asObservable().subscribe(action)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun get(sourceKey: Long): Source? {
|
open fun get(sourceKey: Long): Source? {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user