diff options
author | Vladimir Marko <vmarko@google.com> | 2013-10-04 16:42:17 +0100 |
---|---|---|
committer | Vladimir Marko <vmarko@google.com> | 2013-10-07 15:06:20 +0100 |
commit | 2824b0750e978e5a63f804a42e9eedba53e8d21d (patch) | |
tree | fc00d60a915c8322d2dacd3f1c197b0eec52d076 /src/com/android/launcher3 | |
parent | d4507eefa37245c012a68d148aa5f14d4638f96d (diff) | |
download | android_packages_apps_Trebuchet-2824b0750e978e5a63f804a42e9eedba53e8d21d.tar.gz android_packages_apps_Trebuchet-2824b0750e978e5a63f804a42e9eedba53e8d21d.tar.bz2 android_packages_apps_Trebuchet-2824b0750e978e5a63f804a42e9eedba53e8d21d.zip |
Don't measure GONE views.
Don't measure GONE views in ShortcutAndWidgetContainer and
PagedView. They will not be processed in onLayout anyway.
This is pre-requisite for avoiding costly onMeasure in GEL.
Bug: 10734110
Change-Id: I4c1bef41d9185af5eda42b43371546c60f341f87
Diffstat (limited to 'src/com/android/launcher3')
-rw-r--r-- | src/com/android/launcher3/PagedView.java | 90 | ||||
-rw-r--r-- | src/com/android/launcher3/ShortcutAndWidgetContainer.java | 4 |
2 files changed, 49 insertions, 45 deletions
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java index 96d8c1928..003b2db20 100644 --- a/src/com/android/launcher3/PagedView.java +++ b/src/com/android/launcher3/PagedView.java @@ -827,48 +827,50 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc for (int i = 0; i < childCount; i++) { // disallowing padding in paged view (just pass 0) final View child = getPageAt(i); - final LayoutParams lp = (LayoutParams) child.getLayoutParams(); + if (child.getVisibility() != GONE) { + final LayoutParams lp = (LayoutParams) child.getLayoutParams(); - int childWidthMode; - int childHeightMode; - int childWidth; - int childHeight; + int childWidthMode; + int childHeightMode; + int childWidth; + int childHeight; - if (!lp.isFullScreenPage) { - if (lp.width == LayoutParams.WRAP_CONTENT) { - childWidthMode = MeasureSpec.AT_MOST; - } else { - childWidthMode = MeasureSpec.EXACTLY; - } - - if (lp.height == LayoutParams.WRAP_CONTENT) { - childHeightMode = MeasureSpec.AT_MOST; - } else { - childHeightMode = MeasureSpec.EXACTLY; - } + if (!lp.isFullScreenPage) { + if (lp.width == LayoutParams.WRAP_CONTENT) { + childWidthMode = MeasureSpec.AT_MOST; + } else { + childWidthMode = MeasureSpec.EXACTLY; + } - childWidth = widthSize - horizontalPadding; - childHeight = heightSize - verticalPadding - mInsets.top - mInsets.bottom; - mNormalChildHeight = childHeight; + if (lp.height == LayoutParams.WRAP_CONTENT) { + childHeightMode = MeasureSpec.AT_MOST; + } else { + childHeightMode = MeasureSpec.EXACTLY; + } - } else { - childWidthMode = MeasureSpec.EXACTLY; - childHeightMode = MeasureSpec.EXACTLY; + childWidth = widthSize - horizontalPadding; + childHeight = heightSize - verticalPadding - mInsets.top - mInsets.bottom; + mNormalChildHeight = childHeight; - if (mUseMinScale) { - childWidth = getViewportWidth(); - childHeight = getViewportHeight(); } else { - childWidth = widthSize - getPaddingLeft() - getPaddingRight(); - childHeight = heightSize - getPaddingTop() - getPaddingBottom(); + childWidthMode = MeasureSpec.EXACTLY; + childHeightMode = MeasureSpec.EXACTLY; + + if (mUseMinScale) { + childWidth = getViewportWidth(); + childHeight = getViewportHeight(); + } else { + childWidth = widthSize - getPaddingLeft() - getPaddingRight(); + childHeight = heightSize - getPaddingTop() - getPaddingBottom(); + } } - } - final int childWidthMeasureSpec = - MeasureSpec.makeMeasureSpec(childWidth, childWidthMode); - final int childHeightMeasureSpec = - MeasureSpec.makeMeasureSpec(childHeight, childHeightMode); - child.measure(childWidthMeasureSpec, childHeightMeasureSpec); + final int childWidthMeasureSpec = + MeasureSpec.makeMeasureSpec(childWidth, childWidthMode); + final int childHeightMeasureSpec = + MeasureSpec.makeMeasureSpec(childHeight, childHeightMode); + child.measure(childWidthMeasureSpec, childHeightMeasureSpec); + } } setMeasuredDimension(scaledWidthSize, scaledHeightSize); @@ -929,18 +931,18 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc for (int i = startIndex; i != endIndex; i += delta) { final View child = getPageAt(i); - LayoutParams lp = (LayoutParams) child.getLayoutParams(); - int childTop; - if (lp.isFullScreenPage) { - childTop = offsetY; - } else { - childTop = offsetY + getPaddingTop() + mInsets.top; - if (mCenterPagesVertically) { - childTop += (getViewportHeight() - mInsets.top - mInsets.bottom - verticalPadding - child.getMeasuredHeight()) / 2; + if (child.getVisibility() != View.GONE) { + LayoutParams lp = (LayoutParams) child.getLayoutParams(); + int childTop; + if (lp.isFullScreenPage) { + childTop = offsetY; + } else { + childTop = offsetY + getPaddingTop() + mInsets.top; + if (mCenterPagesVertically) { + childTop += (getViewportHeight() - mInsets.top - mInsets.bottom - verticalPadding - child.getMeasuredHeight()) / 2; + } } - } - if (child.getVisibility() != View.GONE) { final int childWidth = child.getMeasuredWidth(); final int childHeight = child.getMeasuredHeight(); diff --git a/src/com/android/launcher3/ShortcutAndWidgetContainer.java b/src/com/android/launcher3/ShortcutAndWidgetContainer.java index b9511005e..fcd6f19ae 100644 --- a/src/com/android/launcher3/ShortcutAndWidgetContainer.java +++ b/src/com/android/launcher3/ShortcutAndWidgetContainer.java @@ -103,7 +103,9 @@ public class ShortcutAndWidgetContainer extends ViewGroup { for (int i = 0; i < count; i++) { View child = getChildAt(i); - measureChild(child); + if (child.getVisibility() != GONE) { + measureChild(child); + } } } |