mirror of
https://github.com/SagerNet/sing-box-for-android.git
synced 2025-04-04 04:17:37 +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() {
|
override fun onDestroyView() {
|
||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
binding = null
|
binding = null
|
||||||
|
commandClient.disconnect()
|
||||||
}
|
}
|
||||||
|
|
||||||
private var displayed = false
|
private var displayed = false
|
||||||
|
|
|
@ -40,10 +40,11 @@ class DashboardFragment : Fragment(R.layout.fragment_dashboard) {
|
||||||
return binding.root
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val adapter by lazy { Adapter(this) }
|
||||||
private fun onCreate() {
|
private fun onCreate() {
|
||||||
val activity = activity ?: return
|
val activity = activity ?: return
|
||||||
val binding = binding ?: return
|
val binding = binding ?: return
|
||||||
binding.dashboardPager.adapter = Adapter(this)
|
binding.dashboardPager.adapter = adapter
|
||||||
binding.dashboardPager.offscreenPageLimit = Page.values().size
|
binding.dashboardPager.offscreenPageLimit = Page.values().size
|
||||||
activity.serviceStatus.observe(viewLifecycleOwner) {
|
activity.serviceStatus.observe(viewLifecycleOwner) {
|
||||||
when (it) {
|
when (it) {
|
||||||
|
@ -107,6 +108,7 @@ class DashboardFragment : Fragment(R.layout.fragment_dashboard) {
|
||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
mediator?.detach()
|
mediator?.detach()
|
||||||
mediator = null
|
mediator = null
|
||||||
|
binding?.dashboardPager?.adapter = null
|
||||||
binding = null
|
binding = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue