diff --git a/app/src/main/java/com/hippo/ehviewer/client/EhClient.kt b/app/src/main/java/com/hippo/ehviewer/client/EhClient.kt index c214eeb99..931f7311e 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/EhClient.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/EhClient.kt @@ -133,15 +133,6 @@ object EhClient { params[4] as Boolean, ) - METHOD_VOTE_TAG -> EhEngine.voteTag( - params[0] as Long, - params[1] as String?, - params[2] as Long, - params[3] as String?, - params[4] as String?, - params[5] as Int, - ) - else -> throw IllegalStateException("Can't detect method $method") } } @@ -166,5 +157,4 @@ object EhClient { const val METHOD_IMAGE_SEARCH = 16 const val METHOD_ARCHIVE_LIST = 17 const val METHOD_DOWNLOAD_ARCHIVE = 18 - const val METHOD_VOTE_TAG = 19 } diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.kt b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.kt index 5e2cb6ce3..8017d28ed 100755 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.kt @@ -1391,23 +1391,21 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { } private fun voteTag(tag: String, vote: Int) { - val context = context - val activity = mainActivity - if (null == context || null == activity) { - return + composeBindingGD?.run { + lifecycleScope.launchIO { + runSuspendCatching { + EhEngine.voteTag(apiUid, apiKey, gid, token, tag, vote) + }.onSuccess { result -> + if (result.isNotEmpty()) { + showTip(result, LENGTH_SHORT) + } else { + showTip(R.string.tag_vote_successfully, LENGTH_SHORT) + } + }.onFailure { + showTip(R.string.vote_failed, LENGTH_LONG) + } + } } - val request = EhRequest() - .setMethod(EhClient.METHOD_VOTE_TAG) - .setArgs( - composeBindingGD!!.apiUid, - composeBindingGD!!.apiKey!!, - composeBindingGD!!.gid, - composeBindingGD!!.token!!, - tag, - vote, - ) - .setCallback(VoteTagListener(context)) - request.enqueue(this) } private fun downloadLongClick() { @@ -1545,23 +1543,6 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { } } - private class VoteTagListener(context: Context) : - EhCallback(context) { - override fun onSuccess(result: String) { - if (result.isNotEmpty()) { - showTip(result, LENGTH_SHORT) - } else { - showTip(R.string.tag_vote_successfully, LENGTH_SHORT) - } - } - - override fun onFailure(e: Exception) { - showTip(R.string.vote_failed, LENGTH_LONG) - } - - override fun onCancel() {} - } - private class DownloadArchiveListener( context: Context, private val mGalleryInfo: GalleryInfo?,