/**
* 打开等待框
*/
fun Fragment.showLoadingExt(message: String = "请求网络中...") {
dismissLoadingExt()
activity?.let {
if (!it.isFinishing) {
if (loadingDialog == null) {
//弹出loading时 把当前界面的输入法关闭
it.hideOffKeyboard()
loadingDialog = Dialog(requireActivity(), R.style.loadingDialogTheme).apply {
setCancelable(true)
setCanceledOnTouchOutside(false)
setContentView(
LayoutInflater.from(it)
.inflate(R.layout.layout_loading_view, null).apply {
this.findViewById<TextView>(R.id.loading_tips).text = message
})
}
loadingDialog?.setOnDismissListener {
//设置dialog关闭时 置空 不然会出现 一个隐藏bug 这里就不细说了
dismissLoadingExt()
}
}
loadingDialog?.show()
}
}
}