From 7ea73d156671e15505dd190464e90808ed00c7d5 Mon Sep 17 00:00:00 2001 From: Deon Olarewaju Date: Tue, 25 Jun 2024 02:47:55 +0100 Subject: [PATCH] 5395 fixed concept card not closing --- .../app/topic/conceptcard/ConceptCardFragment.kt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/oppia/android/app/topic/conceptcard/ConceptCardFragment.kt b/app/src/main/java/org/oppia/android/app/topic/conceptcard/ConceptCardFragment.kt index 7ea7fa759ed..2a035cff512 100644 --- a/app/src/main/java/org/oppia/android/app/topic/conceptcard/ConceptCardFragment.kt +++ b/app/src/main/java/org/oppia/android/app/topic/conceptcard/ConceptCardFragment.kt @@ -26,6 +26,7 @@ class ConceptCardFragment : InjectableDialogFragment() { companion object { const val CONCEPT_CARD_FRAGMENT_ARGUMENTS_KEY = "ConceptCardFragment.arguments" + private var conceptCardFragment: ConceptCardFragment? = null /** The fragment tag corresponding to the concept card dialog fragment. */ private const val CONCEPT_CARD_DIALOG_FRAGMENT_TAG = "CONCEPT_CARD_FRAGMENT" @@ -82,11 +83,15 @@ class ConceptCardFragment : InjectableDialogFragment() { fun dismissAll(fragmentManager: FragmentManager) { val toDismiss = fragmentManager.fragments.filterIsInstance() if (toDismiss.isNotEmpty()) { - val transaction = fragmentManager.beginTransaction() - for (fragment in toDismiss) { - transaction.remove(fragment) + fragmentManager.beginTransaction().apply { + for (fragment in toDismiss) { + remove(fragment) + } + commitNow() } - transaction.commitNow() + } else { + conceptCardFragment?.dismiss() + conceptCardFragment = null } } @@ -97,6 +102,7 @@ class ConceptCardFragment : InjectableDialogFragment() { ): ConceptCardFragment { val conceptCardFragment = newInstance(skillId, profileId) conceptCardFragment.showNow(fragmentManager, CONCEPT_CARD_DIALOG_FRAGMENT_TAG) + this.conceptCardFragment = conceptCardFragment return conceptCardFragment } }