mirror of
https://github.com/mihonapp/mihon.git
synced 2025-06-27 11:37:51 +02:00
Migrate to flow
This commit is contained in:
@ -12,7 +12,6 @@ import com.google.android.material.bottomsheet.BottomSheetDialog
|
|||||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
|
||||||
import eu.kanade.tachiyomi.databinding.PreMigrationControllerBinding
|
import eu.kanade.tachiyomi.databinding.PreMigrationControllerBinding
|
||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||||
@ -98,7 +97,7 @@ class PreMigrationController(bundle: Bundle? = null) :
|
|||||||
val listOfSources = adapter?.items?.filter {
|
val listOfSources = adapter?.items?.filter {
|
||||||
it.sourceEnabled
|
it.sourceEnabled
|
||||||
}?.joinToString("/") { it.source.id.toString() }
|
}?.joinToString("/") { it.source.id.toString() }
|
||||||
prefs.migrationSources().set(listOfSources)
|
prefs.migrationSources().set(listOfSources!!)
|
||||||
|
|
||||||
router.replaceTopController(
|
router.replaceTopController(
|
||||||
MigrationListController.create(
|
MigrationListController.create(
|
||||||
@ -136,7 +135,7 @@ class PreMigrationController(bundle: Bundle? = null) :
|
|||||||
*/
|
*/
|
||||||
private fun getEnabledSources(): List<HttpSource> {
|
private fun getEnabledSources(): List<HttpSource> {
|
||||||
val languages = prefs.enabledLanguages().get()
|
val languages = prefs.enabledLanguages().get()
|
||||||
val sourcesSaved = prefs.migrationSources().getOrDefault().split("/")
|
val sourcesSaved = prefs.migrationSources().get().split("/")
|
||||||
var sources = sourceManager.getVisibleCatalogueSources()
|
var sources = sourceManager.getVisibleCatalogueSources()
|
||||||
.filterIsInstance<HttpSource>()
|
.filterIsInstance<HttpSource>()
|
||||||
.filter { it.lang in languages }
|
.filter { it.lang in languages }
|
||||||
@ -154,7 +153,7 @@ class PreMigrationController(bundle: Bundle? = null) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun isEnabled(id: String): Boolean {
|
fun isEnabled(id: String): Boolean {
|
||||||
val sourcesSaved = prefs.migrationSources().getOrDefault()
|
val sourcesSaved = prefs.migrationSources().get()
|
||||||
val hiddenCatalogues = prefs.hiddenCatalogues().get()
|
val hiddenCatalogues = prefs.hiddenCatalogues().get()
|
||||||
return if (sourcesSaved.isEmpty()) id !in hiddenCatalogues
|
return if (sourcesSaved.isEmpty()) id !in hiddenCatalogues
|
||||||
else sourcesSaved.split("/").contains(id)
|
else sourcesSaved.split("/").contains(id)
|
||||||
|
@ -128,7 +128,7 @@ class MigrationListController(bundle: Bundle? = null) :
|
|||||||
val useSourceWithMost = preferences.useSourceWithMost().getOrDefault()
|
val useSourceWithMost = preferences.useSourceWithMost().getOrDefault()
|
||||||
val useSmartSearch = preferences.smartMigration().getOrDefault()
|
val useSmartSearch = preferences.smartMigration().getOrDefault()
|
||||||
|
|
||||||
val sources = preferences.migrationSources().getOrDefault().split("/").mapNotNull {
|
val sources = preferences.migrationSources().get().split("/").mapNotNull {
|
||||||
val value = it.toLongOrNull() ?: return
|
val value = it.toLongOrNull() ?: return
|
||||||
sourceManager.get(value) as? CatalogueSource
|
sourceManager.get(value) as? CatalogueSource
|
||||||
}
|
}
|
||||||
|
@ -213,7 +213,7 @@ class SettingsLibraryController : SettingsController() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (preferences.skipPreMigration().get() || preferences.migrationSources()
|
if (preferences.skipPreMigration().get() || preferences.migrationSources()
|
||||||
.getOrDefault().isNotEmpty()
|
.get().isNotEmpty()
|
||||||
) {
|
) {
|
||||||
switchPreference {
|
switchPreference {
|
||||||
key = Keys.skipPreMigration
|
key = Keys.skipPreMigration
|
||||||
|
Reference in New Issue
Block a user