summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaj Yengisetty <rajesh@cyngn.com>2014-11-10 18:35:01 (GMT)
committerAdnan <adnan@cyngn.com>2014-11-19 23:53:58 (GMT)
commitea3b5e62a45fb70041ac52f06608acbb96f6af30 (patch)
tree58fb1f033bb21eafea910451ba05c8f83f9e877c
parent82c3fdad45896b0c602d2735fd2ab437d2fe7757 (diff)
downloadandroid_packages_apps_Trebuchet-ea3b5e62a45fb70041ac52f06608acbb96f6af30.zip
android_packages_apps_Trebuchet-ea3b5e62a45fb70041ac52f06608acbb96f6af30.tar.gz
android_packages_apps_Trebuchet-ea3b5e62a45fb70041ac52f06608acbb96f6af30.tar.bz2
Fix layout issues in Trebuchet
Change-Id: I834209656b440e90af437ae127070456586d8bd4
-rw-r--r--src/com/android/launcher3/PagedView.java33
1 files changed, 10 insertions, 23 deletions
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index b7b0e52..b314bd1 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -952,6 +952,8 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
if (DEBUG) Log.d(TAG, "PagedView.onLayout()");
final int childCount = getChildCount();
+ int screenWidth = getViewportWidth();
+
int offsetX = getViewportOffsetX();
int offsetY = getViewportOffsetY();
@@ -966,10 +968,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
int verticalPadding = getPaddingTop() + getPaddingBottom();
- LayoutParams lp = (LayoutParams) getChildAt(startIndex).getLayoutParams();
- LayoutParams nextLp;
-
- int childLeft = offsetX + (lp.isFullScreenPage ? 0 : getPaddingLeft());
+ int childLeft = offsetX + (screenWidth - getChildWidth(startIndex)) / 2;
if (mPageScrolls == null || getChildCount() != mChildCountOnLastLayout) {
mPageScrolls = new int[getChildCount()];
}
@@ -977,7 +976,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
for (int i = startIndex; i != endIndex; i += delta) {
final View child = getPageAt(i);
if (child.getVisibility() != View.GONE) {
- lp = (LayoutParams) child.getLayoutParams();
+ LayoutParams lp = (LayoutParams) child.getLayoutParams();
int childTop;
if (lp.isFullScreenPage) {
childTop = offsetY;
@@ -995,26 +994,14 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
child.layout(childLeft, childTop,
childLeft + child.getMeasuredWidth(), childTop + childHeight);
- int scrollOffsetLeft = lp.isFullScreenPage ? 0 : getPaddingLeft();
- mPageScrolls[i] = childLeft - scrollOffsetLeft - offsetX;
+ int scrollOffset = (getViewportWidth() - childWidth) / 2;
+ mPageScrolls[i] = childLeft - scrollOffset - offsetX;
- int pageGap = mPageSpacing;
- int next = i + delta;
- if (next != endIndex) {
- nextLp = (LayoutParams) getPageAt(next).getLayoutParams();
- } else {
- nextLp = null;
+ if (i != endIndex - delta) {
+ childLeft += childWidth + scrollOffset;
+ int nextScrollOffset = (getViewportWidth() - getChildWidth(i + delta)) /2;
+ childLeft += nextScrollOffset;
}
-
- // Prevent full screen pages from showing in the viewport
- // when they are not the current page.
- if (lp.isFullScreenPage) {
- pageGap = getPaddingLeft();
- } else if (nextLp != null && nextLp.isFullScreenPage) {
- pageGap = getPaddingRight();
- }
-
- childLeft += childWidth + pageGap;
}
}