From 108b013a517e43c352208cb359b595e4e44819d8 Mon Sep 17 00:00:00 2001 From: Siyamed Sinir Date: Fri, 27 May 2016 01:36:05 +0000 Subject: [PATCH] Revert "Fix TextView layout reuse when maxLines is set" This reverts commit f75775ea7ff25fc9039ce7994312b29419294902. Bug: 28885989 Bug: 28468120 Change-Id: I6fa5401c8a76db1bacc2d8201eece91a3c52b758 --- core/java/android/widget/TextView.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index 3711b9402f3a..fc120eb0e65f 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -6983,19 +6983,14 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener return false; } - private static int desired(Layout layout, int maxLines) { + private static int desired(Layout layout) { int n = layout.getLineCount(); CharSequence text = layout.getText(); float max = 0; - // if maxLines is set, and the text length is greater that the length of the text in the - // layout, it means that there is a cut-off and we cannot use it. - if (maxLines != -1 && text.length() > layout.getLineEnd(n - 1)) { - return -1; - } - // if any line was wrapped, we can't use it. // but it's ok for the last line not to have a newline + for (int i = 0; i < n - 1; i++) { if (text.charAt(layout.getLineEnd(i) - 1) != '\n') return -1; @@ -7068,7 +7063,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener width = widthSize; } else { if (mLayout != null && mEllipsize == null) { - des = desired(mLayout, getMaxLines()); + des = desired(mLayout); } if (des < 0) { @@ -7100,7 +7095,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener int hintWidth; if (mHintLayout != null && mEllipsize == null) { - hintDes = desired(mHintLayout, getMaxLines()); + hintDes = desired(mHintLayout); } if (hintDes < 0) { -- 2.11.0