Browse Source

Merge pull request #13038 from nextcloud/bugfix/setLeftFragment-fragmentManager-has-been-destroyed

Check FragmentManager Before commit new FragmentTransaction
Alper Öztürk 1 year ago
parent
commit
50b5cc55f7

+ 7 - 4
app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java

@@ -597,10 +597,13 @@ public class FileDisplayActivity extends FileActivity
 
         showSortListGroup(showSortListGroup);
 
-        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
-        transaction.addToBackStack(null);
-        transaction.replace(R.id.left_fragment_container, fragment, TAG_LIST_OF_FILES);
-        transaction.commit();
+        FragmentManager fragmentManager = getSupportFragmentManager();
+        if (!isFinishing() && !fragmentManager.isDestroyed()) {
+            FragmentTransaction transaction = fragmentManager.beginTransaction();
+            transaction.addToBackStack(null);
+            transaction.replace(R.id.left_fragment_container, fragment, TAG_LIST_OF_FILES);
+            transaction.commit();
+        }
     }
 
     private OCFileListFragment getOCFileListFragmentFromFile() {