Skip to content

Commit 8a6ba49

Browse files
Gilles DebunneAndroid (Google) Code Review
authored andcommitted
Merge "All runnable are stopped on detach. DO NOT MERGE." into gingerbread
2 parents 53841df + d5253fa commit 8a6ba49

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

core/java/android/widget/TextView.java

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3815,6 +3815,18 @@ protected void onDetachedFromWindow() {
38153815
hideError();
38163816
}
38173817

3818+
if (mBlink != null) {
3819+
mBlink.cancel();
3820+
}
3821+
3822+
if (mInsertionPointCursorController != null) {
3823+
mInsertionPointCursorController.onDetached();
3824+
}
3825+
3826+
if (mSelectionModifierCursorController != null) {
3827+
mSelectionModifierCursorController.onDetached();
3828+
}
3829+
38183830
hideControllers();
38193831
}
38203832

@@ -7718,6 +7730,13 @@ private interface CursorController extends ViewTreeObserver.OnTouchModeChangeLis
77187730
* @param event The touch event
77197731
*/
77207732
public boolean onTouchEvent(MotionEvent event);
7733+
7734+
/**
7735+
* Called when the view is detached from window. Perform house keeping task, such as
7736+
* stopping Runnable thread that would otherwise keep a reference on the context, thus
7737+
* preventing the activity to be recycled.
7738+
*/
7739+
public void onDetached();
77217740
}
77227741

77237742
private class HandleView extends View {
@@ -7995,12 +8014,12 @@ public void show() {
79958014

79968015
public void hide() {
79978016
mHandle.hide();
7998-
TextView.this.removeCallbacks(mHider);
8017+
removeCallbacks(mHider);
79998018
}
80008019

80018020
private void hideDelayed(int msec) {
8002-
TextView.this.removeCallbacks(mHider);
8003-
TextView.this.postDelayed(mHider, msec);
8021+
removeCallbacks(mHider);
8022+
postDelayed(mHider, msec);
80048023
}
80058024

80068025
public boolean isShowing() {
@@ -8040,6 +8059,11 @@ public void onTouchModeChanged(boolean isInTouchMode) {
80408059
hide();
80418060
}
80428061
}
8062+
8063+
@Override
8064+
public void onDetached() {
8065+
removeCallbacks(mHider);
8066+
}
80438067
}
80448068

80458069
private class SelectionModifierCursorController implements CursorController {
@@ -8197,6 +8221,11 @@ public void onTouchModeChanged(boolean isInTouchMode) {
81978221
hide();
81988222
}
81998223
}
8224+
8225+
@Override
8226+
public void onDetached() {
8227+
removeCallbacks(mHider);
8228+
}
82008229
}
82018230

82028231
private void hideInsertionPointCursorController() {

0 commit comments

Comments
 (0)