| 1378 | } |
| 1379 | |
| 1380 | private void fireCloseEvent(boolean parentsToo) { |
| 1381 | closeListeners.fireActionEvent(new ActionEvent(this)); |
| 1382 | if (parentsToo && parentSheet != null) { |
| 1383 | parentSheet.fireCloseEvent(true); |
| 1384 | } |
| 1385 | // Auto-resolve a pending showForResult() with null when the sheet closes |
| 1386 | // without finish() having been called (back, swipe-dismiss, or being |
| 1387 | // replaced by another sheet). This mirrors how Android Activity onResult |
| 1388 | // semantics treat a cancelled return: subscribers see a null payload. |
| 1389 | AsyncResource<Object> r = pendingResult; |
| 1390 | if (r != null && !r.isDone()) { |
| 1391 | pendingResult = null; |
| 1392 | try { |
| 1393 | r.complete(null); |
| 1394 | } catch (Throwable t) { |
| 1395 | com.codename1.io.Log.e(t); |
| 1396 | } |
| 1397 | } |
| 1398 | } |
| 1399 | |
| 1400 | /// Adds listener to be notified when user goes back to the parent. This is not |
| 1401 | /// fired if the sheet is simply closed. Only if the "back" button is pressed, |