From 458f4d1ff9453b50a08afed429f3c93ef1bd4ba7 Mon Sep 17 00:00:00 2001 From: rebelonion <87634197+rebelonion@users.noreply.github.com> Date: Wed, 21 Feb 2024 23:32:53 -0600 Subject: [PATCH] fix: most recent watch at beginning of list --- .../connections/anilist/AnilistQueries.kt | 22 +++++++++++++------ .../ani/dantotsu/media/anime/ExoplayerView.kt | 8 +++---- .../dantotsu/settings/saving/Preferences.kt | 4 ++-- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/ani/dantotsu/connections/anilist/AnilistQueries.kt b/app/src/main/java/ani/dantotsu/connections/anilist/AnilistQueries.kt index 35289fc7ef..fbeddf2c82 100644 --- a/app/src/main/java/ani/dantotsu/connections/anilist/AnilistQueries.kt +++ b/app/src/main/java/ani/dantotsu/connections/anilist/AnilistQueries.kt @@ -301,10 +301,14 @@ class AnilistQueries { } } } - val set = PrefManager.getCustomVal>("continue_$type", setOf()).toMutableSet() + if (type != "ANIME") { + returnArray.addAll(map.values) + return returnArray + } + val set = PrefManager.getVal>(PrefName.ContinuedAnimeSet).toMutableSet() if (set.isNotEmpty()) { - set.reversed().forEach { - if (map.containsKey(it)) returnArray.add(map[it]!!) + set.forEach { + if (map.containsKey(it.toInt())) returnArray.add(map[it.toInt()]!!) } for (i in map) { if (i.value !in returnArray) returnArray.add(i.value) @@ -448,11 +452,15 @@ class AnilistQueries { subMap[m.id] = m } } - val set = PrefManager.getCustomVal>("continue_${type.uppercase()}", setOf()) - .toMutableSet() + if (type != "Anime") { + returnArray.addAll(subMap.values) + returnMap["current$type"] = returnArray + return + } + val set = PrefManager.getVal>(PrefName.ContinuedAnimeSet).toMutableSet() if (set.isNotEmpty()) { - set.reversed().forEach { - if (subMap.containsKey(it)) returnArray.add(subMap[it]!!) + set.forEach { + if (subMap.containsKey(it.toInt())) returnArray.add(subMap[it.toInt()]!!) } for (i in subMap) { if (i.value !in returnArray) returnArray.add(i.value) diff --git a/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt b/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt index e86c560c5d..5ac83c8927 100644 --- a/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt +++ b/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt @@ -1245,10 +1245,10 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL media.anime!!.selectedEpisode!! ) - val list = PrefManager.getVal>(PrefName.ContinuedAnime).toMutableList() - if (list.contains(media.id)) list.remove(media.id) - list.add(media.id) - PrefManager.setVal(PrefName.ContinuedAnime, list.toList()) + val list = PrefManager.getVal>(PrefName.ContinuedAnimeSet).toMutableList() + if (list.contains(media.id.toString())) list.remove(media.id.toString()) + list.add(media.id.toString()) + PrefManager.setVal(PrefName.ContinuedAnimeSet, list.toSet()) lifecycleScope.launch(Dispatchers.IO) { extractor?.onVideoStopped(video) diff --git a/app/src/main/java/ani/dantotsu/settings/saving/Preferences.kt b/app/src/main/java/ani/dantotsu/settings/saving/Preferences.kt index ca3434e6be..728474820b 100644 --- a/app/src/main/java/ani/dantotsu/settings/saving/Preferences.kt +++ b/app/src/main/java/ani/dantotsu/settings/saving/Preferences.kt @@ -10,7 +10,7 @@ enum class PrefName(val data: Pref) { //TODO: Split this into multiple files SharedUserID(Pref(Location.General, Boolean::class, true)), OfflineView(Pref(Location.General, Int::class, 0)), DownloadManager(Pref(Location.General, Int::class, 0)), - NSFWExtension(Pref(Location.General, Boolean::class, false)), + NSFWExtension(Pref(Location.General, Boolean::class, true)), SdDl(Pref(Location.General, Boolean::class, false)), ContinueMedia(Pref(Location.General, Boolean::class, true)), RecentlyListOnly(Pref(Location.General, Boolean::class, false)), @@ -98,7 +98,7 @@ enum class PrefName(val data: Pref) { //TODO: Split this into multiple files UseInternalCast(Pref(Location.Player, Boolean::class, false)), Pip(Pref(Location.Player, Boolean::class, true)), RotationPlayer(Pref(Location.Player, Boolean::class, true)), - ContinuedAnime(Pref(Location.Player, List::class, listOf())), + ContinuedAnimeSet(Pref(Location.Player, Set::class, setOf())), //Reader ShowSource(Pref(Location.Reader, Boolean::class, true)),