[Android] Restore listener on screen rotation
Geoffrey Métais
git at videolan.org
Thu Jun 7 11:44:39 CEST 2018
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Jun 7 11:41:32 2018 +0200| [d167a41c356886d58c5d4590dd79084d7ba01117] | committer: Geoffrey Métais
Restore listener on screen rotation
> https://code.videolan.org/videolan/vlc-android/commit/d167a41c356886d58c5d4590dd79084d7ba01117
---
.../src/org/videolan/vlc/gui/dialogs/ContextSheet.kt | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/vlc-android/src/org/videolan/vlc/gui/dialogs/ContextSheet.kt b/vlc-android/src/org/videolan/vlc/gui/dialogs/ContextSheet.kt
index 264d997af..e1816ed8f 100644
--- a/vlc-android/src/org/videolan/vlc/gui/dialogs/ContextSheet.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/dialogs/ContextSheet.kt
@@ -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? {
More information about the Android
mailing list