Skip to content
Snippets Groups Projects
Commit d167a41c authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Restore listener on screen rotation

parent 4d25fb9f
No related branches found
No related tags found
No related merge requests found
......@@ -49,6 +49,20 @@ class ContextSheet : BottomSheetDialogFragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
itemPosition = arguments?.getInt(CTX_POSITION_KEY) ?: -1
if (!this::receiver.isInitialized) restoreReceiver(savedInstanceState)
}
private fun restoreReceiver(savedInstanceState: Bundle?) {
if (savedInstanceState != null) {
val fragments = requireActivity().supportFragmentManager.fragments
for ((index, fragment) in fragments.withIndex()) {
if (fragment is CtxActionReceiver) {
receiver = fragment
return
} else if (index > 1) break
}
}
dismiss()
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment