feat: automatically check sources

This commit is contained in:
TwistedUmbrellaX 2024-03-19 19:59:50 -04:00
parent ab7bc15573
commit 26d97da066
7 changed files with 75 additions and 2 deletions

View file

@ -159,8 +159,7 @@ class AnimeWatchAdapter(
}
subscribeButton(false)
fragment.loadEpisodes(media.selected!!.sourceIndex, true)
} ?: run {
}
} ?: run { }
}
//settings
@ -430,6 +429,22 @@ class AnimeWatchAdapter(
val sourceFound = media.anime.episodes!!.isNotEmpty()
binding.animeSourceNotFound.isGone = sourceFound
binding.faqbutton.isGone = sourceFound
if (!sourceFound && PrefManager.getVal(PrefName.SearchSources)) {
if (binding.animeSource.adapter.count > media.selected!!.sourceIndex + 1) {
val nextIndex = media.selected!!.sourceIndex + 1
binding.animeSource.setText(binding.animeSource.adapter
.getItem(nextIndex).toString(), false)
fragment.onSourceChange(nextIndex).apply {
binding.animeSourceTitle.text = showUserText
showUserTextListener = { MainScope().launch { binding.animeSourceTitle.text = it } }
binding.animeSourceDubbed.isChecked = selectDub
binding.animeSourceDubbedCont.isVisible = isDubAvailableSeparately()
setLanguageList(0, nextIndex)
}
subscribeButton(false)
fragment.loadEpisodes(nextIndex, false)
}
}
} else {
binding.animeSourceContinue.visibility = View.GONE
binding.animeSourceNotFound.visibility = View.GONE

View file

@ -481,6 +481,22 @@ class MangaReadAdapter(
val sourceFound = media.manga.chapters!!.isNotEmpty()
binding.animeSourceNotFound.isGone = sourceFound
binding.faqbutton.isGone = sourceFound
if (!sourceFound && PrefManager.getVal(PrefName.SearchSources)) {
if (binding.animeSource.adapter.count > media.selected!!.sourceIndex + 1) {
val nextIndex = media.selected!!.sourceIndex + 1
binding.animeSource.setText(binding.animeSource.adapter
.getItem(nextIndex).toString(), false)
fragment.onSourceChange(nextIndex).apply {
binding.animeSourceTitle.text = showUserText
showUserTextListener = { MainScope().launch { binding.animeSourceTitle.text = it } }
setLanguageList(0, nextIndex)
}
subscribeButton(false)
// invalidate if it's the last source
val invalidate = nextIndex == mangaReadSources.names.size - 1
fragment.loadChapters(nextIndex, invalidate)
}
}
} else {
binding.animeSourceContinue.visibility = View.GONE
binding.animeSourceNotFound.visibility = View.GONE

View file

@ -710,6 +710,11 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
PrefManager.setVal(PrefName.ContinueMedia, isChecked)
}
settingsSearchSources.isChecked = PrefManager.getVal(PrefName.SearchSources)
settingsSearchSources.setOnCheckedChangeListener { _, isChecked ->
PrefManager.setVal(PrefName.SearchSources, isChecked)
}
settingsRecentlyListOnly.isChecked = PrefManager.getVal(PrefName.RecentlyListOnly)
settingsRecentlyListOnly.setOnCheckedChangeListener { _, isChecked ->
PrefManager.setVal(PrefName.RecentlyListOnly, isChecked)

View file

@ -15,6 +15,7 @@ enum class PrefName(val data: Pref) { //TODO: Split this into multiple files
NSFWExtension(Pref(Location.General, Boolean::class, true)),
SdDl(Pref(Location.General, Boolean::class, false)),
ContinueMedia(Pref(Location.General, Boolean::class, true)),
SearchSources(Pref(Location.General, Boolean::class, true)),
RecentlyListOnly(Pref(Location.General, Boolean::class, false)),
SettingsPreferDub(Pref(Location.General, Boolean::class, false)),
SubscriptionCheckingNotifications(Pref(Location.General, Boolean::class, true)),