修复:测试TG/Webhook发送通道时,子线程调用Toast引发FC

This commit is contained in:
pppscn 2022-06-14 19:33:37 +08:00
parent f9a3608500
commit 4a81c0d0a5
2 changed files with 7 additions and 7 deletions

View File

@ -100,9 +100,9 @@ class TelegramUtils {
client.newCall(request).enqueue(object : Callback {
override fun onFailure(call: Call, e: IOException) {
SendUtils.updateLogs(logId, 0, e.message.toString())
e.printStackTrace()
Looper.prepare()
SendUtils.updateLogs(logId, 0, e.message.toString())
//XToastUtils.error("发送失败:" + e.message)
Looper.loop()
}
@ -114,13 +114,13 @@ class TelegramUtils {
val resp = Gson().fromJson(responseStr, TelegramResult::class.java)
if (resp.ok == true) {
SendUtils.updateLogs(logId, 2, responseStr.toString())
Looper.prepare()
SendUtils.updateLogs(logId, 2, responseStr.toString())
//XToastUtils.success(ResUtils.getString(R.string.request_succeeded))
Looper.loop()
} else {
SendUtils.updateLogs(logId, 0, responseStr.toString())
Looper.prepare()
SendUtils.updateLogs(logId, 0, responseStr.toString())
//XToastUtils.error(ResUtils.getString(R.string.request_failed) + response)
Looper.loop()
}

View File

@ -160,10 +160,10 @@ class WebhookUtils {
client.newCall(requestBuilder.build()).enqueue(object : Callback {
override fun onFailure(call: Call, e: IOException) {
SendUtils.updateLogs(logId, 0, e.message.toString())
//LogUtils.updateLog(logId, 0, e.message)
//解决在子线程中调用Toast的异常情况处理
Looper.prepare()
e.printStackTrace()
SendUtils.updateLogs(logId, 0, e.message.toString())
//XToastUtils.error(ResUtils.getString(R.string.request_failed) + e.message)
Looper.loop()
}
@ -175,13 +175,13 @@ class WebhookUtils {
//返回http状态200即为成功
if (200 == response.code()) {
SendUtils.updateLogs(logId, 2, responseStr)
Looper.prepare()
SendUtils.updateLogs(logId, 2, responseStr)
//XToastUtils.success(ResUtils.getString(R.string.request_succeeded))
Looper.loop()
} else {
SendUtils.updateLogs(logId, 0, responseStr)
Looper.prepare()
SendUtils.updateLogs(logId, 0, responseStr)
//XToastUtils.error(ResUtils.getString(R.string.request_failed) + response)
Looper.loop()
}