diff options
author | Michael Kolb <kolby@google.com> | 2011-08-09 10:24:41 -0700 |
---|---|---|
committer | Michael Kolb <kolby@google.com> | 2011-08-15 13:31:03 -0700 |
commit | c3af06776be83ba64a0d3549cb72ca6e5e7f03cd (patch) | |
tree | 60d1a15205ac0b46f94528c0da0963a79f6d547e /src/com/android/browser/NavScreen.java | |
parent | 8d5af2d0208aa5b5197f50e12ba11c5565d74dc4 (diff) | |
download | packages_apps_Browser-c3af06776be83ba64a0d3549cb72ca6e5e7f03cd.zip packages_apps_Browser-c3af06776be83ba64a0d3549cb72ca6e5e7f03cd.tar.gz packages_apps_Browser-c3af06776be83ba64a0d3549cb72ca6e5e7f03cd.tar.bz2 |
Tab switcher animation
Bug: 5123884
first step towards animations between browser and tab switcher
Change-Id: I1d959d42d0036f3c4498972fcc8ad434fa7f4437
Diffstat (limited to 'src/com/android/browser/NavScreen.java')
-rw-r--r-- | src/com/android/browser/NavScreen.java | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/src/com/android/browser/NavScreen.java b/src/com/android/browser/NavScreen.java index 22f6257..768f9ba 100644 --- a/src/com/android/browser/NavScreen.java +++ b/src/com/android/browser/NavScreen.java @@ -39,12 +39,17 @@ import android.widget.TextView; import com.android.browser.NavTabGallery.OnRemoveListener; import com.android.browser.TabControl.OnThumbnailUpdatedListener; +import com.android.browser.view.Gallery.OnScrollFinishedListener; import java.util.HashMap; public class NavScreen extends RelativeLayout implements OnClickListener, OnMenuItemClickListener, OnThumbnailUpdatedListener { + + private static final int SCROLL_MIN = 200; + private static final int SCROLL_FACTOR = 20; + UiController mUiController; PhoneUi mUi; Tab mTab; @@ -126,11 +131,11 @@ public class NavScreen extends RelativeLayout TabControl tc = mUiController.getTabControl(); mTabViews = new HashMap<Tab, View>(tc.getTabCount()); mAdapter = new TabAdapter(mContext, tc); - mScroller.setAdapter(mAdapter); mScroller.setOrientation(mOrientation == Configuration.ORIENTATION_LANDSCAPE ? LinearLayout.HORIZONTAL : LinearLayout.VERTICAL); // update state for active tab - mScroller.setSelection(mUiController.getTabControl().getTabPosition(mUi.getActiveTab())); + mScroller.setAdapter(mAdapter, + mUiController.getTabControl().getTabPosition(mUi.getActiveTab())); mScroller.setOnRemoveListener(new OnRemoveListener() { public void onRemovePosition(int pos) { Tab tab = mAdapter.getItem(pos); @@ -185,21 +190,28 @@ public class NavScreen extends RelativeLayout // need to call openTab explicitely with setactive false Tab tab = mUiController.openTab(BrowserSettings.getInstance().getHomePage(), false, false, false); - mAdapter.notifyDataSetChanged(); + int duration = 0; if (tab != null) { - // set tab as the selected in flipper, then hide + mUiController.setBlockEvents(true); + int oldsel = mScroller.getSelectedItemPosition(); final int tix = mUi.mTabControl.getTabPosition(tab); - mScroller.setSelection(tix); - postDelayed(new Runnable() { + duration = SCROLL_MIN + SCROLL_FACTOR * Math.abs(oldsel - tix); + mScroller.handleDataChanged(); + mScroller.smoothScrollToPosition(tix, duration, new OnScrollFinishedListener() { @Override - public void run() { + public void onScrollFinished() { + mUiController.setBlockEvents(false); mUi.hideNavScreen(true); switchToSelected(); } - }, 100); + }); } } + View getSelectedTabView() { + return mScroller.getSelectedTab(); + } + private void switchToSelected() { Tab tab = (Tab) mScroller.getSelectedItem(); if (tab != mUi.getActiveTab()) { @@ -243,7 +255,7 @@ public class NavScreen extends RelativeLayout public View getView(final int position, View convertView, ViewGroup parent) { final NavTabView tabview = new NavTabView(mActivity); final Tab tab = getItem(position); - tabview.setWebView(mUi, tab); + tabview.setWebView(tab); mTabViews.put(tab, tabview.mImage); tabview.setOnClickListener(new OnClickListener() { @Override |