Implemented NFC Card Reader Code from https://git.sterul.com/student-projects/dhbw...
[DHBWCampusApp.git] / app / src / main / java / de / dhbwloe / campusapp / NavigationManager.java
index 33d2f1c541938de315e4281b30e7bb31fb07e013..07732f2a589595682e178f1c320f2db32209908f 100644 (file)
@@ -50,6 +50,13 @@ public class NavigationManager {
     public String getCurrentPageName() {
         if(oCurrentPage == null)
             return null;
+        if(oCurrentPage.fragmentType == 3 && oParentFragment != null){
+            if(oCurrentFragment.isAdded())
+                return oCurrentPage.name;
+            else {
+                closeDialog();
+            }
+        }
         return oCurrentPage.name;
     }
 
@@ -160,17 +167,20 @@ public class NavigationManager {
     public boolean closeDialog() {
         if(oCurrentPage != null && oCurrentPage.fragmentType == 3) {
             PopupFragment fragment = (PopupFragment) oCurrentFragment;
-            fragment.destroyView();
+            if(oCurrentFragment.isAdded()) {
+                fragment.destroyView();
 
-            FragmentActivity fragmentActivity = (FragmentActivity) AppContext.getMainActivity();
-            FragmentTransaction transaction = fragmentActivity.getSupportFragmentManager().beginTransaction();
+                FragmentActivity fragmentActivity = (FragmentActivity) AppContext.getMainActivity();
+                FragmentTransaction transaction = fragmentActivity.getSupportFragmentManager().beginTransaction();
 
-            transaction.remove(oCurrentFragment);
+                transaction.remove(oCurrentFragment);
+                transaction.commit();
+            }
 
             oCurrentPage = oParentPage;
             oCurrentFragment = oParentFragment;
 
-            transaction.commit();
+
             return true;
         }
         return false;