Fixed
Status Update
Comments
il...@google.com <il...@google.com>
ap...@google.com <ap...@google.com> #2
Please include a sample project that reproduces your issue.
om...@gmail.com <om...@gmail.com> #3
Thanks for the sample app, I was able to reproduce your issue.
You can work around it by switching the order that you call replace and setPrimaryNavigationFragment and call setPrimaryNavigationFragment *after* replace:
requireFragmentManager().beginTransaction()
.addToBackStack(null)
.replace(Window.ID_ANDROID_CONTENT, fragment)
.setPrimaryNavigationFragment(fragment)
.commit()
You can work around it by switching the order that you call replace and setPrimaryNavigationFragment and call setPrimaryNavigationFragment *after* replace:
requireFragmentManager().beginTransaction()
.addToBackStack(null)
.replace(Window.ID_ANDROID_CONTENT, fragment)
.setPrimaryNavigationFragment(fragment)
.commit()
ap...@google.com <ap...@google.com> #4
Project: platform/frameworks/support
Branch: androidx-master-dev
commit a4806ba69d611dcc36b794870e9dc80981371ec9
Author: Ian Lake <ilake@google.com>
Date: Tue Jun 11 13:14:42 2019
Fix pop when calling setPrimary before replace
When popping a FragmentTransaction, the operations
you apply are undone in reverse ordering. This means
that when you call setPrimaryNavigationFragment()
before replace(), the replace() is undone first, causing
the current Fragment to be removed from the
FragmentManager before the code for undoing
setPrimaryNavigationFragment runs.
We now ensure that performPrimaryNavigationFragmentChanged
is only called if the Fragment is still attached.
Test: new replacePrimaryNavAfterSetPrimary test passes
Fixes: 134673465
Change-Id: I1a126c265c2350ed4e7d437fb68df29376ff5fcf
M fragment/fragment/src/androidTest/java/androidx/fragment/app/PrimaryNavFragmentTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentManagerImpl.java
https://android-review.googlesource.com/980591
https://goto.google.com/android-sha1/a4806ba69d611dcc36b794870e9dc80981371ec9
Branch: androidx-master-dev
commit a4806ba69d611dcc36b794870e9dc80981371ec9
Author: Ian Lake <ilake@google.com>
Date: Tue Jun 11 13:14:42 2019
Fix pop when calling setPrimary before replace
When popping a FragmentTransaction, the operations
you apply are undone in reverse ordering. This means
that when you call setPrimaryNavigationFragment()
before replace(), the replace() is undone first, causing
the current Fragment to be removed from the
FragmentManager before the code for undoing
setPrimaryNavigationFragment runs.
We now ensure that performPrimaryNavigationFragmentChanged
is only called if the Fragment is still attached.
Test: new replacePrimaryNavAfterSetPrimary test passes
Fixes: 134673465
Change-Id: I1a126c265c2350ed4e7d437fb68df29376ff5fcf
M fragment/fragment/src/androidTest/java/androidx/fragment/app/PrimaryNavFragmentTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentManagerImpl.java
an...@google.com <an...@google.com> #5
This is fixed internally and will be in the next release of Fragments.
Description
Version used: 1.2.0-alpha01
When running a test in Robolectric, the new behavior introduced in
We should continue to use commitNowAllowingStateLoss(), but catch the IllegalStateException and fall back to commitAllowingStateLoss() specifically in the case where we're already performing transactions.