Merge "Revert "Fix TextView layout reuse when maxLines is set"" into nyc-dev am: 990e26118d

am: 6fe1ab7f21

* commit '6fe1ab7f21a7b8d1b88334020a6f11aea6b7a771':
  Revert "Fix TextView layout reuse when maxLines is set"

Change-Id: I9141cc021ed511988f8fd4d9f6b4ea7d04aca270
This commit is contained in:
Siyamed Sinir
2016-05-27 19:00:11 +00:00
committed by android-build-merger

View File

@@ -6982,19 +6982,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;
@@ -7067,7 +7062,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) {
@@ -7099,7 +7094,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) {