管灌系统巡查员智能手机App
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package cc.shinichi.library.tool.common
 
import android.content.Context
import android.os.Handler
import android.os.Looper
import android.widget.Toast
 
/**
 * @author 工藤
 * @email qinglingou@gmail.com
 */
class ToastUtil {
 
    fun showShort(context: Context, text: String?) {
        HANDLER.post { Toast.makeText(context.applicationContext, text, Toast.LENGTH_SHORT).show() }
    }
 
    fun showLong(context: Context, text: String?) {
        HANDLER.post { Toast.makeText(context.applicationContext, text, Toast.LENGTH_LONG).show() }
    }
 
    private object InnerClass {
        val instance = ToastUtil()
    }
 
    companion object {
        private val HANDLER = Handler(Looper.getMainLooper())
 
        @JvmStatic
        val instance: ToastUtil
            get() = InnerClass.instance
    }
}