mirror of
https://github.com/SagerNet/sing-box-for-android.git
synced 2025-04-03 03:47:38 +03:00
Fix FragmentStateAdapter recreates Fragments
This commit is contained in:
parent
6df2f60c3a
commit
33a943fbec
2 changed files with 4 additions and 1 deletions
|
@ -69,6 +69,7 @@ class GroupsFragment : Fragment(), CommandClient.Handler {
|
|||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
binding = null
|
||||
commandClient.disconnect()
|
||||
}
|
||||
|
||||
private var displayed = false
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue