From 1fa6b9499b4cf435c41e52d76bc74a2ce6121d40 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Mon, 6 Jun 2016 14:20:22 -0700 Subject: [PATCH] When the active page changes, simulate a scroll change. This prevents the animation progess from going out of sync of the active page, when the active page changes before the total number of pages change Bug: 29113836 Change-Id: I2b12ea29d64dc98d773e6060de4b655d3f975b5a --- .../launcher3/pageindicators/PageIndicatorDots.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/com/android/launcher3/pageindicators/PageIndicatorDots.java b/src/com/android/launcher3/pageindicators/PageIndicatorDots.java index 7d84a0c768..99af93bf65 100644 --- a/src/com/android/launcher3/pageindicators/PageIndicatorDots.java +++ b/src/com/android/launcher3/pageindicators/PageIndicatorDots.java @@ -24,7 +24,6 @@ import android.animation.ValueAnimator; import android.animation.ValueAnimator.AnimatorUpdateListener; import android.content.Context; import android.graphics.Canvas; -import android.view.animation.Interpolator; import android.graphics.Outline; import android.graphics.Paint; import android.graphics.Paint.Style; @@ -33,6 +32,7 @@ import android.util.AttributeSet; import android.util.Property; import android.view.View; import android.view.ViewOutlineProvider; +import android.view.animation.Interpolator; import android.view.animation.OvershootInterpolator; import com.android.launcher3.R; @@ -224,8 +224,14 @@ public class PageIndicatorDots extends PageIndicator { @Override public void setActiveMarker(int activePage) { - mActivePage = activePage; - invalidate(); + if (mActivePage != activePage) { + mActivePage = activePage; + + // Simulate a scroll change + int totalScroll = mNumPages - 1; + int currentScroll = mIsRtl ? (totalScroll - mActivePage) : mActivePage; + setScroll(currentScroll, totalScroll); + } } @Override