fixes from inspector

This commit is contained in:
Aria Moradi 2021-04-03 20:08:50 +04:30
parent 15bd5b4b7a
commit 884308690f
2 changed files with 13 additions and 19 deletions

View File

@ -124,10 +124,7 @@ object Extension {
val sources: List<CatalogueSource> = when (val instance = loadExtensionSources(jarFilePath, className)) {
is Source -> listOf(instance)
is SourceFactory -> instance.createSources()
else -> {
throw RuntimeException("Unknown source class type! ${instance.javaClass}")
}
else -> throw RuntimeException("Unknown source class type! ${instance.javaClass}")
}.map { it as CatalogueSource }
val langs = sources.map { it.lang }.toSet()

View File

@ -7,6 +7,7 @@ package ir.armor.tachidesk.impl.util
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import eu.kanade.tachiyomi.source.Source
import eu.kanade.tachiyomi.source.SourceFactory
import eu.kanade.tachiyomi.source.online.HttpSource
import ir.armor.tachidesk.impl.util.PackageTools.loadExtensionSources
@ -40,17 +41,13 @@ object GetHttpSource {
val jarName = apkName.substringBefore(".apk") + ".jar"
val jarPath = "${ApplicationDirs.extensionsRoot}/$jarName"
val extensionInstance = loadExtensionSources(jarPath, className)
if (sourceRecord[SourceTable.partOfFactorySource]) {
(extensionInstance as SourceFactory).createSources().forEach {
when (val instance = loadExtensionSources(jarPath, className)) {
is Source -> listOf(instance)
is SourceFactory -> instance.createSources()
else -> throw Exception("Unknown source class type! ${instance.javaClass}")
}.forEach {
sourceCache[it.id] = it as HttpSource
}
} else {
(extensionInstance as HttpSource).also {
sourceCache[it.id] = it
}
}
return sourceCache[sourceId]!!
}
}