Skip to content

Instantly share code, notes, and snippets.

@KaustubhPatange
Created February 7, 2023 12:05
Show Gist options
  • Save KaustubhPatange/969e57f69d3d2cc7e37fc3b6d9d5fa7f to your computer and use it in GitHub Desktop.
Save KaustubhPatange/969e57f69d3d2cc7e37fc3b6d9d5fa7f to your computer and use it in GitHub Desktop.
class OnBackPressedDispatcher ... {
...
@MainThread
public void onBackPressed() {
Iterator<OnBackPressedCallback> iterator =
mOnBackPressedCallbacks.descendingIterator();
while (iterator.hasNext()) {
OnBackPressedCallback callback = iterator.next();
if (callback.isEnabled()) {
callback.handleOnBackPressed();
return;
}
}
if (mFallbackOnBackPressed != null) {
mFallbackOnBackPressed.run();
}
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment