From b2a65a4f3c92b65f02ffef54f5c55bd24b164c37 Mon Sep 17 00:00:00 2001 From: fankesyooni Date: Sun, 22 Oct 2023 22:38:16 +0800 Subject: [PATCH] fix: catch toast when no looper --- .../fankes/coloros/notify/utils/factory/FunctionFactory.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/fankes/coloros/notify/utils/factory/FunctionFactory.kt b/app/src/main/java/com/fankes/coloros/notify/utils/factory/FunctionFactory.kt index 21c728c..ec1ef2a 100644 --- a/app/src/main/java/com/fankes/coloros/notify/utils/factory/FunctionFactory.kt +++ b/app/src/main/java/com/fankes/coloros/notify/utils/factory/FunctionFactory.kt @@ -62,6 +62,7 @@ import com.highcapable.yukihookapi.hook.factory.field import com.highcapable.yukihookapi.hook.factory.hasClass import com.highcapable.yukihookapi.hook.factory.method import com.highcapable.yukihookapi.hook.factory.toClassOrNull +import com.highcapable.yukihookapi.hook.log.YLog import com.highcapable.yukihookapi.hook.type.java.StringClass import com.highcapable.yukihookapi.hook.xposed.application.ModuleApplication.Companion.appContext import com.topjohnwu.superuser.Shell @@ -445,7 +446,11 @@ fun execShell(cmd: String, isSu: Boolean = true) = safeOfNothing { * 弹出 [Toast] * @param msg 提示内容 */ -fun toast(msg: String) = Toast.makeText(appContext, msg, Toast.LENGTH_SHORT).show() +fun toast(msg: String) { + runCatching { + Toast.makeText(appContext, msg, Toast.LENGTH_SHORT).show() + }.onFailure { YLog.warn(msg) } +} /** * 跳转到指定页面