diff --git a/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryListParser.kt b/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryListParser.kt index d6ca9f5cf..7381df195 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryListParser.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryListParser.kt @@ -1,9 +1,12 @@ package com.hippo.ehviewer.client.parser import com.hippo.ehviewer.EhDB +import com.hippo.ehviewer.R import com.hippo.ehviewer.client.data.BaseGalleryInfo import com.hippo.ehviewer.client.data.GalleryInfo.Companion.LOCAL_FAVORITED import com.hippo.ehviewer.client.data.GalleryInfo.Companion.NOT_FAVORITED +import com.hippo.ehviewer.client.exception.EhException +import com.hippo.ehviewer.client.exception.ParseException object GalleryListParser { suspend fun parse(body: String) = runCatching { @@ -15,13 +18,21 @@ object GalleryListParser { it.generateSLang() } } - }.getOrDefault(GalleryListResult()) + }.getOrElse { + if (body.contains("

You do not have any watched tags")) { + throw EhException(R.string.gallery_list_empty_hit_subscription) + } + if (body.contains("No hits found

")) { + throw EhException(R.string.gallery_list_empty_hit) + } + throw ParseException("Can't parse gallery list", body, it) + } } class GalleryListResult( - val prev: String? = null, - val next: String? = null, - val galleryInfoList: ArrayList = arrayListOf(), + val prev: String?, + val next: String?, + val galleryInfoList: ArrayList, ) private external fun parseGalleryInfoList(e: String): GalleryListResult diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.kt b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.kt index 2cfbfbd44..f5649faaa 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.kt @@ -365,7 +365,6 @@ class GalleryListScene : SearchBarScene() { binding.refreshLayout.setOnRefreshListener { mAdapter?.refresh() } val transition = ViewTransition(binding.refreshLayout, binding.progress, binding.tip) val empty = getString(R.string.gallery_list_empty_hit) - val noWatch = getString(R.string.gallery_list_empty_hit_subscription) adapter.addLoadStateListener { viewLifecycleOwner.lifecycleScope.launchUI { ensureActive() @@ -395,11 +394,7 @@ class GalleryListScene : SearchBarScene() { delay(500) binding.refreshLayout.isRefreshing = false if (mAdapter?.itemCount == 0) { - if (mUrlBuilder.mode == MODE_SUBSCRIPTION) { - binding.tip.text = noWatch - } else { - binding.tip.text = empty - } + binding.tip.text = empty transition.showView(2) } else { transition.showView(0)