File tree Expand file tree Collapse file tree 3 files changed +12
-0
lines changed
lib/java/com/google/android/material Expand file tree Collapse file tree 3 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -186,6 +186,9 @@ public void startListeningForBackCallbacks(
186186 @ DoNotInline
187187 @ Override
188188 public void stopListeningForBackCallbacks (@ NonNull View view ) {
189+ if (onBackInvokedCallback == null ) {
190+ return ;
191+ }
189192 OnBackInvokedDispatcher onBackInvokedDispatcher = view .findOnBackInvokedDispatcher ();
190193 if (onBackInvokedDispatcher == null ) {
191194 return ;
Original file line number Diff line number Diff line change @@ -476,6 +476,8 @@ protected void onDetachedFromWindow() {
476476 DrawerLayout drawerLayout = (DrawerLayout ) parent ;
477477 drawerLayout .removeDrawerListener (backDrawerListener );
478478 }
479+
480+ backOrchestrator .stopListeningForBackCallbacks ();
479481 }
480482
481483 @ Override
Original file line number Diff line number Diff line change @@ -265,6 +265,13 @@ protected void onAttachedToWindow() {
265265 MaterialShapeUtils .setParentAbsoluteElevation (this );
266266 }
267267
268+ @ Override
269+ protected void onDetachedFromWindow () {
270+ super .onDetachedFromWindow ();
271+
272+ backOrchestrator .stopListeningForBackCallbacks ();
273+ }
274+
268275 @ Override
269276 @ NonNull
270277 public CoordinatorLayout .Behavior <SearchView > getBehavior () {
You can’t perform that action at this time.
0 commit comments