From 17b0bda4db04d0918df807786a2cd7addbdd4f25 Mon Sep 17 00:00:00 2001 From: Keisuke Kuroyanagi Date: Fri, 19 Jun 2015 15:24:07 +0900 Subject: 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 --- core/java/android/widget/TextView.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index 78b5d5dd65c9..3b95130466ab 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -9499,10 +9499,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener 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(); + } } } -- cgit v1.2.3-59-g8ed1b