Prepare to export sources
This commit is contained in:
50
app/src/main/java/xyz/quaver/pupil/sources/SourceLoader.kt
Normal file
50
app/src/main/java/xyz/quaver/pupil/sources/SourceLoader.kt
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Pupil, Hitomi.la viewer for Android
|
||||
* Copyright (C) 2020 tom5079
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package xyz.quaver.pupil.sources
|
||||
|
||||
import android.app.Application
|
||||
import androidx.navigation.NavController
|
||||
import androidx.navigation.NavGraphBuilder
|
||||
import org.kodein.di.*
|
||||
import xyz.quaver.pupil.sources.hitomi.Hitomi
|
||||
import xyz.quaver.pupil.sources.manatoki.Manatoki
|
||||
|
||||
abstract class Source {
|
||||
abstract val name: String
|
||||
abstract val iconResID: Int
|
||||
|
||||
open fun NavGraphBuilder.navGraph(navController: NavController) { }
|
||||
}
|
||||
|
||||
typealias SourceEntry = Pair<String, Source>
|
||||
typealias SourceEntries = Set<SourceEntry>
|
||||
val sourceModule = DI.Module(name = "source") {
|
||||
bindSet<SourceEntry>()
|
||||
|
||||
listOf<(Application) -> (Source)>(
|
||||
{ Hitomi(it) },
|
||||
//{ Hiyobi_io(it) },
|
||||
{ Manatoki(it) }
|
||||
).forEach { source ->
|
||||
inSet { singleton { source(instance()).let { it.name to it } } }
|
||||
}
|
||||
|
||||
//bind { singleton { History(di) } }
|
||||
// inSet { singleton { Downloads(di).let { it.name to it as Source } } }
|
||||
}
|
||||
Reference in New Issue
Block a user