Add a few source helper functions
This commit is contained in:
@@ -180,8 +180,8 @@ class FullBackupManager(context: Context) : AbstractBackupManager(context) {
|
||||
}
|
||||
}
|
||||
|
||||
val source = sourceManager.get(manga.source)?.getMainSource()
|
||||
if (source is MetadataSource<*, *>) {
|
||||
val source = sourceManager.get(manga.source)?.getMainSource<MetadataSource<*, *>>()
|
||||
if (source != null) {
|
||||
manga.id?.let { mangaId ->
|
||||
databaseHelper.getFlatMetadataForManga(mangaId).executeAsBlocking()?.let { flatMetadata ->
|
||||
mangaObject.flatMetadata = BackupFlatMetadata.copyFrom(flatMetadata)
|
||||
|
||||
+4
-3
@@ -57,6 +57,7 @@ import eu.kanade.tachiyomi.widget.EmptyView
|
||||
import eu.kanade.tachiyomi.widget.materialdialogs.setTextInput
|
||||
import exh.log.xLogW
|
||||
import exh.savedsearches.EXHSavedSearch
|
||||
import exh.source.anyIs
|
||||
import exh.source.getMainSource
|
||||
import exh.source.isEhBasedSource
|
||||
import exh.widget.preference.MangadexLoginDialog
|
||||
@@ -169,8 +170,8 @@ open class BrowseSourceController(bundle: Bundle) :
|
||||
binding.progress.isVisible = true
|
||||
|
||||
// SY -->
|
||||
val mainSource = presenter.source.getMainSource()
|
||||
if (mainSource is LoginSource && mainSource.requiresLogin && !mainSource.isLogged()) {
|
||||
val mainSource = presenter.source.getMainSource<LoginSource>()
|
||||
if (mainSource != null && mainSource.requiresLogin && !mainSource.isLogged()) {
|
||||
val dialog = MangadexLoginDialog(mainSource)
|
||||
dialog.showDialog(router)
|
||||
}
|
||||
@@ -438,7 +439,7 @@ open class BrowseSourceController(bundle: Bundle) :
|
||||
menu.findItem(R.id.action_local_source_help)?.isVisible = isLocalSource
|
||||
|
||||
// SY -->
|
||||
menu.findItem(R.id.action_settings)?.isVisible = presenter.source is ConfigurableSource
|
||||
menu.findItem(R.id.action_settings)?.isVisible = presenter.source.anyIs<ConfigurableSource>()
|
||||
// SY <--
|
||||
}
|
||||
|
||||
|
||||
@@ -118,8 +118,8 @@ class SourceFilterSheet(
|
||||
|
||||
init {
|
||||
// SY -->
|
||||
val mainSource = source?.getMainSource()
|
||||
if (mainSource is BrowseSourceFilterHeader && controller != null) {
|
||||
val mainSource = source?.getMainSource<BrowseSourceFilterHeader>()
|
||||
if (mainSource != null && controller != null) {
|
||||
adapters += mainSource.getFilterHeader(controller) { dismissSheet?.invoke() }
|
||||
}
|
||||
adapters += savedSearchesAdapter
|
||||
|
||||
@@ -302,8 +302,8 @@ class MangaController :
|
||||
chaptersHeaderAdapter = MangaChaptersHeaderAdapter(this)
|
||||
chaptersAdapter = ChaptersAdapter(this, view.context)
|
||||
// SY -->
|
||||
val mainSource = presenter.source.getMainSource()
|
||||
if (mainSource is MetadataSource<*, *>) {
|
||||
val mainSource = presenter.source.getMainSource<MetadataSource<*, *>>()
|
||||
if (mainSource != null) {
|
||||
mangaMetaInfoAdapter = mainSource.getDescriptionAdapter(this)
|
||||
}
|
||||
if (!preferences.recommendsInOverflow().get() || smartSearchConfig != null) {
|
||||
@@ -556,8 +556,8 @@ class MangaController :
|
||||
|
||||
// SY -->
|
||||
fun onNextMetaInfo(flatMetadata: FlatMetadata) {
|
||||
val mainSource = presenter.source.getMainSource()
|
||||
if (mainSource is MetadataSource<*, *>) {
|
||||
val mainSource = presenter.source.getMainSource<MetadataSource<*, *>>()
|
||||
if (mainSource != null) {
|
||||
presenter.meta = flatMetadata.raise(mainSource.metaClass)
|
||||
mangaMetaInfoAdapter?.notifyDataSetChanged()
|
||||
updateFilterIconState()
|
||||
|
||||
@@ -247,8 +247,8 @@ class ReaderPresenter(
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
// SY -->
|
||||
.flatMap { manga ->
|
||||
val source = sourceManager.get(manga.source)?.getMainSource()
|
||||
if (manga.initialized && source is MetadataSource<*, *>) {
|
||||
val source = sourceManager.get(manga.source)?.getMainSource<MetadataSource<*, *>>()
|
||||
if (manga.initialized && source != null) {
|
||||
db.getFlatMetadataForManga(mangaId).asRxSingle().map {
|
||||
manga to it?.raise(source.metaClass)
|
||||
}.toObservable()
|
||||
|
||||
Reference in New Issue
Block a user