Fixed
Status Update
Comments
jg...@google.com <jg...@google.com> #2
Hi, thanks for reporting.
As a temporary workaround, you can probably:
- unregister your margin transformer
- register a MarginPageTransformer with an offset of 0
- viewpager2.requestTransform()
- viewpager2.adapter.notifyItemInserted()
- revert back to the original transformer
It should be indistinguishible from the user perspective when done while viewPager.getScrollState() == SCROLL_STATE_IDLE (at that stage, there is no visible offset).
If it's not there, OnPageChangeCallback will notify you once the viewpager changes to SCROLL_STATE_IDLE.
Alternatively, if you don't want the animation, a notifyDatasetChanged() should work fine. Especially if you're using Fragments, as they will be kept around.
Apologies for the extra steps. We'll look into it!
As a temporary workaround, you can probably:
- unregister your margin transformer
- register a MarginPageTransformer with an offset of 0
- viewpager2.requestTransform()
- viewpager2.adapter.notifyItemInserted()
- revert back to the original transformer
It should be indistinguishible from the user perspective when done while viewPager.getScrollState() == SCROLL_STATE_IDLE (at that stage, there is no visible offset).
If it's not there, OnPageChangeCallback will notify you once the viewpager changes to SCROLL_STATE_IDLE.
Alternatively, if you don't want the animation, a notifyDatasetChanged() should work fine. Especially if you're using Fragments, as they will be kept around.
Apologies for the extra steps. We'll look into it!
jg...@google.com <jg...@google.com>
jg...@google.com <jg...@google.com>
ap...@google.com <ap...@google.com> #3
Project: platform/frameworks/support
Branch: androidx-master-dev
commit f3df487541c41b9b0e81199a73eaeda058cab7a9
Author: Jakub Gielzak <jgielzak@google.com>
Date: Thu Aug 01 22:20:00 2019
Fix for PageTransformer + dataSet animations clash
Suspends data-set change animations in the presence of a
PageTransformer.
Bug: 134658996
Test: ./gradlew viewpager2:connectedCheck
Change-Id: I873f7233a87b553ef6f410a76b35e6567bd4dc80
A viewpager2/src/androidTest/java/androidx/viewpager2/widget/PageTransformerItemAnimatorTest.kt
M viewpager2/src/main/java/androidx/viewpager2/widget/ViewPager2.java
https://android-review.googlesource.com/1095609
https://goto.google.com/android-sha1/f3df487541c41b9b0e81199a73eaeda058cab7a9
Branch: androidx-master-dev
commit f3df487541c41b9b0e81199a73eaeda058cab7a9
Author: Jakub Gielzak <jgielzak@google.com>
Date: Thu Aug 01 22:20:00 2019
Fix for PageTransformer + dataSet animations clash
Suspends data-set change animations in the presence of a
PageTransformer.
Bug: 134658996
Test: ./gradlew viewpager2:connectedCheck
Change-Id: I873f7233a87b553ef6f410a76b35e6567bd4dc80
A viewpager2/src/androidTest/java/androidx/viewpager2/widget/PageTransformerItemAnimatorTest.kt
M viewpager2/src/main/java/androidx/viewpager2/widget/ViewPager2.java
sv...@linkedin.com <sv...@linkedin.com> #5
Comment has been deleted.
Description
Since both MarginPageTransformer and ItemAnimator used translation internally things break when you use MarginPageTransformer and want to animate additions and removals.
Steps to reproduce:
1. Create a view pager with a MarginPageTransformer
2. Add or remove items using notifyItemInserted/notifyItemRemoved