From 6a15ad7de372e6c21a00dd40a6ae089260cfaedf Mon Sep 17 00:00:00 2001 From: Yorke Lee Date: Wed, 26 Mar 2014 16:13:10 -0700 Subject: DO NOT MERGE Fix crash when recreating activity and receiving dial intent * Initialize all member variable button references at onCreate to avoid potential NPEs * Make sure we call mDialpadFragment.buildOptionsMenu only when it is guaranteed to have been attached. Bug: 13653973 Change-Id: I407072503cebaf77ec9ef86d8a7ab23302eed6d6 --- src/com/android/dialer/DialtactsActivity.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java index b78a7bc62..2e087634d 100644 --- a/src/com/android/dialer/DialtactsActivity.java +++ b/src/com/android/dialer/DialtactsActivity.java @@ -336,7 +336,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O } }); - + setupFakeActionBarItems(); prepareSearchView(); if (UI.FILTER_CONTACTS_ACTION.equals(intent.getAction()) @@ -353,7 +353,6 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O @Override protected void onResume() { super.onResume(); - setupFakeActionBarItems(); if (mFirstLaunch) { displayFragment(getIntent()); } else if (!phoneIsInUse() && mInCallDialpadUp) { @@ -552,6 +551,11 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O ft.commit(); mDialButton.setVisibility(shouldShowOnscreenDialButton() ? View.VISIBLE : View.GONE); mDialpadButton.setVisibility(View.GONE); + + if (mDialpadOverflowMenu == null) { + mDialpadOverflowMenu = mDialpadFragment.buildOptionsMenu(mMenuButton); + } + mMenuButton.setOnTouchListener(mDialpadOverflowMenu.getDragToOpenListener()); } @@ -680,17 +684,12 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O if (mOverflowMenu == null) { mOverflowMenu = buildOptionsMenu(mMenuButton); } - if (mDialpadOverflowMenu == null) { - mDialpadOverflowMenu = mDialpadFragment.buildOptionsMenu(mMenuButton); - } - // Initial state is with dialpad fragment not shown mMenuButton.setOnTouchListener(mOverflowMenu.getDragToOpenListener()); } mFakeActionBar = findViewById(R.id.fake_action_bar); mCallHistoryButton = findViewById(R.id.call_history_button); - // mCallHistoryButton.setMinimumWidth(fakeMenuItemWidth); mCallHistoryButton.setOnClickListener(this); mDialButton = findViewById(R.id.dial_button); @@ -698,7 +697,6 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O mDialButton.setOnLongClickListener(this); mDialpadButton = findViewById(R.id.dialpad_button); - // DialpadButton.setMinimumWidth(fakeMenuItemWidth); mDialpadButton.setOnClickListener(this); } -- cgit v1.2.3