summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Shrauner <shrauner@google.com>2015-09-18 22:38:54 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-09-18 22:38:54 +0000
commitaa4ca7604fe2ea1d60388fbb0265e87864decbf4 (patch)
tree9c120d3a34b858e9b1242fa4b4fd92b6fdddf04c
parent02e7dfb52f114b243c38e59bb63c2978e3c1c352 (diff)
parent8239d56d7976ff492b326c449e35805bace40a01 (diff)
am 8239d56d: Merge "Fix IllegalStateException in onOptionsItemSelected" into ub-contactsdialer-a-dev
* commit '8239d56d7976ff492b326c449e35805bace40a01': Fix IllegalStateException in onOptionsItemSelected
-rw-r--r--src/com/android/dialer/calllog/CallLogActivity.java31
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);