Fix for empty fragment still opened after device rotation if user clicked on the empty part

This commit is contained in:
Sylvain Berfini 2025-09-15 11:26:30 +02:00
parent 82879506af
commit 11e6e86e20

View file

@ -24,14 +24,19 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.annotation.UiThread
import androidx.lifecycle.ViewModelProvider
import androidx.navigation.fragment.findNavController
import org.linphone.databinding.EmptyFragmentBinding
import org.linphone.ui.GenericFragment
import org.linphone.ui.main.viewmodel.SharedMainViewModel
import org.linphone.utils.Event
@UiThread
class EmptyFragment : GenericFragment() {
private lateinit var binding: EmptyFragmentBinding
protected lateinit var sharedViewModel: SharedMainViewModel
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
@ -45,11 +50,19 @@ class EmptyFragment : GenericFragment() {
super.onViewCreated(view, savedInstanceState)
binding.lifecycleOwner = viewLifecycleOwner
sharedViewModel = requireActivity().run {
ViewModelProvider(this)[SharedMainViewModel::class.java]
}
}
override fun onResume() {
super.onResume()
findNavController().popBackStack()
// This should prevent empty fragment from staying visible
// after the device rotated if user touched the empty fragment on the right
sharedViewModel.closeSlidingPaneEvent.postValue(Event(true))
}
}