2017-01-20 21:24:31 +01:00
|
|
|
package eu.kanade.tachiyomi.source
|
|
|
|
|
|
|
|
import android.content.Context
|
2017-01-20 21:27:53 +01:00
|
|
|
import eu.kanade.tachiyomi.source.online.HttpSource
|
2017-01-20 21:24:31 +01:00
|
|
|
import eu.kanade.tachiyomi.source.online.english.*
|
|
|
|
import eu.kanade.tachiyomi.source.online.german.WieManga
|
|
|
|
import eu.kanade.tachiyomi.source.online.russian.Mangachan
|
|
|
|
import eu.kanade.tachiyomi.source.online.russian.Mintmanga
|
|
|
|
import eu.kanade.tachiyomi.source.online.russian.Readmanga
|
|
|
|
|
|
|
|
open class SourceManager(private val context: Context) {
|
|
|
|
|
|
|
|
private val sourcesMap = mutableMapOf<Long, Source>()
|
|
|
|
|
|
|
|
init {
|
2018-02-05 22:50:56 +01:00
|
|
|
createInternalSources().forEach { registerSource(it) }
|
2017-01-20 21:24:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
open fun get(sourceKey: Long): Source? {
|
|
|
|
return sourcesMap[sourceKey]
|
|
|
|
}
|
|
|
|
|
2017-01-20 21:27:53 +01:00
|
|
|
fun getOnlineSources() = sourcesMap.values.filterIsInstance<HttpSource>()
|
2017-01-20 21:24:31 +01:00
|
|
|
|
|
|
|
fun getCatalogueSources() = sourcesMap.values.filterIsInstance<CatalogueSource>()
|
|
|
|
|
2018-02-05 22:50:56 +01:00
|
|
|
internal fun registerSource(source: Source, overwrite: Boolean = false) {
|
2017-01-20 21:24:31 +01:00
|
|
|
if (overwrite || !sourcesMap.containsKey(source.id)) {
|
|
|
|
sourcesMap.put(source.id, source)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-05 22:50:56 +01:00
|
|
|
internal fun unregisterSource(source: Source) {
|
|
|
|
sourcesMap.remove(source.id)
|
|
|
|
}
|
|
|
|
|
2017-01-20 21:24:31 +01:00
|
|
|
private fun createInternalSources(): List<Source> = listOf(
|
2017-01-29 20:48:55 +01:00
|
|
|
LocalSource(context),
|
2017-01-20 21:24:31 +01:00
|
|
|
Batoto(),
|
|
|
|
Mangahere(),
|
|
|
|
Mangafox(),
|
|
|
|
Kissmanga(),
|
|
|
|
Readmanga(),
|
|
|
|
Mintmanga(),
|
|
|
|
Mangachan(),
|
|
|
|
Readmangatoday(),
|
|
|
|
Mangasee(),
|
|
|
|
WieManga()
|
|
|
|
)
|
|
|
|
}
|