diff options
| author | 2023-04-21 19:12:27 +0000 | |
|---|---|---|
| committer | 2023-04-21 19:12:27 +0000 | |
| commit | 8412b132c7dd660128dfc99cda33e6da4ca73bca (patch) | |
| tree | 83d5c63df9b632c10f3163747d92f2b2e88b22e8 | |
| parent | 913ba5eef1627a1573c90ec2c3f024a1243c9f9a (diff) | |
| parent | 61d982884fa0e14dc5f58e872f182bb5c1b04afd (diff) | |
Merge "Fix cursor not blinking when view re-added to layout"
| -rw-r--r-- | core/java/android/widget/Editor.java | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java index fadad99f0885..14aac89dcb10 100644 --- a/core/java/android/widget/Editor.java +++ b/core/java/android/widget/Editor.java @@ -709,7 +709,10 @@ public class Editor { } getPositionListener().addSubscriber(mCursorAnchorInfoNotifier, true); - makeBlink(); + // Call resumeBlink here instead of makeBlink to ensure that if mBlink is not null the + // Blink object is uncancelled. This ensures when a view is removed and added back the + // cursor will resume blinking. + resumeBlink(); } void onDetachedFromWindow() { @@ -1081,8 +1084,10 @@ public class Editor { private void resumeBlink() { if (mBlink != null) { mBlink.uncancel(); - makeBlink(); } + // Moving makeBlink outside of the null check block ensures that mBlink object gets + // instantiated when the view is added to the window if mBlink is still null. + makeBlink(); } void adjustInputType(boolean password, boolean passwordInputType, @@ -2862,6 +2867,9 @@ public class Editor { if (shouldBlink()) { mShowCursor = SystemClock.uptimeMillis(); if (mBlink == null) mBlink = new Blink(); + // Call uncancel as mBlink could have previously been cancelled and cursor will not + // resume blinking unless uncancelled. + mBlink.uncancel(); mTextView.removeCallbacks(mBlink); mTextView.postDelayed(mBlink, BLINK); } else { |