first commit

This commit is contained in:
fengjignqi
2026-09-17 08:59:24 +08:00
parent ea41ddbe74
commit 6e9b97e42e
149 changed files with 5948 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
package com.juhabi.birds.util
import android.content.Context
import android.widget.Toast
/** Toast 统一管理工具。 */
object ToastUtil {
var isShow = true
private var toast: Toast? = null
fun showShort(context: Context, message: CharSequence) {
show(context, message, Toast.LENGTH_SHORT)
}
fun showShort(context: Context, message: Int) {
show(context, message.toString(), Toast.LENGTH_SHORT)
}
fun showLong(context: Context, message: CharSequence) {
show(context, message, Toast.LENGTH_LONG)
}
fun showLong(context: Context, message: Int) {
show(context, message.toString(), Toast.LENGTH_LONG)
}
fun show(context: Context, message: CharSequence, duration: Int) {
val currentToast = toast
if (currentToast == null) {
toast = Toast.makeText(context, message, duration)
} else {
currentToast.setText(message)
currentToast.duration = duration
}
toast?.show()
}
fun show(context: Context, message: Int, duration: Int) {
show(context, message.toString(), duration)
}
}