fixed app for non nfc devices & fixed navigation after app pause & resume (it seems...
[DHBWCampusApp.git] / app / src / main / java / de / dhbwloe / campusapp / NavigationManager.java
index 1330940689b5f8bb3efcfdf4821e1f8a7ff18b15..4a168a2212c829cedeae047bc5f2c505e9ebf528 100644 (file)
@@ -12,6 +12,7 @@ import android.widget.PopupWindow;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
+import java.util.List;
 
 import de.dhbwloe.campusapp.fragments.PopupFragment;
 
@@ -108,9 +109,16 @@ public class NavigationManager {
             oParentPage = oCurrentPage;
             oParentFragment = oCurrentFragment;
             history = false;
-        } else if (oCurrentPage != null) {
-            transaction.replace(iFragmentContainerId, fragment);
         } else {
+            // remove fragments
+            List<Fragment> al = fragmentActivity.getSupportFragmentManager().getFragments();
+            if(al != null) {
+                for (Fragment frag : al) {
+                    if (frag != null && frag.isAdded()) {
+                        transaction.remove(frag);
+                    }
+                }
+            }
             transaction.add(iFragmentContainerId, fragment);
         }
         if (history)