[Android] Fix secondary fragment backstack handling

Geoffrey Métais git at videolan.org
Mon Dec 29 14:10:11 CET 2014


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Dec 29 14:09:41 2014 +0100| [6d237d095a91af2272a5075325de550ec96d68e1] | committer: Geoffrey Métais

Fix secondary fragment backstack handling

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=6d237d095a91af2272a5075325de550ec96d68e1
---

 vlc-android/src/org/videolan/vlc/gui/MainActivity.java |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index cb58e41..454bd06 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -487,7 +487,7 @@ public class MainActivity extends ActionBarActivity {
         return mSidebarAdapter.fetchFragment(id);
     }
 
-    private static void ShowFragment(FragmentActivity activity, String tag, Fragment fragment) {
+    private static void ShowFragment(FragmentActivity activity, String tag, Fragment fragment, String previous) {
         if (fragment == null) {
             Log.e(TAG, "Cannot show a null fragment, ShowFragment("+tag+") aborted.");
             return;
@@ -508,7 +508,7 @@ public class MainActivity extends ActionBarActivity {
         FragmentTransaction ft = fm.beginTransaction();
         ft.setCustomAnimations(R.anim.anim_enter_right, R.anim.anim_leave_left, R.anim.anim_enter_left, R.anim.anim_leave_right);
         ft.replace(R.id.fragment_placeholder, fragment, tag);
-        ft.addToBackStack(tag);
+        ft.addToBackStack(previous);
         ft.commit();
     }
 
@@ -562,7 +562,7 @@ public class MainActivity extends ActionBarActivity {
 
         mCurrentFragment = fragmentTag;
         Fragment frag = fetchSecondaryFragment(mCurrentFragment);
-        ShowFragment(this, mCurrentFragment, frag);
+        ShowFragment(this, mCurrentFragment, frag, mPreviousFragment);
         return frag;
     }
 
@@ -570,8 +570,7 @@ public class MainActivity extends ActionBarActivity {
      * Hide the current secondary fragment.
      */
     public void popSecondaryFragment() {
-        FragmentManager fragmentManager = getSupportFragmentManager();
-        fragmentManager.popBackStackImmediate(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
+        getSupportFragmentManager().popBackStackImmediate();
         mCurrentFragment = mPreviousFragment;
     }
 



More information about the Android mailing list