Fix StaticLayout crash when maxLines = 0

An app setting maxLines = 0 is an edge case, but it can happen. We
had some logic that would index an array at -1 in that case. This
patch just skips the fixup of the ellipsis line break in that case.

Bug: 22353342
Change-Id: I940cf0782b319010f5aedf75b9291df4ac2976d8
This commit is contained in:
Raph Levien
2015-07-09 15:38:04 -07:00
parent 7d170797ac
commit 04a84559fd

View File

@@ -744,7 +744,8 @@ public class StaticLayout extends Layout {
&& (ellipsize == TextUtils.TruncateAt.END
|| (mMaximumVisibleLineCount == 1
&& ellipsize != TextUtils.TruncateAt.MARQUEE));
if (remainingLineCount < breakCount && ellipsisMayBeApplied) {
if (remainingLineCount > 0 && remainingLineCount < breakCount &&
ellipsisMayBeApplied) {
// Treat the last line and overflowed lines as a single line.
breaks[remainingLineCount - 1] = breaks[breakCount - 1];
// Calculate width and flag.