Kill GalleryListScene GetGalleryListListener
This commit is contained in:
1 parent
f36480d5d6
commit
f02cd58a6b
3 files changed
+31
-70
No files matched your search
@@ -19,7 +19,6 @@ import eu.kanade.tachiyomi.util.lang.launchIO
|
||||
import eu.kanade.tachiyomi.util.lang.withUIContext
|
||||
import kotlinx.coroutines.CancellationException
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import java.io.File
|
||||
|
||||
object EhClient {
|
||||
internal fun enqueue(request: EhRequest, scope: CoroutineScope) {
|
||||
@@ -47,10 +46,6 @@ object EhClient {
|
||||
|
||||
suspend fun execute(method: Int, vararg params: Any?): Any? {
|
||||
return when (method) {
|
||||
METHOD_GET_GALLERY_LIST -> EhEngine.getGalleryList(
|
||||
params[0] as String,
|
||||
)
|
||||
|
||||
METHOD_GET_GALLERY_DETAIL -> EhEngine.getGalleryDetail(
|
||||
params[0] as String,
|
||||
)
|
||||
@@ -91,13 +86,6 @@ object EhClient {
|
||||
params[2] as String?,
|
||||
)
|
||||
|
||||
METHOD_IMAGE_SEARCH -> EhEngine.imageSearch(
|
||||
params[0] as File,
|
||||
params[1] as Boolean,
|
||||
params[2] as Boolean,
|
||||
params[3] as Boolean,
|
||||
)
|
||||
|
||||
METHOD_ARCHIVE_LIST -> EhEngine.getArchiveList(
|
||||
params[0] as String,
|
||||
params[1] as Long,
|
||||
@@ -114,7 +102,6 @@ object EhClient {
|
||||
fun onCancel()
|
||||
}
|
||||
|
||||
const val METHOD_GET_GALLERY_LIST = 1
|
||||
const val METHOD_GET_GALLERY_DETAIL = 3
|
||||
const val METHOD_GET_COMMENT_GALLERY = 6
|
||||
const val METHOD_GET_GALLERY_TOKEN = 7
|
||||
@@ -122,6 +109,5 @@ object EhClient {
|
||||
const val METHOD_ADD_FAVORITES_RANGE = 10
|
||||
const val METHOD_MODIFY_FAVORITES = 11
|
||||
const val METHOD_GET_TORRENT_LIST = 12
|
||||
const val METHOD_IMAGE_SEARCH = 16
|
||||
const val METHOD_ARCHIVE_LIST = 17
|
||||
}
|
||||
@@ -17,7 +17,6 @@ package com.hippo.ehviewer.ui.scene
|
||||
|
||||
import android.animation.Animator
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
import android.content.Intent
|
||||
import android.content.res.Resources
|
||||
@@ -68,8 +67,7 @@ import com.hippo.ehviewer.FavouriteStatusRouter
|
||||
import com.hippo.ehviewer.R
|
||||
import com.hippo.ehviewer.Settings
|
||||
import com.hippo.ehviewer.WindowInsetsAnimationHelper
|
||||
import com.hippo.ehviewer.client.EhClient
|
||||
import com.hippo.ehviewer.client.EhRequest
|
||||
import com.hippo.ehviewer.client.EhEngine
|
||||
import com.hippo.ehviewer.client.EhUtils
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo
|
||||
import com.hippo.ehviewer.client.data.ListUrlBuilder
|
||||
@@ -1100,31 +1098,9 @@ class GalleryListScene :
|
||||
}
|
||||
}
|
||||
|
||||
private fun onGetGalleryListFailure(e: Exception, taskId: Int) {
|
||||
if (mHelper != null && mHelper!!.isCurrentTask(taskId)) {
|
||||
mHelper!!.onGetException(taskId, e)
|
||||
}
|
||||
}
|
||||
|
||||
@IntDef(STATE_NORMAL, STATE_SIMPLE_SEARCH, STATE_SEARCH, STATE_SEARCH_SHOW_LIST)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
private annotation class State
|
||||
private inner class GetGalleryListListener(
|
||||
context: Context,
|
||||
private val mTaskId: Int,
|
||||
) : EhCallback<GalleryListScene, GalleryListParser.Result>(context) {
|
||||
override fun onSuccess(result: GalleryListParser.Result) {
|
||||
val scene = this@GalleryListScene
|
||||
scene.onGetGalleryListSuccess(result, mTaskId)
|
||||
}
|
||||
|
||||
override fun onFailure(e: Exception) {
|
||||
val scene = this@GalleryListScene
|
||||
scene.onGetGalleryListFailure(e, mTaskId)
|
||||
}
|
||||
|
||||
override fun onCancel() {}
|
||||
}
|
||||
|
||||
private class QsDrawerHolder(val binding: ItemDrawerListBinding) :
|
||||
RecyclerView.ViewHolder(binding.root)
|
||||
@@ -1317,34 +1293,28 @@ class GalleryListScene :
|
||||
mUrlBuilder.setIndex(index, isNext)
|
||||
mUrlBuilder.setJumpTo(jumpTo)
|
||||
}
|
||||
if (ListUrlBuilder.MODE_IMAGE_SEARCH == mUrlBuilder.mode) {
|
||||
val request = EhRequest()
|
||||
request.setMethod(EhClient.METHOD_IMAGE_SEARCH)
|
||||
request.setCallback(
|
||||
GetGalleryListListener(
|
||||
context,
|
||||
taskId,
|
||||
),
|
||||
)
|
||||
request.setArgs(
|
||||
File(StringUtils.avoidNull(mUrlBuilder.imagePath)),
|
||||
mUrlBuilder.isUseSimilarityScan,
|
||||
mUrlBuilder.isOnlySearchCovers,
|
||||
mUrlBuilder.isShowExpunged,
|
||||
)
|
||||
request.enqueue(this@GalleryListScene)
|
||||
} else {
|
||||
val url = mUrlBuilder.build()
|
||||
val request = EhRequest()
|
||||
request.setMethod(EhClient.METHOD_GET_GALLERY_LIST)
|
||||
request.setCallback(
|
||||
GetGalleryListListener(
|
||||
context,
|
||||
taskId,
|
||||
),
|
||||
)
|
||||
request.setArgs(url)
|
||||
request.enqueue(this@GalleryListScene)
|
||||
lifecycleScope.launchIO {
|
||||
runSuspendCatching {
|
||||
if (ListUrlBuilder.MODE_IMAGE_SEARCH == mUrlBuilder.mode) {
|
||||
EhEngine.imageSearch(
|
||||
File(StringUtils.avoidNull(mUrlBuilder.imagePath)),
|
||||
mUrlBuilder.isUseSimilarityScan,
|
||||
mUrlBuilder.isOnlySearchCovers,
|
||||
mUrlBuilder.isShowExpunged,
|
||||
)
|
||||
} else {
|
||||
val url = mUrlBuilder.build()
|
||||
EhEngine.getGalleryList(url)
|
||||
}
|
||||
}.onSuccess {
|
||||
withUIContext {
|
||||
onGetGalleryListSuccess(it, taskId)
|
||||
}
|
||||
}.onFailure { throwable ->
|
||||
withUIContext {
|
||||
mHelper?.takeIf { it.isCurrentTask(taskId) }?.onGetException(taskId, throwable)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ import com.hippo.widget.ContentLayout.ContentHelper
|
||||
import com.hippo.widget.recyclerview.AutoGridLayoutManager
|
||||
import com.hippo.widget.recyclerview.STRATEGY_SUITABLE_SIZE
|
||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||
import eu.kanade.tachiyomi.util.lang.withUIContext
|
||||
import moe.tarsin.coroutines.runSuspendCatching
|
||||
import java.util.Locale
|
||||
|
||||
@@ -190,9 +191,13 @@ class GalleryPreviewsScene : BaseToolbarScene() {
|
||||
}
|
||||
}
|
||||
}
|
||||
mHelper?.takeIf { it.isCurrentTask(taskId) }?.run { onGetPageData(taskId, result.second, 0, null, null, result.first) }
|
||||
}.onFailure {
|
||||
mHelper?.takeIf { it.isCurrentTask(taskId) }?.run { onGetException(taskId, it) }
|
||||
withUIContext {
|
||||
mHelper?.takeIf { it.isCurrentTask(taskId) }?.onGetPageData(taskId, result.second, 0, null, null, result.first)
|
||||
}
|
||||
}.onFailure { throwable ->
|
||||
withUIContext {
|
||||
mHelper?.takeIf { it.isCurrentTask(taskId) }?.onGetException(taskId, throwable)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user