Fixed
Status Update
Comments
jg...@google.com <jg...@google.com>
ap...@google.com <ap...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 19d6489437a61a09fc1775bc5a8a3018c1a9c664
Author: Jakub Gielzak <jgielzak@google.com>
Date: Fri Sep 20 14:38:41 2019
Pausing old primary Fragment first
Pausing (STARTED) old primary Fragment, before resuming (RESUMED) new
primary Fragment.
TODO: automated test
Bug: 139489059
Test: manual
Test: ./gradlew viewpager2:connectedCheck
Change-Id: If9036f53f6512d7c8e6b198e09fd8c979a970b37
M viewpager2/src/main/java/androidx/viewpager2/adapter/FragmentStateAdapter.java
https://android-review.googlesource.com/1126604
https://goto.google.com/android-sha1/19d6489437a61a09fc1775bc5a8a3018c1a9c664
Branch: androidx-master-dev
commit 19d6489437a61a09fc1775bc5a8a3018c1a9c664
Author: Jakub Gielzak <jgielzak@google.com>
Date: Fri Sep 20 14:38:41 2019
Pausing old primary Fragment first
Pausing (STARTED) old primary Fragment, before resuming (RESUMED) new
primary Fragment.
TODO: automated test
Bug: 139489059
Test: manual
Test: ./gradlew viewpager2:connectedCheck
Change-Id: If9036f53f6512d7c8e6b198e09fd8c979a970b37
M viewpager2/src/main/java/androidx/viewpager2/adapter/FragmentStateAdapter.java
jg...@google.com <jg...@google.com> #3
Fixed in http://aosp/1126604 and should come out in the next release.
Description
FragmentMaxLifecycleEnforcer method's updateFragmentMaxLifecycle doesn't guarantee current item will be paused before new one will be resumed.
for (int ix = 0; ix < mFragments.size(); ix++) {
long itemId = mFragments.keyAt(ix);
Fragment fragment = mFragments.valueAt(ix);
if (!fragment.isAdded()) {
continue;
}
transaction.setMaxLifecycle(fragment, itemId == mPrimaryItemId ? RESUMED : STARTED);
fragment.setMenuVisibility(itemId == mPrimaryItemId);
}
Implamentation depends on key order and doesn't enforce current item's lifecycle before new one.
So if I have fragment A and B:
- Moving from A to B will pause A and then resume B
- Moving from B to A will resume A and then pause B