Refactor repository creation

This commit is contained in:
Koitharu
2021-01-20 20:27:47 +02:00
parent bb1dd74277
commit 9054f5720f
7 changed files with 77 additions and 39 deletions

View File

@@ -9,6 +9,7 @@ import org.koitharu.kotatsu.core.model.MangaSource
import org.koitharu.kotatsu.core.parser.RemoteMangaRepository
import org.koitharu.kotatsu.core.prefs.SourceSettings
import org.koitharu.kotatsu.settings.utils.EditTextSummaryProvider
import org.koitharu.kotatsu.utils.ext.mangaRepositoryOf
import org.koitharu.kotatsu.utils.ext.withArgs
class SourceSettingsFragment : PreferenceFragmentCompat() {
@@ -24,7 +25,7 @@ class SourceSettingsFragment : PreferenceFragmentCompat() {
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
preferenceManager.sharedPreferencesName = source.name
val repo = source.repository as? RemoteMangaRepository ?: return
val repo = mangaRepositoryOf(source) as? RemoteMangaRepository ?: return
val keys = repo.onCreatePreferences()
addPreferencesFromResource(R.xml.pref_source)
for (i in 0 until preferenceScreen.preferenceCount) {