Fixed
Status Update
Comments
er...@gmail.com <er...@gmail.com> #2
Hi, thanks for reporting. Should be an easy fix!
I'm guessing it should work find until ~ 2^23 items = ~ 8M items. How did you come across this bug? Do you have a ViewPager2 with that many items?
I'm guessing it should work find until ~ 2^23 items = ~ 8M items. How did you come across this bug? Do you have a ViewPager2 with that many items?
er...@gmail.com <er...@gmail.com> #3
Hi, good to hear that.
We have an implementation of RecyclerView.Adapter that supports "infinite looping". So when the infinite looping is enabled, the adapter's getItemCount() reports Int.MAX_VALUE items. We also call setCurrentItem to somewhere in the middle of item count on the ViewPager2, so that's how we got that far.
We have an implementation of RecyclerView.Adapter that supports "infinite looping". So when the infinite looping is enabled, the adapter's getItemCount() reports Int.MAX_VALUE items. We also call setCurrentItem to somewhere in the middle of item count on the ViewPager2, so that's how we got that far.
jg...@google.com <jg...@google.com> #4
For future reference: first item for which it fails is probably when mCurrentItem = (1 << 25) + 2
jg...@google.com <jg...@google.com> #5
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 2e9f35536432bed0677171c8ae59b4f67850915a
Author: Jelle Fresen <jellefresen@google.com>
Date: Fri Jul 12 14:26:10 2019
Use double instead of float for decimal positions
A position ranges from 0 to Integer.MAX_VALUE, but floats only have a 23
bit mantissa. Values over 2^23 are rounded to a nearby value.
Solve this by using double instead of float when we need to represent a
position with a fractional component. A double has a mantissa of 52 bit
and can therefore represent all 2^32 possible int values.
Bug: 134858960
Test: ./gradlew viewpager2:cC
Change-Id: I08b97df6fac600caa83366ccab8671541e2c1e7f
A viewpager2/src/androidTest/java/androidx/viewpager2/test/ui/SparseAdapter.kt
M viewpager2/src/androidTest/java/androidx/viewpager2/widget/FakeDragTest.kt
M viewpager2/src/androidTest/java/androidx/viewpager2/widget/OffscreenPageLimitTest.kt
M viewpager2/src/androidTest/java/androidx/viewpager2/widget/PageChangeCallbackTest.kt
M viewpager2/src/androidTest/java/androidx/viewpager2/widget/PageTransformerTest.kt
M viewpager2/src/androidTest/java/androidx/viewpager2/widget/SetItemWhileScrollInProgressTest.kt
M viewpager2/src/main/java/androidx/viewpager2/widget/ScrollEventAdapter.java
M viewpager2/src/main/java/androidx/viewpager2/widget/ViewPager2.java
https://android-review.googlesource.com/1014538
https://goto.google.com/android-sha1/2e9f35536432bed0677171c8ae59b4f67850915a
Branch: androidx-master-dev
commit 2e9f35536432bed0677171c8ae59b4f67850915a
Author: Jelle Fresen <jellefresen@google.com>
Date: Fri Jul 12 14:26:10 2019
Use double instead of float for decimal positions
A position ranges from 0 to Integer.MAX_VALUE, but floats only have a 23
bit mantissa. Values over 2^23 are rounded to a nearby value.
Solve this by using double instead of float when we need to represent a
position with a fractional component. A double has a mantissa of 52 bit
and can therefore represent all 2^32 possible int values.
Bug: 134858960
Test: ./gradlew viewpager2:cC
Change-Id: I08b97df6fac600caa83366ccab8671541e2c1e7f
A viewpager2/src/androidTest/java/androidx/viewpager2/test/ui/SparseAdapter.kt
M viewpager2/src/androidTest/java/androidx/viewpager2/widget/FakeDragTest.kt
M viewpager2/src/androidTest/java/androidx/viewpager2/widget/OffscreenPageLimitTest.kt
M viewpager2/src/androidTest/java/androidx/viewpager2/widget/PageChangeCallbackTest.kt
M viewpager2/src/androidTest/java/androidx/viewpager2/widget/PageTransformerTest.kt
M viewpager2/src/androidTest/java/androidx/viewpager2/widget/SetItemWhileScrollInProgressTest.kt
M viewpager2/src/main/java/androidx/viewpager2/widget/ScrollEventAdapter.java
M viewpager2/src/main/java/androidx/viewpager2/widget/ViewPager2.java
jg...@google.com <jg...@google.com>
je...@google.com <je...@google.com>
ap...@google.com <ap...@google.com> #7
Project: platform/frameworks/support
Branch: androidx-master-dev
commit dca177316c5d2771759641d01f956b0f49892ca7
Author: Jelle Fresen <jellefresen@google.com>
Date: Fri Jan 17 17:32:28 2020
Fix for Fragment menu visibility issue in FSA
The fragment's menu visibility is directly related to the fragment's max
lifecycle. When the max lifecycle is STARTED, the menu should not be
visible. When the max lifecycle is RESUMED, the menu should be visible.
This CL fixes the bug where a fragment that is added to the fragment
manager by FragmentStateAdapter did set the max lifecycle to STARTED,
but did not set the menu visibility to false.
Relnote: "Fixed `FragmentStateAdapter` issue with initial fragment menu
visibility when adding a fragment to the `FragmentManager`."
Bug: 144442240
Test: ./gradlew viewpager2:viewpager2:cC \
-Pandroid.testInstrumentationRunnerArguments.class=\
androidx.viewpager2.widget.FragmentLifecycleTest
Change-Id: I9d2ffa0efcb03b63eeca25f2d4e74c81446a5774
M viewpager2/viewpager2/src/androidTest/java/androidx/viewpager2/widget/FragmentLifecycleTest.kt
M viewpager2/viewpager2/src/main/java/androidx/viewpager2/adapter/FragmentStateAdapter.java
https://android-review.googlesource.com/1211984
Branch: androidx-master-dev
commit dca177316c5d2771759641d01f956b0f49892ca7
Author: Jelle Fresen <jellefresen@google.com>
Date: Fri Jan 17 17:32:28 2020
Fix for Fragment menu visibility issue in FSA
The fragment's menu visibility is directly related to the fragment's max
lifecycle. When the max lifecycle is STARTED, the menu should not be
visible. When the max lifecycle is RESUMED, the menu should be visible.
This CL fixes the bug where a fragment that is added to the fragment
manager by FragmentStateAdapter did set the max lifecycle to STARTED,
but did not set the menu visibility to false.
Relnote: "Fixed `FragmentStateAdapter` issue with initial fragment menu
visibility when adding a fragment to the `FragmentManager`."
Bug: 144442240
Test: ./gradlew viewpager2:viewpager2:cC \
-Pandroid.testInstrumentationRunnerArguments.class=\
androidx.viewpager2.widget.FragmentLifecycleTest
Change-Id: I9d2ffa0efcb03b63eeca25f2d4e74c81446a5774
M viewpager2/viewpager2/src/androidTest/java/androidx/viewpager2/widget/FragmentLifecycleTest.kt
M viewpager2/viewpager2/src/main/java/androidx/viewpager2/adapter/FragmentStateAdapter.java
je...@google.com <je...@google.com>
v....@gmail.com <v....@gmail.com> #8
I think this issue relates to https://issuetracker.google.com/issues/147550812 as well and that other issue can be marked as fixed too.
Checked on 1.1.0-alpha01 and can confirm the fix.
Checked on 1.1.0-alpha01 and can confirm the fix.
ni...@gmail.com <ni...@gmail.com> #9
Comment has been deleted.
14...@gmail.com <14...@gmail.com> #10
Still having issue in alpha, when you slide very fast, icon will disappear for a while!
je...@google.com <je...@google.com> #11
Can you file a new bug for that? It sounds like that is a separate issue where for a brief period of time there none of the fragments is in RESUMED state. We'd need to figure out if that is a bug or working as intended.
Description
As a result, between the time the fragment is added and the time it becomes the new primary fragment of the ViewPager2, its menu is briefly shown at the same time as the menu of the current primary fragment, creating a visual glitch of duplicate menu items.
Fix: update the code of FragmentStateAdapter to call newFragment.setMenuItemVisible(false) right after creating the fragment using createFragment(position)