Bug 699706: Scroll to the selected tab in Tabs tray [r=mfinkle]

This commit is contained in:
Sriram Ramasubramanian 2011-11-08 13:17:15 -08:00
parent 81021f9877
commit 8f638b7d93

View File

@ -104,6 +104,17 @@ public class TabsTray extends Activity implements GeckoApp.OnTabsChangedListener
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)
mList.smoothScrollToPosition(position);
}
}
public void onTabsChanged() {
@ -146,6 +157,13 @@ public class TabsTray extends Activity implements GeckoApp.OnTabsChangedListener
return position;
}
public int getPositionForTab(Tab tab) {
if (mTabs == null || tab == null)
return -1;
return mTabs.indexOf(tab);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {