diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 7871fc977..1af2e03a3 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -106,6 +106,7 @@ android { "-progressive", "-Xjvm-default=all", "-Xlambdas=indy", + "-XXLanguage:+BreakContinueInInlineLambdas", "-opt-in=coil.annotation.ExperimentalCoilApi", "-opt-in=androidx.compose.foundation.layout.ExperimentalLayoutApi", diff --git a/app/src/main/java/com/hippo/ehviewer/spider/SpiderQueen.kt b/app/src/main/java/com/hippo/ehviewer/spider/SpiderQueen.kt index 6e24259d2..134fc3057 100644 --- a/app/src/main/java/com/hippo/ehviewer/spider/SpiderQueen.kt +++ b/app/src/main/java/com/hippo/ehviewer/spider/SpiderQueen.kt @@ -624,14 +624,14 @@ class SpiderQueen private constructor(val galleryInfo: GalleryInfo) : CoroutineS var error: String? = null var forceHtml = false var leakSkipHathKey = false - repeat(3) { + loop@ for (i in 1..3) { var imageUrl: String? = null var localShowKey: String? showKeyLock.withLock { localShowKey = showKey if (localShowKey == null || forceHtml) { - if (leakSkipHathKey) return@repeat + if (leakSkipHathKey) break var pageUrl = EhUrl.getPageUrl(mSpiderInfo.gid, index, pToken) // Add skipHathKey if (skipHathKey != null) { @@ -648,7 +648,7 @@ class SpiderQueen private constructor(val galleryInfo: GalleryInfo) : CoroutineS // Get 509 notifyGet509(index) error = ERROR_509 - return@repeat + break@loop } } }.onSuccess { result -> @@ -670,14 +670,8 @@ class SpiderQueen private constructor(val galleryInfo: GalleryInfo) : CoroutineS showKey = result.showKey }.onFailure { - if (it is ParseException && "Key mismatch" == it.message) { - // Show key is wrong, enter a new loop to get the new show key - if (showKey == localShowKey) showKey = null - return@repeat - } else { - error = ExceptionUtils.getReadableString(it) - return@repeat - } + error = ExceptionUtils.getReadableString(it) + break } } } @@ -685,7 +679,7 @@ class SpiderQueen private constructor(val galleryInfo: GalleryInfo) : CoroutineS if (imageUrl == null) { if (localShowKey == null) { error = "ShowKey error" - return@repeat + break } runSuspendCatching { EhEngine.getGalleryPageApi( @@ -699,17 +693,18 @@ class SpiderQueen private constructor(val galleryInfo: GalleryInfo) : CoroutineS // Get 509 notifyGet509(index) error = ERROR_509 - return@repeat + break@loop } } }.onFailure { if (it is ParseException && "Key mismatch" == it.message) { // Show key is wrong, enter a new loop to get the new show key if (showKey == localShowKey) showKey = null + continue } else { error = ExceptionUtils.getReadableString(it) + break } - return@repeat }.onSuccess { imageUrl = it.imageUrl skipHathKey = it.skipHathKey @@ -729,7 +724,7 @@ class SpiderQueen private constructor(val galleryInfo: GalleryInfo) : CoroutineS } if (targetImageUrl == null) { error = "TargetImageUrl error" - return@repeat + break } Log.d(WORKER_DEBUG_TAG, targetImageUrl) @@ -748,13 +743,13 @@ class SpiderQueen private constructor(val galleryInfo: GalleryInfo) : CoroutineS Log.e(WORKER_DEBUG_TAG, "Can't download all of image data") error = "Incomplete" forceHtml = true - return@repeat + continue@loop } if (mSpiderDen.checkPlainText(index)) { error = "" forceHtml = true - return@repeat + continue@loop } Log.d(WORKER_DEBUG_TAG, "Download image succeed $index")