summaryrefslogtreecommitdiffstats
path: root/core/java/android/view/View.java
diff options
context:
space:
mode:
authorChet Haase <chet@google.com>2012-12-19 07:43:02 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-12-19 07:43:23 -0800
commit118257517a4b715f4f0318c03f14b3236721dd01 (patch)
tree08bd68aa64468a3522b45d95f0e86f8138c8ccfd /core/java/android/view/View.java
parentceab6cbf781d084ab4bb1b4985d7202f5c5b9ed0 (diff)
parentcc699b4fe396b3f93d45211d0df6f02baa325b2f (diff)
downloadframeworks_base-118257517a4b715f4f0318c03f14b3236721dd01.zip
frameworks_base-118257517a4b715f4f0318c03f14b3236721dd01.tar.gz
frameworks_base-118257517a4b715f4f0318c03f14b3236721dd01.tar.bz2
Merge "Fix for requestLayout-during-layout inefficiencies"
Diffstat (limited to 'core/java/android/view/View.java')
-rw-r--r--core/java/android/view/View.java24
1 files changed, 20 insertions, 4 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 080e7c0..97287c3 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -15509,17 +15509,27 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* handle possible request-during-layout errors correctly.</p>
*/
public void requestLayout() {
- ViewRootImpl viewRoot = getViewRootImpl();
- if (viewRoot != null && viewRoot.isInLayout()) {
- viewRoot.requestLayoutDuringLayout(this);
- return;
+ if (mAttachInfo != null && mAttachInfo.mViewRequestingLayout == null) {
+ // Only trigger request-during-layout logic if this is the view requesting it,
+ // not the views in its parent hierarchy
+ ViewRootImpl viewRoot = getViewRootImpl();
+ if (viewRoot != null && viewRoot.isInLayout()) {
+ if (!viewRoot.requestLayoutDuringLayout(this)) {
+ return;
+ }
+ }
+ mAttachInfo.mViewRequestingLayout = this;
}
+
mPrivateFlags |= PFLAG_FORCE_LAYOUT;
mPrivateFlags |= PFLAG_INVALIDATED;
if (mParent != null && !mParent.isLayoutRequested()) {
mParent.requestLayout();
}
+ if (mAttachInfo != null && mAttachInfo.mViewRequestingLayout == this) {
+ mAttachInfo.mViewRequestingLayout = null;
+ }
}
/**
@@ -18000,6 +18010,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
final Point mPoint = new Point();
/**
+ * Used to track which View originated a requestLayout() call, used when
+ * requestLayout() is called during layout.
+ */
+ View mViewRequestingLayout;
+
+ /**
* Creates a new set of attachment information with the specified
* events handler and thread.
*