refactor(utils): 简化 toast 扩展函数实现

- 移除多余的 null 检查代码块
- 删除已注释的旧版 toast 实现
- 简化条件判断语法
- 保留 ToastUtil 统一调用方式
This commit is contained in:
2026-05-19 15:38:52 +08:00
parent 1140d6bf91
commit ea79e584f3
@@ -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
}