diff --git a/app/src/main/java/ani/dantotsu/notifications/subscription/SubscriptionHelper.kt b/app/src/main/java/ani/dantotsu/notifications/subscription/SubscriptionHelper.kt index 9905cb86..79f84381 100644 --- a/app/src/main/java/ani/dantotsu/notifications/subscription/SubscriptionHelper.kt +++ b/app/src/main/java/ani/dantotsu/notifications/subscription/SubscriptionHelper.kt @@ -23,7 +23,7 @@ class SubscriptionHelper { mediaId: Int ): Selected { val data = - PrefManager.getNullableCustomVal("${mediaId}-select", null, Selected::class.java) + PrefManager.getNullableCustomVal("Selected-${mediaId}", null, Selected::class.java) ?: Selected().let { it.sourceIndex = 0 it.preferDub = PrefManager.getVal(PrefName.SettingsPreferDub) @@ -33,13 +33,16 @@ class SubscriptionHelper { } private fun saveSelected(mediaId: Int, data: Selected) { - PrefManager.setCustomVal("${mediaId}-select", data) + PrefManager.setCustomVal("Selected-${mediaId}", data) } fun getAnimeParser(id: Int): AnimeParser { val sources = AnimeSources Logger.log("getAnimeParser size: ${sources.list.size}") val selected = loadSelected(id) + if (selected.sourceIndex >= sources.list.size) { + selected.sourceIndex = 0 + } val parser = sources[selected.sourceIndex] parser.selectDub = selected.preferDub return parser @@ -76,7 +79,11 @@ class SubscriptionHelper { fun getMangaParser(id: Int): MangaParser { val sources = MangaSources + Logger.log("getMangaParser size: ${sources.list.size}") val selected = loadSelected(id) + if (selected.sourceIndex >= sources.list.size) { + selected.sourceIndex = 0 + } return sources[selected.sourceIndex] }