fix last tab close bug

    Bug: 5098467
    The controller did not update the tab list correctly
    and called activity finish instead. The adapter
    got updated and showed the last tab still
    Now the controller removes the last tab before
    calling finish, so the visible update to the tab
    list is correct.

Change-Id: Idf29dff7d60181c63f6b3ebcbc8a1562f027b2c1
diff --git a/src/com/android/browser/NavTabGallery.java b/src/com/android/browser/NavTabGallery.java
index 8247a5d..8aa2782 100644
--- a/src/com/android/browser/NavTabGallery.java
+++ b/src/com/android/browser/NavTabGallery.java
@@ -151,7 +151,7 @@
                         setGapPosition(position, mHorizontal ? v.getWidth() : v.getHeight());
                     }
                     mRemoveListener.onRemovePosition(position);
-                    if (!needsGap && position > 0) {
+                    if (!needsGap && (position > 0) && (mAdapter.getCount() > 0)) {
                         scrollToChild(position - 1);
                     }
                     mAnimator = null;