Skip to content

Commit 2eca613

Browse files
adampAndroid (Google) Code Review
authored andcommitted
Merge "Fix bug 5528574 - "View not attached to window manager" upon orientation change when there is a dialog with ActionMode on" into ics-mr1
2 parents 46a10ee + cfe9aee commit 2eca613

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

core/java/android/app/Dialog.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ public class Dialog implements DialogInterface, Window.Callback,
110110

111111
private Handler mListenersHandler;
112112

113+
private ActionMode mActionMode;
114+
113115
private final Runnable mDismissAction = new Runnable() {
114116
public void run() {
115117
dismissDialog();
@@ -310,6 +312,9 @@ private void dismissDialog() {
310312
try {
311313
mWindowManager.removeView(mDecor);
312314
} finally {
315+
if (mActionMode != null) {
316+
mActionMode.finish();
317+
}
313318
mDecor = null;
314319
mWindow.closeAllPanels();
315320
onStop();
@@ -952,10 +957,26 @@ public ActionMode onWindowStartingActionMode(ActionMode.Callback callback) {
952957
return null;
953958
}
954959

960+
/**
961+
* {@inheritDoc}
962+
*
963+
* Note that if you override this method you should always call through
964+
* to the superclass implementation by calling super.onActionModeStarted(mode).
965+
*/
955966
public void onActionModeStarted(ActionMode mode) {
967+
mActionMode = mode;
956968
}
957969

970+
/**
971+
* {@inheritDoc}
972+
*
973+
* Note that if you override this method you should always call through
974+
* to the superclass implementation by calling super.onActionModeFinished(mode).
975+
*/
958976
public void onActionModeFinished(ActionMode mode) {
977+
if (mode == mActionMode) {
978+
mActionMode = null;
979+
}
959980
}
960981

961982
/**

0 commit comments

Comments
 (0)