diff options
author | Jay Shrauner <shrauner@google.com> | 2015-09-16 15:49:56 -0700 |
---|---|---|
committer | Jay Shrauner <shrauner@google.com> | 2015-09-16 16:38:27 -0700 |
commit | f499a09cdbbd8efb4d97b9981fe1a0141e8a930d (patch) | |
tree | 153350b81e8532254ab028cd4318aa470a81aba9 /src/com/android/dialer/calllog/CallLogActivity.java | |
parent | 091214b943991595fee536ab3eddd973f560fbe3 (diff) |
Fix IllegalStateException in onOptionsItemSelected
Make sure we're still visible before showing dialogs.
Bug:24138858
Change-Id: I3a2cc7dba6144e055ae074177ba5c89258f69b1b
Diffstat (limited to 'src/com/android/dialer/calllog/CallLogActivity.java')
-rw-r--r-- | src/com/android/dialer/calllog/CallLogActivity.java | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/com/android/dialer/calllog/CallLogActivity.java b/src/com/android/dialer/calllog/CallLogActivity.java index ff0726df7..ad795f9bd 100644 --- a/src/com/android/dialer/calllog/CallLogActivity.java +++ b/src/com/android/dialer/calllog/CallLogActivity.java @@ -48,6 +48,8 @@ public class CallLogActivity extends AppCompatActivity implements ViewPager.OnPa private CallLogFragment mAllCallsFragment; private CallLogFragment mMissedCallsFragment; + private boolean mIsVisible; + private String[] mTabTitles; private static final int TAB_INDEX_ALL = 0; @@ -161,6 +163,31 @@ public class CallLogActivity extends AppCompatActivity implements ViewPager.OnPa } @Override + protected void onStart() { + super.onStart(); + mIsVisible = false; + } + + @Override + protected void onStop() { + mIsVisible = false; + super.onStop(); + } + + @Override + protected void onSaveInstanceState(Bundle outState) { + mIsVisible = false; + super.onSaveInstanceState(outState); + } + + /** + * Returns true when the Activity is currently visible (between onStart and onStop). + */ + /* package */ boolean isVisible() { + return mIsVisible; + } + + @Override public boolean onCreateOptionsMenu(Menu menu) { final MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.call_log_options, menu); @@ -180,6 +207,10 @@ public class CallLogActivity extends AppCompatActivity implements ViewPager.OnPa @Override public boolean onOptionsItemSelected(MenuItem item) { + if (!isVisible()) { + return true; + } + switch (item.getItemId()) { case android.R.id.home: final Intent intent = new Intent(this, DialtactsActivity.class); |