diff options
author | Jay Shrauner <shrauner@google.com> | 2015-09-17 12:00:18 -0700 |
---|---|---|
committer | Jay Shrauner <shrauner@google.com> | 2015-09-17 12:00:18 -0700 |
commit | 119b06565c54f3bbe70555d8c5aba6065e6c9ad2 (patch) | |
tree | 942ad758b728a321cc78a5236d665163df0c7455 | |
parent | 69c3db29a3baf8526197110c7c36f8483e70e563 (diff) |
Fix IllegalStateException in onMenuItemClick
Make sure we're still visible before showing dialogs.
Bug:24153279
Change-Id: I2eccdcd26064d73a59344107f79ee8eac1b47865
-rw-r--r-- | src/com/android/dialer/DialtactsActivity.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java index dbff276e5..3ca04df01 100644 --- a/src/com/android/dialer/DialtactsActivity.java +++ b/src/com/android/dialer/DialtactsActivity.java @@ -158,6 +158,8 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O */ private SmartDialSearchFragment mSmartDialSearchFragment; + private boolean mIsVisible; + /** * Animation that slides in. */ @@ -563,6 +565,25 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O } @Override + protected void onStart() { + super.onStart(); + mIsVisible = true; + } + + @Override + protected void onStop() { + mIsVisible = false; + super.onStop(); + } + + /** + * Returns true when the Activity is currently visible (between onStart and onStop). + */ + /* package */ boolean isVisible() { + return mIsVisible; + } + + @Override protected void onPause() { if (mClearSearchOnPause) { hideDialpadAndSearchUi(); @@ -576,6 +597,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O @Override protected void onSaveInstanceState(Bundle outState) { + mIsVisible = false; super.onSaveInstanceState(outState); outState.putString(KEY_SEARCH_QUERY, mSearchQuery); outState.putBoolean(KEY_IN_REGULAR_SEARCH_UI, mInRegularSearch); @@ -648,6 +670,10 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O @Override public boolean onMenuItemClick(MenuItem item) { + if (!isVisible()) { + return true; + } + switch (item.getItemId()) { case R.id.menu_history: // Use explicit CallLogActivity intent instead of ACTION_VIEW + |