Only register full callback when ClientsFragment is active

This commit is contained in:
Mygod
2020-06-27 23:00:04 -04:00
parent a13a37a822
commit 5c6b22a6d2
2 changed files with 13 additions and 3 deletions

View File

@@ -224,8 +224,9 @@ class ClientsFragment : Fragment() {
binding.clients.adapter = adapter
binding.swipeRefresher.setColorSchemeResources(R.color.colorSecondary)
binding.swipeRefresher.setOnRefreshListener { IpNeighbourMonitor.instance?.flushAsync() }
activityViewModels<ClientViewModel>().value.clients.observe(viewLifecycleOwner) {
adapter.submitList(it.toMutableList())
activityViewModels<ClientViewModel>().value.apply {
lifecycle.addObserver(this)
clients.observe(viewLifecycleOwner) { adapter.submitList(it.toMutableList()) }
}
return binding.root
}