diff --git a/src/com/android/email/activity/UIControllerOnePane.java b/src/com/android/email/activity/UIControllerOnePane.java index a51ca74e0..15fdcce27 100644 --- a/src/com/android/email/activity/UIControllerOnePane.java +++ b/src/com/android/email/activity/UIControllerOnePane.java @@ -40,8 +40,8 @@ import java.util.Set; * * One one-pane, only at most one fragment can be installed at a time. * - * Note due to the asynchronous nature of the fragment transaction, there is a window when - * there is no installed or visible fragments. + * Note: Always use {@link #commitFragmentTransaction} to operate fragment transactions, + * so that we can easily switch between synchronous and asynchronous transactions. * * Major TODOs * - TODO Newer/Older for message view with swipe! @@ -497,11 +497,14 @@ class UIControllerOnePane extends UIControllerBase { } /** - * Use this instead of {@link FragmentTransaction#commit}. We may switch to the synchronous + * Use this instead of {@link FragmentTransaction#commit}. We may switch to the asynchronous * transaction some day. */ private void commitFragmentTransaction(FragmentTransaction ft) { - ft.commit(); + if (!ft.isEmpty()) { + ft.commit(); + mActivity.getFragmentManager().executePendingTransactions(); + } } /** @@ -619,8 +622,8 @@ class UIControllerOnePane extends UIControllerBase { removeFragment(ft, installed); ft.attach(mPreviousFragment); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE); - commitFragmentTransaction(ft); mPreviousFragment = null; + commitFragmentTransaction(ft); return; } diff --git a/src/com/android/email/activity/UIControllerTwoPane.java b/src/com/android/email/activity/UIControllerTwoPane.java index 15ecf8680..bc393df6b 100644 --- a/src/com/android/email/activity/UIControllerTwoPane.java +++ b/src/com/android/email/activity/UIControllerTwoPane.java @@ -535,7 +535,10 @@ class UIControllerTwoPane extends UIControllerBase implements if (DEBUG_FRAGMENTS) { Log.d(Logging.LOG_TAG, this + " commitFragmentTransaction: " + ft); } - ft.commit(); + if (!ft.isEmpty()) { + ft.commit(); + mActivity.getFragmentManager().executePendingTransactions(); + } } /**