Minor tweaks

This commit is contained in:
FooIbar authored and tarsin committed 2023-08-01 21:04:22 +08:00
1 parent 42c56616fb
commit 10040b2923
5 files changed
+17 -23

No files matched your search

@@ -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() }
@@ -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")
}
@@ -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" />
@@ -143,6 +143,7 @@
<string name="no_more_previews">已显示所有预览</string>
<string name="more_previews">查看更多预览</string>
<string name="refresh">刷新</string>
<string name="refresh_original">刷新(原图)</string>
<string name="open_in_other_app">在其他应用中打开</string>
<string name="rate_successfully">评分成功</string>
<string name="rate_failed">评分失败</string>
+1
View File
@@ -185,6 +185,7 @@
<string name="no_more_previews">No more previews</string>
<string name="more_previews">More previews</string>
<string name="refresh">Refresh</string>
<string name="refresh_original">Refresh (Original image)</string>
<string name="open_in_other_app">Open with other app</string>
<string name="rate_successfully">Rate successfully</string>
<string name="rate_failed">Rate failed</string>