Skip to content

Commit

Permalink
Fix nested fragment transactions crash (fix #994)
Browse files Browse the repository at this point in the history
Signed-off-by: Daniele Ricci <[email protected]>
  • Loading branch information
daniele-athome committed Apr 22, 2017
1 parent a2a3444 commit 61f9c10
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1076,12 +1076,10 @@ private AudioFragment getAudioFragment() {
FragmentActivity parent = getActivity();
if (parent != null) {
fragment = new AudioFragment();
FragmentManager fm = parent.getSupportFragmentManager();
FragmentManager fm = getFragmentManager();
fm.beginTransaction()
.add(fragment, "audio")
.commit();
// commit immediately please
fm.executePendingTransactions();
}
}

Expand Down
9 changes: 4 additions & 5 deletions app/src/main/java/org/kontalk/ui/ComposeMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,10 @@ protected boolean isNormalUpNavigation() {

private void setComposeFragment(@NonNull AbstractComposeFragment f) {
mFragment = f;
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.fragment_compose_message, f);
ft.setTransition(FragmentTransaction.TRANSIT_NONE);
ft.commitAllowingStateLoss();
getSupportFragmentManager().executePendingTransactions();
getSupportFragmentManager().beginTransaction()
.replace(R.id.fragment_compose_message, f)
.setTransition(FragmentTransaction.TRANSIT_NONE)
.commitNowAllowingStateLoss();
}

@Override
Expand Down

0 comments on commit 61f9c10

Please sign in to comment.