|
17 | 17 | import android.view.View;
|
18 | 18 | import android.view.ViewGroup;
|
19 | 19 | import android.view.ViewStructure;
|
| 20 | +import android.view.Window; |
20 | 21 | import android.view.WindowManager;
|
21 | 22 | import android.view.accessibility.AccessibilityEvent;
|
22 | 23 | import android.widget.FrameLayout;
|
@@ -347,24 +348,26 @@ private void updateProperties() {
|
347 | 348 | Assertions.assertNotNull(mDialog, "mDialog must exist when we call updateProperties");
|
348 | 349 |
|
349 | 350 | Activity currentActivity = getCurrentActivity();
|
350 |
| - if (currentActivity != null) { |
351 |
| - int activityWindowFlags = currentActivity.getWindow().getAttributes().flags; |
352 |
| - if ((activityWindowFlags & WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0) { |
353 |
| - mDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); |
354 |
| - } else { |
355 |
| - mDialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); |
356 |
| - } |
| 351 | + |
| 352 | + Window window = mDialog.getWindow(); |
| 353 | + if (currentActivity == null || currentActivity.isFinishing() || !window.isActive()) { |
| 354 | + // If the activity has disappeared, then we shouldn't update the window associated to the |
| 355 | + // Dialog. |
| 356 | + return; |
| 357 | + } |
| 358 | + int activityWindowFlags = currentActivity.getWindow().getAttributes().flags; |
| 359 | + if ((activityWindowFlags & WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0) { |
| 360 | + window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); |
| 361 | + } else { |
| 362 | + window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); |
357 | 363 | }
|
358 | 364 |
|
359 | 365 | if (mTransparent) {
|
360 |
| - mDialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); |
| 366 | + window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); |
361 | 367 | } else {
|
362 |
| - mDialog.getWindow().setDimAmount(0.5f); |
363 |
| - mDialog |
364 |
| - .getWindow() |
365 |
| - .setFlags( |
366 |
| - WindowManager.LayoutParams.FLAG_DIM_BEHIND, |
367 |
| - WindowManager.LayoutParams.FLAG_DIM_BEHIND); |
| 368 | + window.setDimAmount(0.5f); |
| 369 | + window.setFlags( |
| 370 | + WindowManager.LayoutParams.FLAG_DIM_BEHIND, WindowManager.LayoutParams.FLAG_DIM_BEHIND); |
368 | 371 | }
|
369 | 372 | }
|
370 | 373 |
|
|
0 commit comments