chore: code refactor

This commit is contained in:
rebelonion 2024-02-06 02:16:10 -06:00
parent 8d7b86a667
commit a2e44da99d
334 changed files with 3550 additions and 3092 deletions

View file

@ -181,7 +181,11 @@ abstract class AnimeParser : BaseParser() {
override suspend fun loadSavedShowResponse(mediaId: Int): ShowResponse? {
checkIfVariablesAreEmpty()
val dub = if (isDubAvailableSeparately()) "_${if (selectDub) "dub" else "sub"}" else ""
var loaded = PrefManager.getNullableCustomVal("${saveName}${dub}_$mediaId", null, ShowResponse::class.java)
var loaded = PrefManager.getNullableCustomVal(
"${saveName}${dub}_$mediaId",
null,
ShowResponse::class.java
)
if (loaded == null && malSyncBackupName.isNotEmpty())
loaded = MalSyncBackup.get(mediaId, malSyncBackupName, selectDub)
?.also { saveShowResponse(mediaId, it, true) }

View file

@ -1,6 +1,5 @@
package ani.dantotsu.parsers
import android.content.Context
import ani.dantotsu.Lazier
import ani.dantotsu.lazyList
import ani.dantotsu.settings.saving.PrefManager
@ -14,8 +13,9 @@ object AnimeSources : WatchSources() {
var pinnedAnimeSources: List<String> = emptyList()
suspend fun init(fromExtensions: StateFlow<List<AnimeExtension.Installed>>) {
pinnedAnimeSources = PrefManager.getNullableVal<List<String>>(PrefName.AnimeSourcesOrder, null)
?: emptyList()
pinnedAnimeSources =
PrefManager.getNullableVal<List<String>>(PrefName.AnimeSourcesOrder, null)
?: emptyList()
// Initialize with the first value from StateFlow
val initialExtensions = fromExtensions.first()

View file

@ -134,7 +134,11 @@ abstract class BaseParser {
* **/
open suspend fun loadSavedShowResponse(mediaId: Int): ShowResponse? {
checkIfVariablesAreEmpty()
return PrefManager.getNullableCustomVal("${saveName}_$mediaId", null, ShowResponse::class.java)
return PrefManager.getNullableCustomVal(
"${saveName}_$mediaId",
null,
ShowResponse::class.java
)
}
/**

View file

@ -2,8 +2,8 @@ package ani.dantotsu.parsers
import ani.dantotsu.Lazier
import ani.dantotsu.lazyList
import ani.dantotsu.settings.saving.PrefName
import ani.dantotsu.settings.saving.PrefManager
import ani.dantotsu.settings.saving.PrefName
import eu.kanade.tachiyomi.extension.manga.model.MangaExtension
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.first
@ -13,8 +13,9 @@ object MangaSources : MangaReadSources() {
var pinnedMangaSources: List<String> = emptyList()
suspend fun init(fromExtensions: StateFlow<List<MangaExtension.Installed>>) {
pinnedMangaSources = PrefManager.getNullableVal<List<String>>(PrefName.MangaSourcesOrder, null)
?: emptyList()
pinnedMangaSources =
PrefManager.getNullableVal<List<String>>(PrefName.MangaSourcesOrder, null)
?: emptyList()
// Initialize with the first value from StateFlow
val initialExtensions = fromExtensions.first()

View file

@ -14,8 +14,9 @@ object NovelSources : NovelReadSources() {
var pinnedNovelSources: List<String> = emptyList()
suspend fun init(fromExtensions: StateFlow<List<NovelExtension.Installed>>) {
pinnedNovelSources = PrefManager.getNullableVal<List<String>>(PrefName.NovelSourcesOrder, null)
?: emptyList()
pinnedNovelSources =
PrefManager.getNullableVal<List<String>>(PrefName.NovelSourcesOrder, null)
?: emptyList()
// Initialize with the first value from StateFlow
val initialExtensions = fromExtensions.first()

View file

@ -3,8 +3,8 @@ package ani.dantotsu.parsers.novel
import android.content.Context
import ani.dantotsu.logger
import ani.dantotsu.settings.saving.PrefName
import ani.dantotsu.settings.saving.PrefManager
import ani.dantotsu.settings.saving.PrefName
import eu.kanade.tachiyomi.extension.ExtensionUpdateNotifier
import eu.kanade.tachiyomi.extension.anime.model.AnimeExtension
import eu.kanade.tachiyomi.extension.anime.model.AnimeLoadResult