companion object {
val handler by lazy {
Handler(Looper.getMainLooper())
}
}
//函数
fun uiThread(f:()->Unit){
handler.post { f() }
}
by lazy is used to initialize the objects and instances that are currently needed; decorated with val
Use the static keyword in java to modify static methods. Static methods can be called in the form of class name. Method name [this is obvious in the singleton]
In kotlin, object is used to modify static classes , and the modified class can call methods in this class by means of class name and method name.
Comapnion object is used in kotlin to decorate static methods , which can be called by class name.method name