All runnable are stopped on detach. DO NOT MERGE.
This prevents these runnable from holding a reference to the context that will prevent it from being garbage collected. The blinking cursor is especially bad and appears in memore traces. Change-Id: I8acbfbbfc59975dfd7bcf06e941074ea7dc0b0bc
This commit is contained in:
@@ -3810,6 +3810,18 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
hideError();
|
||||
}
|
||||
|
||||
if (mBlink != null) {
|
||||
mBlink.cancel();
|
||||
}
|
||||
|
||||
if (mInsertionPointCursorController != null) {
|
||||
mInsertionPointCursorController.onDetached();
|
||||
}
|
||||
|
||||
if (mSelectionModifierCursorController != null) {
|
||||
mSelectionModifierCursorController.onDetached();
|
||||
}
|
||||
|
||||
hideControllers();
|
||||
}
|
||||
|
||||
@@ -7720,6 +7732,13 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
* @param event The touch event
|
||||
*/
|
||||
public boolean onTouchEvent(MotionEvent event);
|
||||
|
||||
/**
|
||||
* Called when the view is detached from window. Perform house keeping task, such as
|
||||
* stopping Runnable thread that would otherwise keep a reference on the context, thus
|
||||
* preventing the activity to be recycled.
|
||||
*/
|
||||
public void onDetached();
|
||||
}
|
||||
|
||||
private class HandleView extends View {
|
||||
@@ -7997,12 +8016,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
|
||||
public void hide() {
|
||||
mHandle.hide();
|
||||
TextView.this.removeCallbacks(mHider);
|
||||
removeCallbacks(mHider);
|
||||
}
|
||||
|
||||
private void hideDelayed(int msec) {
|
||||
TextView.this.removeCallbacks(mHider);
|
||||
TextView.this.postDelayed(mHider, msec);
|
||||
removeCallbacks(mHider);
|
||||
postDelayed(mHider, msec);
|
||||
}
|
||||
|
||||
public boolean isShowing() {
|
||||
@@ -8042,6 +8061,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
hide();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetached() {
|
||||
removeCallbacks(mHider);
|
||||
}
|
||||
}
|
||||
|
||||
private class SelectionModifierCursorController implements CursorController {
|
||||
@@ -8219,6 +8243,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
hide();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetached() {
|
||||
removeCallbacks(mHider);
|
||||
}
|
||||
}
|
||||
|
||||
private void hideInsertionPointCursorController() {
|
||||
|
||||
Reference in New Issue
Block a user