зеркало из https://github.com/mozilla/pjs.git
Bug 697098: Do not scroll tab list on onTabsChanged() [r=mfinkle]
This commit is contained in:
Родитель
a69218dd80
Коммит
239fc6d6b9
|
@ -122,7 +122,7 @@ abstract public class GeckoApp
|
|||
private Vector<View> mPluginViews = new Vector<View>();
|
||||
|
||||
public interface OnTabsChangedListener {
|
||||
public void onTabsChanged();
|
||||
public void onTabsChanged(Tab tab);
|
||||
}
|
||||
|
||||
private static ArrayList<OnTabsChangedListener> mTabsChangedListeners;
|
||||
|
@ -574,7 +574,7 @@ abstract public class GeckoApp
|
|||
if (Tabs.getInstance().isSelectedTab(tab))
|
||||
mBrowserToolbar.setFavicon(tab.getFavicon());
|
||||
|
||||
onTabsChanged();
|
||||
onTabsChanged(tab);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -657,13 +657,13 @@ abstract public class GeckoApp
|
|||
mTabsChangedListeners.remove(listener);
|
||||
}
|
||||
|
||||
public void onTabsChanged() {
|
||||
public void onTabsChanged(Tab tab) {
|
||||
if (mTabsChangedListeners == null)
|
||||
return;
|
||||
|
||||
Iterator items = mTabsChangedListeners.iterator();
|
||||
while (items.hasNext()) {
|
||||
((OnTabsChangedListener) items.next()).onTabsChanged();
|
||||
((OnTabsChangedListener) items.next()).onTabsChanged(tab);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -870,7 +870,7 @@ abstract public class GeckoApp
|
|||
mMainHandler.post(new Runnable() {
|
||||
public void run() {
|
||||
if (selected && Tabs.getInstance().isSelectedTab(tab)) {
|
||||
onTabsChanged();
|
||||
onTabsChanged(tab);
|
||||
mDoorHangerPopup.updatePopup();
|
||||
}
|
||||
mBrowserToolbar.updateTabs(Tabs.getInstance().getCount());
|
||||
|
@ -885,7 +885,7 @@ abstract public class GeckoApp
|
|||
|
||||
mMainHandler.post(new Runnable() {
|
||||
public void run() {
|
||||
onTabsChanged();
|
||||
onTabsChanged(tab);
|
||||
mBrowserToolbar.updateTabs(Tabs.getInstance().getCount());
|
||||
mDoorHangerPopup.updatePopup();
|
||||
}
|
||||
|
@ -924,7 +924,7 @@ abstract public class GeckoApp
|
|||
mBrowserToolbar.setSecurityMode(tab.getSecurityMode());
|
||||
mBrowserToolbar.setProgressVisibility(true);
|
||||
}
|
||||
onTabsChanged();
|
||||
onTabsChanged(tab);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -940,7 +940,7 @@ abstract public class GeckoApp
|
|||
public void run() {
|
||||
if (Tabs.getInstance().isSelectedTab(tab))
|
||||
mBrowserToolbar.setProgressVisibility(false);
|
||||
onTabsChanged();
|
||||
onTabsChanged(tab);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -970,7 +970,7 @@ abstract public class GeckoApp
|
|||
public void run() {
|
||||
if (Tabs.getInstance().isSelectedTab(tab))
|
||||
mBrowserToolbar.setTitle(tab.getDisplayTitle());
|
||||
onTabsChanged();
|
||||
onTabsChanged(tab);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -986,7 +986,7 @@ abstract public class GeckoApp
|
|||
public void run() {
|
||||
if (Tabs.getInstance().isSelectedTab(tab))
|
||||
mBrowserToolbar.setTitle(tab.getDisplayTitle());
|
||||
onTabsChanged();
|
||||
onTabsChanged(tab);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ public class TabsTray extends Activity implements GeckoApp.OnTabsChangedListener
|
|||
});
|
||||
|
||||
GeckoApp.registerOnTabsChangedListener(this);
|
||||
onTabsChanged();
|
||||
onTabsChanged(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -117,12 +117,27 @@ public class TabsTray extends Activity implements GeckoApp.OnTabsChangedListener
|
|||
}
|
||||
}
|
||||
|
||||
public void onTabsChanged() {
|
||||
public void onTabsChanged(Tab tab) {
|
||||
if (Tabs.getInstance().getCount() == 1)
|
||||
finishActivity();
|
||||
|
||||
mTabsAdapter = new TabsAdapter(this, Tabs.getInstance().getTabsInOrder());
|
||||
mList.setAdapter(mTabsAdapter);
|
||||
if (mTabsAdapter == null) {
|
||||
mTabsAdapter = new TabsAdapter(this, Tabs.getInstance().getTabsInOrder());
|
||||
mList.setAdapter(mTabsAdapter);
|
||||
return;
|
||||
}
|
||||
|
||||
int position = mTabsAdapter.getPositionForTab(tab);
|
||||
if (position == -1)
|
||||
return;
|
||||
|
||||
if (Tabs.getInstance().getIndexOf(tab) == -1) {
|
||||
mTabsAdapter = new TabsAdapter(this, Tabs.getInstance().getTabsInOrder());
|
||||
mList.setAdapter(mTabsAdapter);
|
||||
} else {
|
||||
View view = mList.getChildAt(position - mList.getFirstVisiblePosition());
|
||||
mTabsAdapter.assignValues(view, tab);
|
||||
}
|
||||
}
|
||||
|
||||
void finishActivity() {
|
||||
|
@ -164,6 +179,25 @@ public class TabsTray extends Activity implements GeckoApp.OnTabsChangedListener
|
|||
return mTabs.indexOf(tab);
|
||||
}
|
||||
|
||||
public void assignValues(View view, Tab tab) {
|
||||
if (view == null || tab == null)
|
||||
return;
|
||||
|
||||
ImageView favicon = (ImageView) view.findViewById(R.id.favicon);
|
||||
|
||||
Drawable faviconImage = tab.getFavicon();
|
||||
if (faviconImage != null)
|
||||
favicon.setImageDrawable(faviconImage);
|
||||
else
|
||||
favicon.setImageResource(R.drawable.favicon);
|
||||
|
||||
TextView title = (TextView) view.findViewById(R.id.title);
|
||||
title.setText(tab.getDisplayTitle());
|
||||
|
||||
if (Tabs.getInstance().isSelectedTab(tab))
|
||||
title.setTypeface(title.getTypeface(), Typeface.BOLD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
|
||||
|
@ -180,19 +214,7 @@ public class TabsTray extends Activity implements GeckoApp.OnTabsChangedListener
|
|||
}
|
||||
});
|
||||
|
||||
ImageView favicon = (ImageView) convertView.findViewById(R.id.favicon);
|
||||
|
||||
Drawable faviconImage = tab.getFavicon();
|
||||
if (faviconImage != null)
|
||||
favicon.setImageDrawable(faviconImage);
|
||||
else
|
||||
favicon.setImageResource(R.drawable.favicon);
|
||||
|
||||
TextView title = (TextView) convertView.findViewById(R.id.title);
|
||||
title.setText(tab.getDisplayTitle());
|
||||
|
||||
if (Tabs.getInstance().isSelectedTab(tab))
|
||||
title.setTypeface(title.getTypeface(), Typeface.BOLD);
|
||||
assignValues(convertView, tab);
|
||||
|
||||
ImageButton close = (ImageButton) convertView.findViewById(R.id.close);
|
||||
if (mTabs.size() > 1) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче