summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2015-04-16 21:51:02 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-04-16 21:51:07 +0000
commit3774923944c4da8decc58df1aaa9b839ed542179 (patch)
tree7ccf7ae305c5e32262f1c65c24013c67ac998ef7 /src
parent317073ca2df775d3fae445b82e83f0314f2dcfe3 (diff)
parent3e2ff8afef31dd48f2ab8666d389f1654bca6368 (diff)
downloadandroid_packages_apps_Trebuchet-3774923944c4da8decc58df1aaa9b839ed542179.tar.gz
android_packages_apps_Trebuchet-3774923944c4da8decc58df1aaa9b839ed542179.tar.bz2
android_packages_apps_Trebuchet-3774923944c4da8decc58df1aaa9b839ed542179.zip
Merge "Updating maxscroll only after layouttranstion has finished" into ub-launcher3-burnaby
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/PagedView.java46
1 files changed, 37 insertions, 9 deletions
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index 158a30c40..6e9f27a0a 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -19,6 +19,7 @@ package com.android.launcher3;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
+import android.animation.LayoutTransition;
import android.animation.ObjectAnimator;
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
@@ -961,8 +962,8 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
LayoutParams nextLp;
int childLeft = offsetX + (lp.isFullScreenPage ? 0 : getPaddingLeft());
- if (mPageScrolls == null || getChildCount() != mChildCountOnLastLayout) {
- mPageScrolls = new int[getChildCount()];
+ if (mPageScrolls == null || childCount != mChildCountOnLastLayout) {
+ mPageScrolls = new int[childCount];
}
for (int i = startIndex; i != endIndex; i += delta) {
@@ -1009,19 +1010,36 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
}
}
- if (mFirstLayout && mCurrentPage >= 0 && mCurrentPage < getChildCount()) {
+ if (mFirstLayout && mCurrentPage >= 0 && mCurrentPage < childCount) {
updateCurrentPageScroll();
mFirstLayout = false;
}
- if (childCount > 0) {
- final int index = isLayoutRtl() ? 0 : childCount - 1;
- mMaxScrollX = getScrollForPage(index);
+ final LayoutTransition transition = getLayoutTransition();
+ // If the transition is running defer updating max scroll, as some empty pages could
+ // still be present, and a max scroll change could cause sudden jumps in scroll.
+ if (transition != null && transition.isRunning()) {
+ transition.addTransitionListener(new LayoutTransition.TransitionListener() {
+
+ @Override
+ public void startTransition(LayoutTransition transition, ViewGroup container,
+ View view, int transitionType) { }
+
+ @Override
+ public void endTransition(LayoutTransition transition, ViewGroup container,
+ View view, int transitionType) {
+ // Wait until all transitions are complete.
+ if (!transition.isRunning()) {
+ transition.removeTransitionListener(this);
+ updateMaxScrollX();
+ }
+ }
+ });
} else {
- mMaxScrollX = 0;
+ updateMaxScrollX();
}
- if (mScroller.isFinished() && mChildCountOnLastLayout != getChildCount() &&
+ if (mScroller.isFinished() && mChildCountOnLastLayout != childCount &&
!mDeferringForDelete) {
if (mRestorePage != INVALID_RESTORE_PAGE) {
setCurrentPage(mRestorePage);
@@ -1030,13 +1048,23 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
setCurrentPage(getNextPage());
}
}
- mChildCountOnLastLayout = getChildCount();
+ mChildCountOnLastLayout = childCount;
if (isReordering(true)) {
updateDragViewTranslationDuringDrag();
}
}
+ private void updateMaxScrollX() {
+ int childCount = getChildCount();
+ if (childCount > 0) {
+ final int index = isLayoutRtl() ? 0 : childCount - 1;
+ mMaxScrollX = getScrollForPage(index);
+ } else {
+ mMaxScrollX = 0;
+ }
+ }
+
public void setPageSpacing(int pageSpacing) {
mPageSpacing = pageSpacing;
requestLayout();