diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Manga.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Manga.kt index 128fd5ae8..ac91a41da 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Manga.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Manga.kt @@ -28,6 +28,10 @@ interface Manga : SManga { return chapter_flags and SORT_MASK == SORT_DESC } + fun getGenres(): List? { + return genre?.split(", ")?.map { it.trim() } + } + // Used to display the chapter's title one way or another var displayMode: Int get() = chapter_flags and DISPLAY_MASK diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryItem.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryItem.kt index 596f476ae..98adf0595 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryItem.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryItem.kt @@ -70,10 +70,9 @@ class LibraryItem(val manga: LibraryManga, private val libraryAsList: Preference (manga.artist?.contains(constraint, true) ?: false) || sourceManager.getOrStub(manga.source).name.contains(constraint, true) || if (constraint.contains(",")) { - val genres = manga.genre?.split(", ") - constraint.split(",").all { containsGenre(it.trim(), genres) } + constraint.split(",").all { containsGenre(it.trim(), manga.getGenres()) } } else { - containsGenre(constraint, manga.genre?.split(", ")) + containsGenre(constraint, manga.getGenres()) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt index 6228b6b77..cc8a2147f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt @@ -245,16 +245,14 @@ class MangaInfoController : NucleusController(), if (!manga.genre.isNullOrBlank()) { binding.mangaGenresTags.removeAllViews() - manga.genre?.split(", ").orEmpty() - .map { it.trim() } - .forEach { genre -> - val chip = Chip(view.context).apply { - text = genre - setOnClickListener { performSearch(genre) } - } - - binding.mangaGenresTags.addView(chip) + manga.getGenres()?.forEach { genre -> + val chip = Chip(view.context).apply { + text = genre + setOnClickListener { performSearch(genre) } } + + binding.mangaGenresTags.addView(chip) + } } // Update description TextView.