调整了部分问题
This commit is contained in:
@@ -8,9 +8,13 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import com.sw.platecabinet.R
|
||||
import com.sw.platecabinet.view.CustomDialog
|
||||
import com.sw.platecabinet.viewmodel.SettingViewModel
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
abstract class BaseFragment<VB : ViewBinding>(
|
||||
private val bindingInflater: (inflater: LayoutInflater, parent: ViewGroup?, attachToParent: Boolean) -> VB
|
||||
@@ -18,6 +22,7 @@ abstract class BaseFragment<VB : ViewBinding>(
|
||||
private var _binding: VB? = null
|
||||
protected val binding get() = _binding!!
|
||||
private var mDialogWaiting: CustomDialog? = null
|
||||
protected val viewModel by viewModels<SettingViewModel>()
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
@@ -33,7 +38,17 @@ abstract class BaseFragment<VB : ViewBinding>(
|
||||
/**
|
||||
* 注册数据变化监听
|
||||
*/
|
||||
open fun registerDataChange() {}
|
||||
open fun registerDataChange() {
|
||||
lifecycleScope.launch {
|
||||
viewModel.showLoading.collect {
|
||||
if (it) {
|
||||
showWaitingDialog("")
|
||||
} else {
|
||||
hideWaitingDialog()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abstract fun initialize()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user