Commit 320aa4c
Jeremy Woods
Ensure FragmentNavigator does not destroy entries early
There is a case where if you navigate to a destination and the fragment
that is assocated with the destination does a navigate with popUpTo in
its onResume() lifecycle callback, the FragmentNavigator incorrectly
destroys the entry before the associated fragment is destroyed. The
reason for this is the timing between fragment lifecycle callbacks and
Lifecycle. The onResume() lifecycle callback happens immediately before
the `ON_RESUME` Lifecycle event and once the lifecycle listeners in
FragmentNavigator get the `ON_RESUME` event, the state of the entry has
changed and gets destroyed.
Instead of always marking entries as complete when we get the end
Lifecycle events (ON_RESUME and ON_DESTROY) from the fragment, we should
check whether the back stack contains the entry or not.
RelNote: "Fixed an issue in Navigation with fragments where removing a
fragment via navigate with popUpTo in its `onResume()` lifecycle
callback would cause an `IllegalStateException`."
Test: added test
Bug: 279644470
Change-Id: I21884c268cf213caacabe19db38fd49a1ac829fa1 parent c2a537d commit 320aa4c
File tree
2 files changed
+46
-26
lines changed2 files changed
+46
-26
lines changedLines changed: 25 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
| |||
284 | 286 | | |
285 | 287 | | |
286 | 288 | | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
287 | 303 | | |
288 | 304 | | |
289 | 305 | | |
| |||
295 | 311 | | |
296 | 312 | | |
297 | 313 | | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
298 | 323 | | |
299 | 324 | | |
300 | 325 | | |
| |||
Lines changed: 21 additions & 26 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
33 | 32 | | |
34 | 33 | | |
35 | 34 | | |
| |||
75 | 74 | | |
76 | 75 | | |
77 | 76 | | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
88 | 87 | | |
89 | | - | |
90 | 88 | | |
91 | 89 | | |
92 | 90 | | |
93 | 91 | | |
94 | 92 | | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
108 | 104 | | |
109 | | - | |
110 | 105 | | |
111 | 106 | | |
112 | 107 | | |
| |||
0 commit comments