Bounding scroll bar to the track to prevent overscrolling.
Change-Id: I2db815e072dcf41dda8102829d136fc2dca588e7
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index 807470c..9f9450c 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -1776,11 +1776,13 @@
int numPages = getChildCount();
int pageWidth = getMeasuredWidth();
int maxPageWidth = (numPages * getChildWidth(0)) + ((numPages - 1) * mPageSpacing);
+ int maxScrollPosition = maxPageWidth - pageWidth; // n-1 * pageWidth
int trackWidth = pageWidth - mScrollIndicatorPaddingLeft - mScrollIndicatorPaddingRight;
int indicatorWidth = mScrollIndicator.getMeasuredWidth() -
mScrollIndicator.getPaddingLeft() - mScrollIndicator.getPaddingRight();
- float offset = (float) getScrollX() / maxPageWidth;
+ float offset = (float) Math.max(0f, Math.min(maxScrollPosition, getScrollX()))
+ / maxPageWidth;
int indicatorSpace = trackWidth / numPages;
int indicatorPos = (int) (offset * trackWidth) + mScrollIndicatorPaddingLeft;
if (hasElasticScrollIndicator()) {