summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaj Yengisetty <rajesh@cyngn.com>2014-06-17 16:26:16 -0700
committerAbhisek Devkota <ciwrl@cyanogenmod.com>2014-06-18 22:02:00 +0000
commit26f5466a580cb3d9171fc90c2d4c17f2f735860b (patch)
tree97a091291a4b8caffeae367dc04d9bd00f4112c4
parentdfbfff151c84b33744c6c631af31b9f149efc528 (diff)
downloadandroid_packages_apps_Trebuchet-26f5466a580cb3d9171fc90c2d4c17f2f735860b.tar.gz
android_packages_apps_Trebuchet-26f5466a580cb3d9171fc90c2d4c17f2f735860b.tar.bz2
android_packages_apps_Trebuchet-26f5466a580cb3d9171fc90c2d4c17f2f735860b.zip
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 b258dfd7d..64d97d1d2 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -927,6 +927,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();
@@ -941,10 +943,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()];
}
@@ -952,7 +951,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;
@@ -970,26 +969,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;
}
}