From e65fa8d565108690dbc1d2cea2969cd7bb0f2fe5 Mon Sep 17 00:00:00 2001 From: Finnley Somdahl <87634197+rebelonion@users.noreply.github.com> Date: Sat, 13 Jan 2024 12:24:18 -0600 Subject: [PATCH] exoplayer string fix --- .../main/java/ani/dantotsu/media/anime/AnimeNameAdapter.kt | 5 +++++ app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/ani/dantotsu/media/anime/AnimeNameAdapter.kt b/app/src/main/java/ani/dantotsu/media/anime/AnimeNameAdapter.kt index 5fbed91a3e..050e58a4d7 100644 --- a/app/src/main/java/ani/dantotsu/media/anime/AnimeNameAdapter.kt +++ b/app/src/main/java/ani/dantotsu/media/anime/AnimeNameAdapter.kt @@ -37,5 +37,10 @@ class AnimeNameAdapter { text } } + + fun removeEpisodeNumberCompletely(text: String): String { + val regexPattern = Regex(episodeRegex, RegexOption.IGNORE_CASE) + return text.replace(regexPattern, "") + } } } 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 231077f84b..ae9641d37c 100644 --- a/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt +++ b/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt @@ -955,7 +955,8 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL val episodeTitleArr = arrayListOf() episodes.forEach { val episode = it.value - episodeTitleArr.add("${if (!episode.title.isNullOrEmpty() && episode.title != "null") "" else "numeric :"}${episode.number}${if (episode.filler) " [Filler]" else ""}${if (!episode.title.isNullOrEmpty() && episode.title != "null") " : " + episode.title else ""}") + val cleanedTitle = AnimeNameAdapter.removeEpisodeNumberCompletely(episode.title ?: "") + episodeTitleArr.add("Episode ${episode.number}${if (episode.filler) " [Filler]" else ""}${if (cleanedTitle.isNotEmpty() && cleanedTitle != "null") ": $cleanedTitle" else ""}") } for (i in episodeTitleArr.indices) {