From ea79e584f3ea9beca2ab1fe12a7f012d3c842524 Mon Sep 17 00:00:00 2001 From: lvmeng <848755140@qq.com> Date: Tue, 19 May 2026 15:38:52 +0800 Subject: [PATCH] =?UTF-8?q?refactor(utils):=20=E7=AE=80=E5=8C=96=20toast?= =?UTF-8?q?=20=E6=89=A9=E5=B1=95=E5=87=BD=E6=95=B0=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除多余的 null 检查代码块 - 删除已注释的旧版 toast 实现 - 简化条件判断语法 - 保留 ToastUtil 统一调用方式 --- .../com/shuwei/dish/match/utils/ext/Common.kt | 27 +------------------ 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/app/src/main/java/com/shuwei/dish/match/utils/ext/Common.kt b/app/src/main/java/com/shuwei/dish/match/utils/ext/Common.kt index bc2c7cd..db97b83 100644 --- a/app/src/main/java/com/shuwei/dish/match/utils/ext/Common.kt +++ b/app/src/main/java/com/shuwei/dish/match/utils/ext/Common.kt @@ -31,10 +31,7 @@ fun Context.toast( message: String?, duration: Int = Toast.LENGTH_SHORT, ) { - if (message.isNullOrBlank()) { - return - } - //Toast.makeText(this, message, duration).show() + if (message.isNullOrBlank()) return ToastUtil.show(this, message, duration) } @@ -45,28 +42,6 @@ fun Fragment.toast( activity?.toast(message, duration) } -//fun Fragment.toast( -// message: String?, -// duration: Int = 2000 -//) { -// if (isAdded.not()) { -// return -// } -// CustomToast( -// activity = requireActivity(), -// message = message, -// duration = duration -// ).show() -//} -// -//public fun BaseActivity.toast(message: String?, duration: Int = 2000) { -// CustomToast( -// activity = this, -// message = message, -// duration = duration -// ).show() -//} - fun View.visible() { visibility = View.VISIBLE }