When removing a tab, go back to the correct parent tab.

Fix for http://b/issue?id=2075182 .  We re-set the Adapter so
that it refreshes itself.  Before calling removeTab, we set
the selection to the correct one.  Keep track of that selection
and set it again after re-setting the Adapter.

Change-Id: I2dd07dd9bbf5f2abbbf99e004b5c37560495ec3a
diff --git a/src/com/android/browser/TitleBarSet.java b/src/com/android/browser/TitleBarSet.java
index 4bd3fd8..873f40b 100644
--- a/src/com/android/browser/TitleBarSet.java
+++ b/src/com/android/browser/TitleBarSet.java
@@ -181,10 +181,12 @@
      * Remove the tab at the given position.
      */
     /* package */ void removeTab(int position) {
+        int selection = getSelectedItemPosition();
         mTitleBars.remove(position);
         mCount--;
         // Need to refresh our list
         setAdapter(mTitleAdapter);
+        setCurrentTab(selection);
     }
 
     /**
@@ -206,6 +208,7 @@
      * Change to the tab at the new position.
      */
     /* package */ void setCurrentTab(int position) {
+        if (position < 0 || position >= mCount) return;
         mIgnoreSelectedListener = true;
         setSelection(position);
         mIgnoreSelectedListener = false;