Kill GalleryDetailScene voteTag callback

This commit is contained in:
tarsin committed 2023-04-22 12:18:10 +08:00
1 parent b310e98c5a
commit 7d74bdc3bd
2 files changed
+14 -43

No files matched your search

@@ -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
}
@@ -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<GalleryDetailScene?, String>(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?,