Prepare to export sources

This commit is contained in:
tom5079
2021-12-30 13:00:22 +09:00
parent 0e19d6c9b2
commit 2e11a4907a
14 changed files with 371 additions and 171 deletions

View 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 } } }
}