Refactor the way we track selected tab in ViewContactActivity.
Change-Id: I68ca5a7d7ea3897f2d724f465787fb9c45ffc06f
diff --git a/src/com/android/contacts/BaseContactCardActivity.java b/src/com/android/contacts/BaseContactCardActivity.java
index 2aac1a2..bd62b8a 100644
--- a/src/com/android/contacts/BaseContactCardActivity.java
+++ b/src/com/android/contacts/BaseContactCardActivity.java
@@ -74,7 +74,7 @@
protected static final int TAB_ACCOUNT_TYPE_COLUMN_INDEX = 2;
protected static final String SELECTED_RAW_CONTACT_ID_KEY = "selectedRawContact";
- protected long mSelectedRawContactId;
+ protected Long mSelectedRawContactId = null;
private static final int TOKEN_TABS = 0;
@@ -231,31 +231,24 @@
}
protected void selectInitialTab() {
- int selectedTabIndex = -1;
- if (mSelectedRawContactId > 0) {
- selectedTabIndex = getTabIndexForRawContactId(mSelectedRawContactId);
- }
- if (selectedTabIndex >= 0) {
- mTabWidget.setCurrentTab(selectedTabIndex);
- } else {
- selectDefaultTab();
- }
- }
+ int selectedTabIndex = 0;
- /**
- * Makes the default tab selection. This is called after the tabs have been
- * bound for the first time, and whenever a new intent is received. Override
- * this method if you want to customize the default tab behavior.
- */
- protected void selectDefaultTab() {
- // Select the first tab.
- mTabWidget.setCurrentTab(0);
+ if (mSelectedRawContactId != null) {
+ selectedTabIndex = getTabIndexForRawContactId(mSelectedRawContactId);
+ if (selectedTabIndex == -1) {
+ // If there was no matching tab, just select the first;
+ selectedTabIndex = 0;
+ }
+ }
+
+ mTabWidget.setCurrentTab(selectedTabIndex);
+ onTabSelectionChanged(selectedTabIndex, false);
}
@Override
public void onNewIntent(Intent newIntent) {
setIntent(newIntent);
- selectDefaultTab();
+ selectInitialTab();
mUri = newIntent.getData();
}