Fix: TextView makes new layouts too frequently.
TextView#checkForRelayout was almost always called in
TextView#onRtlPropertiesChanged.
However, #onRtlPropertiesChanged just checks if re-layout
can be skipped for when the text has changed. As a result,
TextView makes new layouts too frequently in that method.
With this patch, TextView#checkForRelayout is called only
when mTextDir has actually changed.
Bug: 17971103
Change-Id: I449d8c8fd7370495cd5af9e38cada942744ca801
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 78b5d5d..3b95130 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -9499,10 +9499,12 @@
public void onRtlPropertiesChanged(int layoutDirection) {
super.onRtlPropertiesChanged(layoutDirection);
- mTextDir = getTextDirectionHeuristic();
-
- if (mLayout != null) {
- checkForRelayout();
+ final TextDirectionHeuristic newTextDir = getTextDirectionHeuristic();
+ if (mTextDir != newTextDir) {
+ mTextDir = newTextDir;
+ if (mLayout != null) {
+ checkForRelayout();
+ }
}
}