Merge "Optimize RTL properties resolution" into jb-mr2-dev
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 0938bb3..c47e111 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -11749,10 +11749,12 @@
/**
* Resolve all RTL related properties.
*
+ * @return true if resolution of RTL properties has been done
+ *
* @hide
*/
- public void resolveRtlPropertiesIfNeeded() {
- if (!needRtlPropertiesResolution()) return;
+ public boolean resolveRtlPropertiesIfNeeded() {
+ if (!needRtlPropertiesResolution()) return false;
// Order is important here: LayoutDirection MUST be resolved first
if (!isLayoutDirectionResolved()) {
@@ -11773,6 +11775,7 @@
resolveDrawables();
}
onRtlPropertiesChanged(getLayoutDirection());
+ return true;
}
/**
@@ -11825,6 +11828,7 @@
/**
* @return true if RTL properties need resolution.
+ *
*/
private boolean needRtlPropertiesResolution() {
return (mPrivateFlags2 & ALL_RTL_PROPERTIES_RESOLVED) != ALL_RTL_PROPERTIES_RESOLVED;
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index c7ce999..58c30e9 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -5453,15 +5453,19 @@
* @hide
*/
@Override
- public void resolveRtlPropertiesIfNeeded() {
- super.resolveRtlPropertiesIfNeeded();
- int count = getChildCount();
- for (int i = 0; i < count; i++) {
- final View child = getChildAt(i);
- if (child.isLayoutDirectionInherited()) {
- child.resolveRtlPropertiesIfNeeded();
+ public boolean resolveRtlPropertiesIfNeeded() {
+ final boolean result = super.resolveRtlPropertiesIfNeeded();
+ // We dont need to resolve the children RTL properties if nothing has changed for the parent
+ if (result) {
+ int count = getChildCount();
+ for (int i = 0; i < count; i++) {
+ final View child = getChildAt(i);
+ if (child.isLayoutDirectionInherited()) {
+ child.resolveRtlPropertiesIfNeeded();
+ }
}
}
+ return result;
}
/**