Make cal start in the correct view

Calendar was always starting in DayView due to tabs change. This
reorders the startup so we can override the tab auto setting us
to a view.

Change-Id: I071ac7f6c125c96e9e3334d7ae6e4957f20d44dd
diff --git a/src/com/android/calendar/AllInOneActivity.java b/src/com/android/calendar/AllInOneActivity.java
index c3ea04f..76d6967 100644
--- a/src/com/android/calendar/AllInOneActivity.java
+++ b/src/com/android/calendar/AllInOneActivity.java
@@ -28,11 +28,8 @@
 import com.android.calendar.month.MonthByWeekFragment;
 import com.android.calendar.selectcalendars.SelectCalendarsFragment;
 
-import dalvik.system.VMRuntime;
-
 import android.app.ActionBar;
 import android.app.ActionBar.Tab;
-import android.app.ActionBar.TabListener;
 import android.app.Activity;
 import android.app.Fragment;
 import android.app.FragmentTransaction;
@@ -110,10 +107,6 @@
     protected void onCreate(Bundle icicle) {
         super.onCreate(icicle);
 
-        // Eliminate extra GCs during startup by setting the initial heap size to 4MB.
-        // TODO: We should restore the old heap size once the activity reaches the idle state
-        VMRuntime.getRuntime().setMinimumHeapSize(INITIAL_HEAP_SIZE);
-
         // This needs to be created before setContentView
         mController = CalendarController.getInstance(this);
         // Get time from intent or icicle
@@ -143,12 +136,18 @@
         mIsMultipane = (getResources().getConfiguration().screenLayout
                 & Configuration.SCREENLAYOUT_SIZE_XLARGE) != 0;
 
+        // setContentView must be called before configureActionBar
+        setContentView(R.layout.all_in_one);
+        // configureActionBar auto-selects the first tab you add, so we need to
+        // call it before we set up our own fragments to make sure it doesn't
+        // overwrite us
+        configureActionBar();
+
         // Must be the first to register because this activity can modify the
         // list of event handlers in it's handle method. This affects who the
         // rest of the handlers the controller dispatches to are.
         mController.registerEventHandler(HANDLER_KEY, this);
 
-        setContentView(R.layout.all_in_one);
         mHomeTime = (TextView) findViewById(R.id.home_time);
 
         initFragments(timeMillis, viewType, icicle);
@@ -159,7 +158,9 @@
         prefs.registerOnSharedPreferenceChangeListener(this);
 
         mContentResolver = getContentResolver();
+    }
 
+    private void configureActionBar() {
         mActionBar = getActionBar();
         mActionBar.setTabNavigationMode();
         if (mActionBar == null) {
@@ -487,7 +488,9 @@
                 // save if it needs to
                 EventHandler editHandler = (EventHandler) getFragmentManager().findFragmentById(
                         R.id.main_pane);
-                editHandler.handleEvent(event);
+                if (editHandler != null) {
+                    editHandler.handleEvent(event);
+                }
             }
 
             // Set title bar