diff --git a/app/src/main/java/com/hippo/ehviewer/client/EhUtils.kt b/app/src/main/java/com/hippo/ehviewer/client/EhUtils.kt index 2a079bb12..879e703c9 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/EhUtils.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/EhUtils.kt @@ -80,6 +80,22 @@ object EhUtils { return CATEGORY_VALUES.getOrDefault(type, CATEGORY_VALUES[UNKNOWN])!![0] } + fun getCategoryColorNullable(category: Int): Int? { + return when (category) { + EhConfig.DOUJINSHI -> BG_COLOR_DOUJINSHI + EhConfig.MANGA -> BG_COLOR_MANGA + EhConfig.ARTIST_CG -> BG_COLOR_ARTIST_CG + EhConfig.GAME_CG -> BG_COLOR_GAME_CG + EhConfig.WESTERN -> BG_COLOR_WESTERN + EhConfig.NON_H -> BG_COLOR_NON_H + EhConfig.IMAGE_SET -> BG_COLOR_IMAGE_SET + EhConfig.COSPLAY -> BG_COLOR_COSPLAY + EhConfig.ASIAN_PORN -> BG_COLOR_ASIAN_PORN + EhConfig.MISC -> BG_COLOR_MISC + else -> null + }?.toInt() + } + fun getCategoryColor(category: Int): Int { return when (category) { EhConfig.DOUJINSHI -> BG_COLOR_DOUJINSHI diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.kt b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.kt index 4d51959f2..6bbcc3e65 100755 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.kt @@ -573,7 +573,7 @@ class GalleryDetailScene : CollapsingToolbarScene(), View.OnClickListener, Downl uploader.text = gd.uploader uploader.alpha = if (gd.disowned) .5f else 1f category.text = EhUtils.getCategory(gd.category) - category.setTextColor(EhUtils.getCategoryColor(gd.category)) + EhUtils.getCategoryColorNullable(gd.category)?.let { category.setTextColor(it) } } updateDownloadText() binding.content.header.run {