使用 Looper.getMainLooper().thread === Thread.currentThread() 进行检测是否为主线程
if (Looper.getMainLooper().thread === Thread.currentThread()){
println("主线程")
// 更新UI
// ...
}else{
println("子线程")
Handler(Looper.getMainLooper()).post {
// 更新UI
// ...
}
}