diff options
author | Yorke Lee <yorkelee@google.com> | 2014-10-28 22:57:16 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-10-28 22:57:16 +0000 |
commit | c29af0a4685eda1c0924781db1ecb8329275ba2c (patch) | |
tree | d64408ae79fbef46a11efb5dc7229bcb49c1cb6a | |
parent | 11e6c3b10b6de3ea64f24ca044c62b9848450904 (diff) | |
parent | 8265c1eb4d2c3fc627cded0bbbee5ca5325b6b98 (diff) |
am 8265c1eb: Merge "Fix various IllegalStateExceptions in Dialer" into lmp-mr1-dev
* commit '8265c1eb4d2c3fc627cded0bbbee5ca5325b6b98':
Fix various IllegalStateExceptions in Dialer
-rw-r--r-- | src/com/android/dialer/DialtactsActivity.java | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java index 560fb26a2..5494b7b54 100644 --- a/src/com/android/dialer/DialtactsActivity.java +++ b/src/com/android/dialer/DialtactsActivity.java @@ -176,6 +176,11 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O */ private ListsFragment mListsFragment; + /** + * Tracks whether onSaveInstanceState has been called. If true, no fragment transactions can + * be commited. + */ + private boolean mStateSaved; private boolean mInDialpadSearch; private boolean mInRegularSearch; private boolean mClearSearchOnPause; @@ -460,6 +465,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O @Override protected void onResume() { super.onResume(); + mStateSaved = false; if (mFirstLaunch) { displayFragment(getIntent()); } else if (!phoneIsInUse() && mInCallDialpadUp) { @@ -481,6 +487,9 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O hideDialpadAndSearchUi(); mClearSearchOnPause = false; } + if (mSlideOut.hasStarted() && !mSlideOut.hasEnded()) { + commitDialpadFragmentHide(); + } super.onPause(); } @@ -493,6 +502,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O outState.putBoolean(KEY_FIRST_LAUNCH, mFirstLaunch); outState.putBoolean(KEY_IS_DIALPAD_SHOWN, mIsDialpadShown); mActionBarController.saveInstanceState(outState); + mStateSaved = true; } @Override @@ -608,7 +618,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O * @see #onDialpadShown */ private void showDialpadFragment(boolean animate) { - if (mIsDialpadShown) { + if (mIsDialpadShown || mStateSaved) { return; } mIsDialpadShown = true; @@ -684,10 +694,11 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O * Finishes hiding the dialpad fragment after any animations are completed. */ private void commitDialpadFragmentHide() { - final FragmentTransaction ft = getFragmentManager().beginTransaction(); - ft.hide(mDialpadFragment); - ft.commit(); - + if (!mStateSaved && !mDialpadFragment.isHidden()) { + final FragmentTransaction ft = getFragmentManager().beginTransaction(); + ft.hide(mDialpadFragment); + ft.commit(); + } mFloatingActionButtonController.scaleIn(AnimUtils.NO_DELAY); } @@ -840,7 +851,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O * Shows the search fragment */ private void enterSearchUi(boolean smartDialSearch, String query) { - if (getFragmentManager().isDestroyed()) { + if (mStateSaved || getFragmentManager().isDestroyed()) { // Weird race condition where fragment is doing work after the activity is destroyed // due to talkback being on (b/10209937). Just return since we can't do any // constructive here. @@ -893,7 +904,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O */ private void exitSearchUi() { // See related bug in enterSearchUI(); - if (getFragmentManager().isDestroyed()) { + if (getFragmentManager().isDestroyed() || mStateSaved) { return; } @@ -916,6 +927,9 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O @Override public void onBackPressed() { + if (mStateSaved) { + return; + } if (mIsDialpadShown) { if (TextUtils.isEmpty(mSearchQuery) || (mSmartDialSearchFragment != null && mSmartDialSearchFragment.isVisible() |