Skip to content

Commit 6f8c1ba

Browse files
raphlinusAndroid (Google) Code Review
authored andcommitted
Merge "Fix for bug 7344916 text view flickers when you hit enter" into jb-mr1-dev
2 parents df40923 + f5c1a87 commit 6f8c1ba

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

core/java/android/widget/TextView.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ static class Drawables {
367367
private boolean mSingleLine;
368368
private int mDesiredHeightAtMeasure = -1;
369369
private boolean mIncludePad = true;
370+
private int mDeferScroll = -1;
370371

371372
// tmp primitives, so we don't alloc them on each draw
372373
private Rect mTempRect;
@@ -6317,6 +6318,11 @@ private void checkForRelayout() {
63176318
@Override
63186319
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
63196320
super.onLayout(changed, left, top, right, bottom);
6321+
if (mDeferScroll >= 0) {
6322+
int curs = mDeferScroll;
6323+
mDeferScroll = -1;
6324+
bringPointIntoView(curs);
6325+
}
63206326
if (changed && mEditor != null) mEditor.invalidateTextDisplayList();
63216327
}
63226328

@@ -6399,6 +6405,10 @@ private boolean bringTextIntoView() {
63996405
* This has to be called after layout. Returns true if anything changed.
64006406
*/
64016407
public boolean bringPointIntoView(int offset) {
6408+
if (isLayoutRequested()) {
6409+
mDeferScroll = offset;
6410+
return false;
6411+
}
64026412
boolean changed = false;
64036413

64046414
Layout layout = isShowingHint() ? mHintLayout: mLayout;
@@ -7108,13 +7118,13 @@ void updateAfterEdit() {
71087118
registerForPreDraw();
71097119
}
71107120

7121+
checkForResize();
7122+
71117123
if (curs >= 0) {
71127124
mHighlightPathBogus = true;
71137125
if (mEditor != null) mEditor.makeBlink();
71147126
bringPointIntoView(curs);
71157127
}
7116-
7117-
checkForResize();
71187128
}
71197129

71207130
/**
@@ -7161,6 +7171,7 @@ void spanChange(Spanned buf, Object what, int oldStart, int newStart, int oldEnd
71617171

71627172
if (oldStart >= 0 || newStart >= 0) {
71637173
invalidateCursor(Selection.getSelectionStart(buf), oldStart, newStart);
7174+
checkForResize();
71647175
registerForPreDraw();
71657176
if (mEditor != null) mEditor.makeBlink();
71667177
}

0 commit comments

Comments
 (0)