Merge "Sum up character widths to get the last line width for ellipsis." into nyc-dev

am: f2cbf95b6b

* commit 'f2cbf95b6b48d0c5dea14db4edbd255ff751beaa':
  Sum up character widths to get the last line width for ellipsis.

Change-Id: I28193273103bf68fbd778048540c35dbf9a51170
This commit is contained in:
Keisuke Kuroyanagi
2016-05-10 21:25:13 +00:00
committed by android-build-merger

View File

@@ -754,15 +754,21 @@ public class StaticLayout extends Layout {
&& ellipsize != TextUtils.TruncateAt.MARQUEE));
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.
float width = 0;
int flag = 0;
for (int i = remainingLineCount - 1; i < breakCount; i++) {
width += lineWidths[i];
if (i == breakCount - 1) {
width += lineWidths[i];
} else {
for (int j = (i == 0 ? 0 : breaks[i - 1]); j < breaks[i]; j++) {
width += widths[j];
}
}
flag |= flags[i] & TAB_MASK;
}
// Treat the last line and overflowed lines as a single line.
breaks[remainingLineCount - 1] = breaks[breakCount - 1];
lineWidths[remainingLineCount - 1] = width;
flags[remainingLineCount - 1] = flag;