From e6247d4428c05bdec2fe4868e7577c4ca62d3ecf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Borcz?= Date: Sun, 28 Mar 2021 08:18:07 +0200 Subject: [PATCH] Fix clearing no existing dialog fragment (#1242) --- .../wulkanowy/ui/modules/main/MainActivity.kt | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/main/MainActivity.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/main/MainActivity.kt index 5fda72106..37c6c6e75 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/main/MainActivity.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/main/MainActivity.kt @@ -324,9 +324,7 @@ class MainActivity : BaseActivity(), MainVie } override fun showAccountPicker(studentWithSemesters: List) { - if (supportFragmentManager.isStateSaved) return - - navController.showDialogFragment(AccountQuickDialog.newInstance(studentWithSemesters)) + showDialogFragment(AccountQuickDialog.newInstance(studentWithSemesters)) } override fun showActionBarElevation(show: Boolean) { @@ -342,9 +340,18 @@ class MainActivity : BaseActivity(), MainVie (navController.currentStack?.getOrNull(0) as? MainView.MainChildView)?.onFragmentChanged() } + @Suppress("DEPRECATION") fun showDialogFragment(dialog: DialogFragment) { if (supportFragmentManager.isStateSaved) return + //Deprecated method is used here to avoid fragnav bug + if (navController.currentDialogFrag?.fragmentManager == null) { + FragNavController::class.java.getDeclaredField("mCurrentDialogFrag").apply { + isAccessible = true + set(navController, null) + } + } + navController.showDialogFragment(dialog) }