Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Fix crash when current BackStack is null #160

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ public void pushScreen(Fragment fragment, @Nullable Bundle options) {
ft.setCustomAnimations(anim.enter, anim.exit, anim.popEnter, anim.popExit);
}
BackStack bsi = getCurrentBackStack();
if (bsi == null) {
Log.w(TAG, "Trying to push with a null BackStack.");
return;
}
ft
.detach(currentFragment)
.add(container.getId(), fragment)
Expand Down Expand Up @@ -209,6 +213,10 @@ public void onBackPressed() {

public void pop() {
BackStack bsi = getCurrentBackStack();
if (bsi == null) {
Log.w(TAG, "Trying to pop with a null BackStack.");
return;
}
if (bsi.getSize() == 1) {
dismiss();
return;
Expand Down Expand Up @@ -281,7 +289,10 @@ private Fragment getCurrentFragment() {
}

private BackStack getCurrentBackStack() {
return backStacks.peek();
if (backStacks.size() > 0) {
return backStacks.peek();
}
return null;
}

@NonNull
Expand Down