Merge "Fix DynamicLayout init to use transformed text length." into sc-dev

This commit is contained in:
Ahaan Ugale
2021-02-08 18:08:59 +00:00
committed by Android (Google) Code Review

View File

@@ -475,9 +475,8 @@ public class DynamicLayout extends Layout {
mObjects.insertAt(0, dirs);
final int baseLength = mBase.length();
// Update from 0 characters to whatever the real text is
reflow(mBase, 0, 0, baseLength);
// Update from 0 characters to whatever the displayed text is
reflow(mBase, 0, 0, mDisplay.length());
if (mBase instanceof Spannable) {
if (mWatcher == null)
@@ -485,6 +484,7 @@ public class DynamicLayout extends Layout {
// Strip out any watchers for other DynamicLayouts.
final Spannable sp = (Spannable) mBase;
final int baseLength = mBase.length();
final ChangeWatcher[] spans = sp.getSpans(0, baseLength, ChangeWatcher.class);
for (int i = 0; i < spans.length; i++) {
sp.removeSpan(spans[i]);