summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Raph Levien <raph@google.com> 2012-10-03 09:34:24 -0700
committer Raph Levien <raph@google.com> 2012-10-03 09:34:24 -0700
commit6b558994d4ea8dfa1967f96e272496a7d2b8972a (patch)
tree448cf738b12a88f218fa32ac737901a2a8296822
parent48315436eece69f4d047c2b14ac63e62f757b88c (diff)
Fix for bug 6954231 text wraps on second line and is fused...
When breaking a line, the paragraphs below the new line break were still being drawn in their old location. This only happened when the height was fill_parent, otherwise the height change would force a relayout, which in turn would do a full invalidation. This patch checks for changes to the layout height (not just the widget height, which won't change when it's fill_parent), and invalidates. Change-Id: I64adb9f5eae0479c1c9c8d37c10c2c27a6f582a8
-rw-r--r--core/java/android/widget/Editor.java11
1 files changed, 11 insertions, 0 deletions
diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java
index c67cae636f45..19b825c4fa0f 100644
--- a/core/java/android/widget/Editor.java
+++ b/core/java/android/widget/Editor.java
@@ -122,6 +122,7 @@ public class Editor {
InputMethodState mInputMethodState;
DisplayList[] mTextDisplayLists;
+ int mLastLayoutHeight;
boolean mFrozenWithFocus;
boolean mSelectionMoved;
@@ -1258,6 +1259,16 @@ public class Editor {
mTextDisplayLists = new DisplayList[ArrayUtils.idealObjectArraySize(0)];
}
+ // If the height of the layout changes (usually when inserting or deleting a line,
+ // but could be changes within a span), invalidate everything. We could optimize
+ // more aggressively (for example, adding offsets to blocks) but it would be more
+ // complex and we would only get the benefit in some cases.
+ int layoutHeight = layout.getHeight();
+ if (mLastLayoutHeight != layoutHeight) {
+ invalidateTextDisplayList();
+ mLastLayoutHeight = layoutHeight;
+ }
+
DynamicLayout dynamicLayout = (DynamicLayout) layout;
int[] blockEndLines = dynamicLayout.getBlockEndLines();
int[] blockIndices = dynamicLayout.getBlockIndices();