diff --git a/app/src/main/java/io/nekohasekai/sfa/ui/dashboard/GroupsFragment.kt b/app/src/main/java/io/nekohasekai/sfa/ui/dashboard/GroupsFragment.kt index 47daa2f..b851bb5 100644 --- a/app/src/main/java/io/nekohasekai/sfa/ui/dashboard/GroupsFragment.kt +++ b/app/src/main/java/io/nekohasekai/sfa/ui/dashboard/GroupsFragment.kt @@ -69,6 +69,7 @@ class GroupsFragment : Fragment(), CommandClient.Handler { override fun onDestroyView() { super.onDestroyView() binding = null + commandClient.disconnect() } private var displayed = false diff --git a/app/src/main/java/io/nekohasekai/sfa/ui/main/DashboardFragment.kt b/app/src/main/java/io/nekohasekai/sfa/ui/main/DashboardFragment.kt index 7258678..1068f2d 100644 --- a/app/src/main/java/io/nekohasekai/sfa/ui/main/DashboardFragment.kt +++ b/app/src/main/java/io/nekohasekai/sfa/ui/main/DashboardFragment.kt @@ -40,10 +40,11 @@ class DashboardFragment : Fragment(R.layout.fragment_dashboard) { return binding.root } + private val adapter by lazy { Adapter(this) } private fun onCreate() { val activity = activity ?: return val binding = binding ?: return - binding.dashboardPager.adapter = Adapter(this) + binding.dashboardPager.adapter = adapter binding.dashboardPager.offscreenPageLimit = Page.values().size activity.serviceStatus.observe(viewLifecycleOwner) { when (it) { @@ -107,6 +108,7 @@ class DashboardFragment : Fragment(R.layout.fragment_dashboard) { super.onDestroyView() mediator?.detach() mediator = null + binding?.dashboardPager?.adapter = null binding = null }