diff options
| author | Raph Levien <raph@google.com> | 2012-10-15 17:22:26 -0700 |
|---|---|---|
| committer | Raph Levien <raph@google.com> | 2012-10-15 17:22:26 -0700 |
| commit | f5c1a8798f3a2e4196473fb1328159bd8297f178 (patch) | |
| tree | 88e8ff47f595567f44bbe8deef0d1dfd10ddef32 /core/java/android/widget/TextView.java | |
| parent | 87d57952af662a94637c1519b2189e22456af2db (diff) | |
Fix for bug 7344916 text view flickers when you hit enter
The flickering was caused by trying to scroll to the cursor position
while the view was in an inconsistent state (text updated to change the
number of lines, but layout not done yet). This patch defers the actual
setting of the cursor until layout is done, when layout is pending.
Change-Id: I8ed3a402beb8058ac7a7f3935afeb946a23308ab
Diffstat (limited to 'core/java/android/widget/TextView.java')
| -rw-r--r-- | core/java/android/widget/TextView.java | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index b3c679c34f84..751ed7c4549a 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -367,6 +367,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener private boolean mSingleLine; private int mDesiredHeightAtMeasure = -1; private boolean mIncludePad = true; + private int mDeferScroll = -1; // tmp primitives, so we don't alloc them on each draw private Rect mTempRect; @@ -6317,6 +6318,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); + if (mDeferScroll >= 0) { + int curs = mDeferScroll; + mDeferScroll = -1; + bringPointIntoView(curs); + } if (changed && mEditor != null) mEditor.invalidateTextDisplayList(); } @@ -6399,6 +6405,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener * This has to be called after layout. Returns true if anything changed. */ public boolean bringPointIntoView(int offset) { + if (isLayoutRequested()) { + mDeferScroll = offset; + return false; + } boolean changed = false; Layout layout = isShowingHint() ? mHintLayout: mLayout; @@ -7108,13 +7118,13 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener registerForPreDraw(); } + checkForResize(); + if (curs >= 0) { mHighlightPathBogus = true; if (mEditor != null) mEditor.makeBlink(); bringPointIntoView(curs); } - - checkForResize(); } /** @@ -7161,6 +7171,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener if (oldStart >= 0 || newStart >= 0) { invalidateCursor(Selection.getSelectionStart(buf), oldStart, newStart); + checkForResize(); registerForPreDraw(); if (mEditor != null) mEditor.makeBlink(); } |
