Address more coroutine scope leaks
This commit is contained in:
@@ -133,14 +133,14 @@ class SettingsBackupController : SettingsController() {
|
||||
}
|
||||
|
||||
preferences.backupInterval().asImmediateFlow { isVisible = it > 0 }
|
||||
.launchIn(scope)
|
||||
.launchIn(viewScope)
|
||||
|
||||
preferences.backupsDirectory().asFlow()
|
||||
.onEach { path ->
|
||||
val dir = UniFile.fromUri(context, path.toUri())
|
||||
summary = dir.filePath + "/automatic"
|
||||
}
|
||||
.launchIn(scope)
|
||||
.launchIn(viewScope)
|
||||
}
|
||||
intListPreference {
|
||||
key = Keys.numberOfBackups
|
||||
@@ -151,7 +151,7 @@ class SettingsBackupController : SettingsController() {
|
||||
summary = "%s"
|
||||
|
||||
preferences.backupInterval().asImmediateFlow { isVisible = it > 0 }
|
||||
.launchIn(scope)
|
||||
.launchIn(viewScope)
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.createLegacyBackup
|
||||
@@ -159,7 +159,7 @@ class SettingsBackupController : SettingsController() {
|
||||
defaultValue = true
|
||||
|
||||
preferences.backupInterval().asImmediateFlow { isVisible = it > 0 }
|
||||
.launchIn(scope)
|
||||
.launchIn(viewScope)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ class SettingsBrowseController : SettingsController() {
|
||||
titleRes = R.string.pref_label_nsfw_extension
|
||||
defaultValue = true
|
||||
|
||||
preferences.showNsfwExtension().asImmediateFlow { isVisible = it }.launchIn(scope)
|
||||
preferences.showNsfwExtension().asImmediateFlow { isVisible = it }.launchIn(viewScope)
|
||||
}
|
||||
|
||||
infoPreference(R.string.parental_controls_info)
|
||||
|
||||
@@ -22,9 +22,7 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.ui.base.controller.BaseController
|
||||
import eu.kanade.tachiyomi.ui.base.controller.RootController
|
||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.MainScope
|
||||
import rx.Observable
|
||||
import rx.Subscription
|
||||
import rx.subscriptions.CompositeSubscription
|
||||
@@ -35,7 +33,7 @@ abstract class SettingsController : PreferenceController() {
|
||||
|
||||
var preferenceKey: String? = null
|
||||
val preferences: PreferencesHelper = Injekt.get()
|
||||
val scope = CoroutineScope(Job() + Dispatchers.Main)
|
||||
val viewScope = MainScope()
|
||||
|
||||
var untilDestroySubscriptions = CompositeSubscription()
|
||||
private set
|
||||
|
||||
@@ -57,7 +57,7 @@ class SettingsDownloadController : SettingsController() {
|
||||
val dir = UniFile.fromUri(context, path.toUri())
|
||||
summary = dir.filePath ?: path
|
||||
}
|
||||
.launchIn(scope)
|
||||
.launchIn(viewScope)
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.downloadOnlyOverWifi
|
||||
@@ -112,7 +112,7 @@ class SettingsDownloadController : SettingsController() {
|
||||
entryValues = categories.map { it.id.toString() }.toTypedArray()
|
||||
|
||||
preferences.downloadNew().asImmediateFlow { isVisible = it }
|
||||
.launchIn(scope)
|
||||
.launchIn(viewScope)
|
||||
|
||||
preferences.downloadNewCategories().asFlow()
|
||||
.onEach { mutableSet ->
|
||||
@@ -126,7 +126,7 @@ class SettingsDownloadController : SettingsController() {
|
||||
selectedCategories.joinToString { it.name }
|
||||
}
|
||||
}
|
||||
.launchIn(scope)
|
||||
.launchIn(viewScope)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ class SettingsGeneralController : SettingsController() {
|
||||
summary = "%s"
|
||||
|
||||
preferences.themeMode().asImmediateFlow { isVisible = it != Values.ThemeMode.dark }
|
||||
.launchIn(scope)
|
||||
.launchIn(viewScope)
|
||||
|
||||
onChange {
|
||||
if (preferences.themeMode().get() != Values.ThemeMode.dark) {
|
||||
@@ -142,7 +142,7 @@ class SettingsGeneralController : SettingsController() {
|
||||
summary = "%s"
|
||||
|
||||
preferences.themeMode().asImmediateFlow { isVisible = it != Values.ThemeMode.light }
|
||||
.launchIn(scope)
|
||||
.launchIn(viewScope)
|
||||
|
||||
onChange {
|
||||
if (preferences.themeMode().get() != Values.ThemeMode.light) {
|
||||
|
||||
@@ -70,7 +70,7 @@ class SettingsLibraryController : SettingsController() {
|
||||
summary = "${context.getString(R.string.portrait)}: $portrait, " +
|
||||
"${context.getString(R.string.landscape)}: $landscape"
|
||||
}
|
||||
.launchIn(scope)
|
||||
.launchIn(viewScope)
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.jumpToChapters
|
||||
@@ -150,7 +150,7 @@ class SettingsLibraryController : SettingsController() {
|
||||
defaultValue = setOf("wifi")
|
||||
|
||||
preferences.libraryUpdateInterval().asImmediateFlow { isVisible = it > 0 }
|
||||
.launchIn(scope)
|
||||
.launchIn(viewScope)
|
||||
|
||||
onChange {
|
||||
// Post to event looper to allow the preference to be updated.
|
||||
@@ -180,7 +180,7 @@ class SettingsLibraryController : SettingsController() {
|
||||
selectedCategories.joinToString { it.name }
|
||||
}
|
||||
}
|
||||
.launchIn(scope)
|
||||
.launchIn(viewScope)
|
||||
}
|
||||
intListPreference {
|
||||
key = Keys.libraryUpdatePrioritization
|
||||
|
||||
@@ -150,7 +150,7 @@ class SettingsReaderController : SettingsController() {
|
||||
defaultValue = "0"
|
||||
summary = "%s"
|
||||
|
||||
preferences.readWithTapping().asImmediateFlow { isVisible = it }.launchIn(scope)
|
||||
preferences.readWithTapping().asImmediateFlow { isVisible = it }.launchIn(viewScope)
|
||||
}
|
||||
listPreference {
|
||||
key = Keys.pagerNavInverted
|
||||
@@ -170,7 +170,7 @@ class SettingsReaderController : SettingsController() {
|
||||
defaultValue = TappingInvertMode.NONE.name
|
||||
summary = "%s"
|
||||
|
||||
preferences.readWithTapping().asImmediateFlow { isVisible = it }.launchIn(scope)
|
||||
preferences.readWithTapping().asImmediateFlow { isVisible = it }.launchIn(viewScope)
|
||||
}
|
||||
intListPreference {
|
||||
key = Keys.imageScaleType
|
||||
@@ -223,7 +223,7 @@ class SettingsReaderController : SettingsController() {
|
||||
defaultValue = "0"
|
||||
summary = "%s"
|
||||
|
||||
preferences.readWithTapping().asImmediateFlow { isVisible = it }.launchIn(scope)
|
||||
preferences.readWithTapping().asImmediateFlow { isVisible = it }.launchIn(viewScope)
|
||||
}
|
||||
listPreference {
|
||||
key = Keys.webtoonNavInverted
|
||||
@@ -243,7 +243,7 @@ class SettingsReaderController : SettingsController() {
|
||||
defaultValue = TappingInvertMode.NONE.name
|
||||
summary = "%s"
|
||||
|
||||
preferences.readWithTapping().asImmediateFlow { isVisible = it }.launchIn(scope)
|
||||
preferences.readWithTapping().asImmediateFlow { isVisible = it }.launchIn(viewScope)
|
||||
}
|
||||
intListPreference {
|
||||
key = Keys.webtoonSidePadding
|
||||
@@ -289,7 +289,7 @@ class SettingsReaderController : SettingsController() {
|
||||
titleRes = R.string.pref_read_with_volume_keys_inverted
|
||||
defaultValue = false
|
||||
|
||||
preferences.readWithVolumeKeys().asImmediateFlow { isVisible = it }.launchIn(scope)
|
||||
preferences.readWithVolumeKeys().asImmediateFlow { isVisible = it }.launchIn(viewScope)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ class SettingsSecurityController : SettingsController() {
|
||||
summary = "%s"
|
||||
|
||||
preferences.useBiometricLock().asImmediateFlow { isVisible = it }
|
||||
.launchIn(scope)
|
||||
.launchIn(viewScope)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user