summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2013-10-28 22:17:38 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-10-28 22:17:38 +0000
commit849d12010214ce75367fa040b5040c42b0269e6d (patch)
treea07f703f57ff62bd0efea3e4bf32f13a93fe5061
parentfb7cd745e73dbb22ec121d0c82e6373a89c29d56 (diff)
parent0cd0eba42ec77a5b5598b753edd6cb71127716fa (diff)
downloadandroid_packages_apps_Trebuchet-849d12010214ce75367fa040b5040c42b0269e6d.tar.gz
android_packages_apps_Trebuchet-849d12010214ce75367fa040b5040c42b0269e6d.tar.bz2
android_packages_apps_Trebuchet-849d12010214ce75367fa040b5040c42b0269e6d.zip
Merge "Finished getting rid of mPageSpacing" into jb-ub-now-jetsonic
-rw-r--r--src/com/android/launcher3/PagedView.java44
1 files changed, 9 insertions, 35 deletions
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index e724063df..c154b33c5 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -157,7 +157,6 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
protected int mTouchSlop;
private int mPagingTouchSlop;
private int mMaximumVelocity;
- protected int mPageSpacing;
protected int mPageLayoutPaddingTop;
protected int mPageLayoutPaddingBottom;
protected int mPageLayoutPaddingLeft;
@@ -260,9 +259,6 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
// Drop to delete
private View mDeleteDropTarget;
- private boolean mAutoComputePageSpacing = false;
- private boolean mRecomputePageSpacing = false;
-
// Bouncer
private boolean mTopAlignPageWhenShrinkingForBouncer = false;
@@ -285,10 +281,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
TypedArray a = context.obtainStyledAttributes(attrs,
R.styleable.PagedView, defStyle, 0);
- setPageSpacing(a.getDimensionPixelSize(R.styleable.PagedView_pageSpacing, 0));
- if (mPageSpacing < 0) {
- mAutoComputePageSpacing = mRecomputePageSpacing = true;
- }
+
mPageLayoutPaddingTop = a.getDimensionPixelSize(
R.styleable.PagedView_pageLayoutPaddingTop, 0);
mPageLayoutPaddingBottom = a.getDimensionPixelSize(
@@ -875,26 +868,6 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
}
}
setMeasuredDimension(scaledWidthSize, scaledHeightSize);
-
- if (childCount > 0) {
- // Calculate the variable page spacing if necessary
- if (mAutoComputePageSpacing && mRecomputePageSpacing) {
- // The gap between pages in the PagedView should be equal to the gap from the page
- // to the edge of the screen (so it is not visible in the current screen). To
- // account for unequal padding on each side of the paged view, we take the maximum
- // of the left/right gap and use that as the gap between each page.
- int offset = (getViewportWidth() - getChildWidth(0)) / 2;
- int spacing = Math.max(offset, widthSize - offset -
- getChildAt(0).getMeasuredWidth());
- setPageSpacing(spacing);
- mRecomputePageSpacing = false;
- }
- }
- }
-
- public void setPageSpacing(int pageSpacing) {
- mPageSpacing = pageSpacing;
- requestLayout();
}
@Override
@@ -1029,7 +1002,6 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
// This ensures that when children are added, they get the correct transforms / alphas
// in accordance with any scroll effects.
mForceScreenScrolled = true;
- mRecomputePageSpacing = true;
updateFreescrollBounds();
invalidate();
}
@@ -1301,9 +1273,9 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
int offset = (getViewportWidth() - getChildWidth(mCurrentPage)) / 2;
if (isLayoutRtl()) {
return (x > (getViewportOffsetX() + getViewportWidth() -
- offset + mPageSpacing));
+ offset));
}
- return (x < getViewportOffsetX() + offset - mPageSpacing);
+ return (x < getViewportOffsetX() + offset);
}
/**
@@ -1312,10 +1284,10 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
protected boolean hitsNextPage(float x, float y) {
int offset = (getViewportWidth() - getChildWidth(mCurrentPage)) / 2;
if (isLayoutRtl()) {
- return (x < getViewportOffsetX() + offset - mPageSpacing);
+ return (x < getViewportOffsetX() + offset);
}
return (x > (getViewportOffsetX() + getViewportWidth() -
- offset + mPageSpacing));
+ offset));
}
/** Returns whether x and y originated within the buffered viewport */
@@ -1506,7 +1478,8 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
protected float getScrollProgress(int screenCenter, View v, int page) {
final int halfScreenSize = getViewportWidth() / 2;
- int totalDistance = v.getMeasuredWidth() + mPageSpacing;
+ int offset = (getViewportWidth() - getChildWidth(page)) / 2;
+ int totalDistance = v.getMeasuredWidth() + offset;
int delta = screenCenter - (getScrollForPage(page) + halfScreenSize);
float scrollProgress = delta / (totalDistance * 1.0f);
@@ -2595,9 +2568,10 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
int newX = 0;
if (slideFromLeft) {
if (i == 0) {
+ int pageSpace = (getViewportWidth() - getChildWidth(i)) / 2;
// Simulate the page being offscreen with the page spacing
oldX = getViewportOffsetX() + getChildOffset(i) - getChildWidth(i)
- - mPageSpacing;
+ - pageSpace;
} else {
oldX = getViewportOffsetX() + getChildOffset(i - 1);
}