fix: catch toast when no looper

This commit is contained in:
2023-10-22 22:38:16 +08:00
parent 799d758671
commit b2a65a4f3c

View File

@@ -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) }
}
/**
* 跳转到指定页面