Bug 726875: Scroll the list after it populates in TabsTray. [r=mfinkle]
authorSriram Ramasubramanian <sriram@mozilla.com>
Tue, 14 Feb 2012 16:27:51 -0800
changeset 86865 a4ddd189b1123b2e70f8c9f3e9541c0391f20c92
parent 86864 0f5f2636d588702696767ecb71b6028c2555ada7
child 86866 08c263fdeecfa45c3a56aea6c5028916e6e7944c
push id22058
push usermak77@bonardo.net
push dateWed, 15 Feb 2012 16:38:33 +0000
treeherdermozilla-central@46e22ce549b0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs726875
milestone13.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 726875: Scroll the list after it populates in TabsTray. [r=mfinkle]
mobile/android/base/TabsTray.java
--- a/mobile/android/base/TabsTray.java
+++ b/mobile/android/base/TabsTray.java
@@ -112,41 +112,31 @@ public class TabsTray extends Activity i
         onTabsChanged(null);
     }
 
     @Override
     public void onDestroy() {
         super.onDestroy();
         GeckoApp.unregisterOnTabsChangedListener(this);
     }
-
-    @Override
-    public void onWindowFocusChanged(boolean hasFocus) {
-        // This function is called after the initial list is populated
-        // Scrolling to the selected tab can happen here
-        if (hasFocus) {
-            int position = mTabsAdapter.getPositionForTab(Tabs.getInstance().getSelectedTab());
-            if (position == -1)
-                return;
-            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) {
-                mList.smoothScrollToPosition(position);
-            } else {
-                /* To Do: Find a way to scroll with Eclair's APIs */
-            }
-        }
-    } 
    
     public void onTabsChanged(Tab tab) {
         if (Tabs.getInstance().getCount() == 1)
             finishActivity();
 
         if (mTabsAdapter == null) {
             mTabsAdapter = new TabsAdapter(this, Tabs.getInstance().getTabsInOrder());
             mList.setAdapter(mTabsAdapter);
             mListContainer.requestLayout();
+
+            int selected = mTabsAdapter.getPositionForTab(Tabs.getInstance().getSelectedTab());
+            if (selected == -1)
+                return;
+
+            mList.setSelection(selected);
             return;
         }
         
         int position = mTabsAdapter.getPositionForTab(tab);
         if (position == -1)
             return;
 
         if (Tabs.getInstance().getIndexOf(tab) == -1) {