Cloned sites working

Fixes #19
This commit is contained in:
Blatzar 2022-08-17 14:26:36 +02:00
parent 99d6aef993
commit aa3ece66a9

View file

@ -452,6 +452,28 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
} }
PluginManager.loadAllLocalPlugins(this@MainActivity) PluginManager.loadAllLocalPlugins(this@MainActivity)
// Load cloned sites after plugins have been loaded since clones depend on plugins.
try {
getKey<Array<SettingsGeneral.CustomSite>>(USER_PROVIDER_API)?.let { list ->
list.forEach { custom ->
allProviders.firstOrNull { it.javaClass.simpleName == custom.parentJavaClass }
?.let {
allProviders.add(it.javaClass.newInstance().apply {
name = custom.name
lang = custom.lang
mainUrl = custom.url.trimEnd('/')
canBeOverridden = false
})
}
}
}
apis = allProviders.distinctBy { it }
APIHolder.apiMap = null
} catch (e: Exception) {
logError(e)
}
afterPluginsLoadedEvent.invoke(true) afterPluginsLoadedEvent.invoke(true)
} }
@ -488,26 +510,6 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
initAll() initAll()
// No duplicates (which can happen by registerMainAPI) // No duplicates (which can happen by registerMainAPI)
apis = allProviders.distinctBy { it } apis = allProviders.distinctBy { it }
try {
getKey<Array<SettingsGeneral.CustomSite>>(USER_PROVIDER_API)?.let { list ->
list.forEach { custom ->
allProviders.firstOrNull { it.javaClass.simpleName == custom.parentJavaClass }
?.let {
allProviders.add(it.javaClass.newInstance().apply {
name = custom.name
lang = custom.lang
mainUrl = custom.url.trimEnd('/')
canBeOverridden = false
})
}
}
}
apis = allProviders.distinctBy { it }
APIHolder.apiMap = null
} catch (e: Exception) {
logError(e)
}
} }
// val navView: BottomNavigationView = findViewById(R.id.nav_view) // val navView: BottomNavigationView = findViewById(R.id.nav_view)