From c1eeb12b6e4570520c3571aba9c04be91b4a20d5 Mon Sep 17 00:00:00 2001 From: Michael Kolb Date: Mon, 1 Aug 2011 09:56:26 -0700 Subject: 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 --- src/com/android/browser/Controller.java | 1 + src/com/android/browser/NavTabGallery.java | 2 +- src/com/android/browser/view/Gallery.java | 44 ++++++++++++++---------------- 3 files changed, 23 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java index fc4c35c..457c2e0 100644 --- a/src/com/android/browser/Controller.java +++ b/src/com/android/browser/Controller.java @@ -2301,6 +2301,7 @@ public class Controller public void closeCurrentTab() { if (mTabControl.getTabCount() == 1) { mCrashRecoveryHandler.clearState(); + mTabControl.removeTab(getCurrentTab()); mActivity.finish(); return; } 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 @@ public class NavTabGallery extends Gallery { 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; diff --git a/src/com/android/browser/view/Gallery.java b/src/com/android/browser/view/Gallery.java index 59e710d..78d4bc6 100644 --- a/src/com/android/browser/view/Gallery.java +++ b/src/com/android/browser/view/Gallery.java @@ -254,29 +254,27 @@ public class Gallery extends ViewGroup implements resetList(); mItemCount = mAdapter.getCount(); // checkFocus(); - int position = mItemCount > 0 ? 0 : INVALID_POSITION; - if (mSelectedPosition >= 0) { - position = Math.min(mItemCount - 1, mSelectedPosition); - } - setSelectedPositionInt(position); - if (mItemCount == 0) { - // Nothing selected - checkSelectionChanged(); - } - if (mGapPosition > INVALID_POSITION) { - mGapAnimator = ObjectAnimator.ofInt(this, "gap", mGap, 0); - mGapAnimator.setDuration(250); - mGapAnimator.addListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator a) { - mGapPosition = INVALID_POSITION; - mGap = 0; - mGapAnimator = null; - } - }); - mGapAnimator.start(); - } else { - layout(0, false); + if (mItemCount > 0) { + int position = 0; + if (mSelectedPosition >= 0) { + position = Math.min(mItemCount - 1, mSelectedPosition); + } + setSelectedPositionInt(position); + if (mGapPosition > INVALID_POSITION) { + mGapAnimator = ObjectAnimator.ofInt(this, "gap", mGap, 0); + mGapAnimator.setDuration(250); + mGapAnimator.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator a) { + mGapPosition = INVALID_POSITION; + mGap = 0; + mGapAnimator = null; + } + }); + mGapAnimator.start(); + } else { + layout(0, false); + } } } else { // checkFocus(); -- cgit v1.1