diff options
author | John Reck <jreck@google.com> | 2011-03-14 12:51:04 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-03-14 12:51:04 -0700 |
commit | 22d96edeb1d77a76399febfd56453d1c59cf0280 (patch) | |
tree | b887834936731ee8f76c8487b28c1d0660810ad3 /src/com/android/browser/XLargeUi.java | |
parent | bc9b5f0f284ad59a28e3c578630e3c9eb6dba99e (diff) | |
parent | 6e8d2e9d32bc03ecd5ee2efffb0df260d10533d4 (diff) | |
download | packages_apps_Browser-22d96edeb1d77a76399febfd56453d1c59cf0280.zip packages_apps_Browser-22d96edeb1d77a76399febfd56453d1c59cf0280.tar.gz packages_apps_Browser-22d96edeb1d77a76399febfd56453d1c59cf0280.tar.bz2 |
Merge "Fix tab switching corner cases" into honeycomb-mr1
Diffstat (limited to 'src/com/android/browser/XLargeUi.java')
-rw-r--r-- | src/com/android/browser/XLargeUi.java | 59 |
1 files changed, 39 insertions, 20 deletions
diff --git a/src/com/android/browser/XLargeUi.java b/src/com/android/browser/XLargeUi.java index 7bb9ff0..02533b0 100644 --- a/src/com/android/browser/XLargeUi.java +++ b/src/com/android/browser/XLargeUi.java @@ -51,6 +51,7 @@ public class XLargeUi extends BaseUi implements ScrollListener { private TitleBarXLarge mTitleBar; private Animator mTitleBarAnimator; + private boolean mSkipTitleBarAnimations; private boolean mUseQuickControls; private PieControl mPieControl; @@ -224,6 +225,8 @@ public class XLargeUi extends BaseUi implements ScrollListener { @Override public void setActiveTab(final Tab tab) { + cancelTitleBarAnimation(true); + mSkipTitleBarAnimations = true; if (mUseQuickControls) { if (mActiveTab != null) { captureTab(mActiveTab); @@ -231,6 +234,7 @@ public class XLargeUi extends BaseUi implements ScrollListener { } super.setActiveTab(tab, true); setActiveTab(tab, true); + mSkipTitleBarAnimations = false; } @Override @@ -281,8 +285,11 @@ public class XLargeUi extends BaseUi implements ScrollListener { @Override public void removeTab(Tab tab) { + cancelTitleBarAnimation(true); + mSkipTitleBarAnimations = true; super.removeTab(tab); mTabBar.onRemoveTab(tab); + mSkipTitleBarAnimations = false; } protected void onRemoveTabCompleted(Tab tab) { @@ -321,18 +328,18 @@ public class XLargeUi extends BaseUi implements ScrollListener { if (mUseQuickControls) { mContentView.addView(mTitleBar); } else { - if (mTitleBarAnimator != null) { - mTitleBarAnimator.cancel(); - } - int visibleHeight = getVisibleTitleHeight(); - float startPos = (-mTitleBar.getEmbeddedHeight() + visibleHeight); - if (mTitleBar.getTranslationY() != 0) { - startPos = Math.max(startPos, mTitleBar.getTranslationY()); + if (!mSkipTitleBarAnimations) { + cancelTitleBarAnimation(false); + int visibleHeight = getVisibleTitleHeight(); + float startPos = (-mTitleBar.getEmbeddedHeight() + visibleHeight); + if (mTitleBar.getTranslationY() != 0) { + startPos = Math.max(startPos, mTitleBar.getTranslationY()); + } + mTitleBarAnimator = ObjectAnimator.ofFloat(mTitleBar, + "translationY", + startPos, 0); + mTitleBarAnimator.start(); } - mTitleBarAnimator = ObjectAnimator.ofFloat(mTitleBar, - "translationY", - startPos, 0); - mTitleBarAnimator.start(); setTitleGravity(Gravity.TOP); } super.showTitleBar(); @@ -347,20 +354,32 @@ public class XLargeUi extends BaseUi implements ScrollListener { if (mUseQuickControls) { mContentView.removeView(mTitleBar); } else { - if (mTitleBarAnimator != null) { - mTitleBarAnimator.cancel(); + if (!mSkipTitleBarAnimations) { + cancelTitleBarAnimation(false); + int visibleHeight = getVisibleTitleHeight(); + mTitleBarAnimator = ObjectAnimator.ofFloat(mTitleBar, + "translationY", mTitleBar.getTranslationY(), + (-mTitleBar.getEmbeddedHeight() + visibleHeight)); + mTitleBarAnimator.addListener(mHideTileBarAnimatorListener); + mTitleBarAnimator.start(); + } else { + setTitleGravity(Gravity.NO_GRAVITY); } - int visibleHeight = getVisibleTitleHeight(); - mTitleBarAnimator = ObjectAnimator.ofFloat(mTitleBar, - "translationY", mTitleBar.getTranslationY(), - (-mTitleBar.getEmbeddedHeight() + visibleHeight)); - mTitleBarAnimator.addListener(mHideTileBarAnimatorListener); - mTitleBarAnimator.start(); } super.hideTitleBar(); } } + private void cancelTitleBarAnimation(boolean reset) { + if (mTitleBarAnimator != null) { + mTitleBarAnimator.cancel(); + mTitleBarAnimator = null; + } + if (reset) { + mTitleBar.setTranslationY(0); + } + } + private int getVisibleTitleHeight() { WebView webview = mActiveTab != null ? mActiveTab.getWebView() : null; return webview != null ? webview.getVisibleTitleHeight() : 0; @@ -382,8 +401,8 @@ public class XLargeUi extends BaseUi implements ScrollListener { public void onAnimationEnd(Animator animation) { if (!mWasCanceled) { mTitleBar.setTranslationY(0); - setTitleGravity(Gravity.NO_GRAVITY); } + setTitleGravity(Gravity.NO_GRAVITY); } @Override |