diff --git a/app/src/main/java/com/hippo/ehviewer/spider/SpiderDen.kt b/app/src/main/java/com/hippo/ehviewer/spider/SpiderDen.kt index a42e67864..368581798 100644 --- a/app/src/main/java/com/hippo/ehviewer/spider/SpiderDen.kt +++ b/app/src/main/java/com/hippo/ehviewer/spider/SpiderDen.kt @@ -143,6 +143,7 @@ class SpiderDen(mGalleryInfo: GalleryInfo) { saveResponseMeta(index, type, length) { file -> file.openOutputStream().use { os -> val chan = os.channel + chan.truncate(0) copyToChannel(chan) { notifyProgress(length, info.receivedByteCount, it) } @@ -232,10 +233,6 @@ class SpiderDen(mGalleryInfo: GalleryInfo) { return false } - fun checkPlainText(index: Int): Boolean { - return false - } - fun getExtension(index: Int): String? { val key = getImageKey(mGid, index) return sCache.read(key) { metadata.toNioPath().readText() } 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 9e41b25c1..c9d7dd9da 100644 --- a/app/src/main/java/com/hippo/ehviewer/spider/SpiderQueen.kt +++ b/app/src/main/java/com/hippo/ehviewer/spider/SpiderQueen.kt @@ -41,6 +41,7 @@ import com.hippo.ehviewer.image.Image import com.hippo.ehviewer.util.ExceptionUtils import com.hippo.unifile.UniFile import eu.kanade.tachiyomi.util.lang.launchIO +import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job @@ -556,13 +557,6 @@ class SpiderQueen private constructor(val galleryInfo: GalleryInfo) : CoroutineS mSemaphore.withPermit { doInJob(index, force, orgImg) } - }.apply { - invokeOnCompletion { - if (getPageState(index) == STATE_DOWNLOADING) { - Log.d(WORKER_DEBUG_TAG, "Download image cancelled $index") - mSpiderDen.remove(index) - } - } } } } @@ -724,7 +718,7 @@ class SpiderQueen private constructor(val galleryInfo: GalleryInfo) : CoroutineS } Log.d(WORKER_DEBUG_TAG, targetImageUrl) - runSuspendCatching { + runCatching { Log.d(WORKER_DEBUG_TAG, "Start download image $index") val success: Boolean = mSpiderDen.makeHttpCallAndSaveImage( index, @@ -741,21 +735,22 @@ class SpiderQueen private constructor(val galleryInfo: GalleryInfo) : CoroutineS continue@loop } - if (mSpiderDen.checkPlainText(index)) { - error = "" - forceHtml = true - continue@loop - } - Log.d(WORKER_DEBUG_TAG, "Download image succeed $index") - updatePageState(index, STATE_FINISHED) delay(mDownloadDelay.toLong()) return }.onFailure { - it.printStackTrace() - error = NETWORK_ERROR - forceHtml = true + if (it is CancellationException) { + Log.d(WORKER_DEBUG_TAG, "Download image cancelled $index") + error = "Cancelled" + mSpiderDen.remove(index) + updatePageState(index, STATE_FAILED, error) + throw it + } else { + it.printStackTrace() + error = NETWORK_ERROR + forceHtml = true + } } Log.d(WORKER_DEBUG_TAG, "End download image $index") } diff --git a/app/src/main/res/layout/reader_page_sheet.xml b/app/src/main/res/layout/reader_page_sheet.xml index e1757f7cb..d35d6ba3d 100644 --- a/app/src/main/res/layout/reader_page_sheet.xml +++ b/app/src/main/res/layout/reader_page_sheet.xml @@ -30,7 +30,7 @@ android:focusable="true" android:paddingHorizontal="16dp" android:foreground="?attr/selectableItemBackground" - android:text="@string/settings_download_download_origin_image" + android:text="@string/refresh_original" android:textColor="?attr/colorOnBackground" app:drawableStartCompat="@drawable/v_refresh_dark_x24" app:drawableTint="?attr/colorOnBackground" /> diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 13e7cbbb4..fa9804384 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -143,6 +143,7 @@ 已显示所有预览 查看更多预览 刷新 + 刷新(原图) 在其他应用中打开 评分成功 评分失败 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1904be5a7..45522359c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -185,6 +185,7 @@ No more previews More previews Refresh + Refresh (Original image) Open with other app Rate successfully Rate failed