зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1302936 - Ignore tab clicks when the tab has already been removed. r=sebastian
MozReview-Commit-ID: K0eUnMHI9j1 --HG-- extra : rebase_source : 69ffde7ceb4cddc11116ae63a126c8e023e01195
This commit is contained in:
Родитель
f8100451db
Коммит
dc8471c2f8
|
@ -265,7 +265,7 @@ public class Tabs implements GeckoEventListener {
|
|||
// This avoids a NPE below, but callers need to be careful to
|
||||
// handle this case.
|
||||
if (tab == null || oldTab == tab) {
|
||||
return null;
|
||||
return tab;
|
||||
}
|
||||
|
||||
mSelectedTab = tab;
|
||||
|
|
|
@ -102,13 +102,14 @@ class TabsGridLayout extends GridView
|
|||
setOnItemClickListener(new OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
final TabsLayoutItemView tab = (TabsLayoutItemView) view;
|
||||
final int tabId = tab.getTabId();
|
||||
Tabs.getInstance().selectTab(tabId);
|
||||
final TabsLayoutItemView tabView = (TabsLayoutItemView) view;
|
||||
final int tabId = tabView.getTabId();
|
||||
final Tab tab = Tabs.getInstance().selectTab(tabId);
|
||||
if (tab == null) {
|
||||
return;
|
||||
}
|
||||
autoHidePanel();
|
||||
Tabs.getInstance().notifyListeners(
|
||||
Tabs.getInstance().getTab(tabId), Tabs.TabEvents.OPENED_FROM_TABS_TRAY
|
||||
);
|
||||
Tabs.getInstance().notifyListeners(tab, Tabs.TabEvents.OPENED_FROM_TABS_TRAY);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -577,11 +578,11 @@ class TabsGridLayout extends GridView
|
|||
if (!mSwiping) {
|
||||
final TabsLayoutItemView item = (TabsLayoutItemView) mSwipeView;
|
||||
final int tabId = item.getTabId();
|
||||
Tabs.getInstance().selectTab(tabId);
|
||||
final Tab tab = Tabs.getInstance().selectTab(tabId);
|
||||
if (tab != null) {
|
||||
autoHidePanel();
|
||||
Tabs.getInstance().notifyListeners(
|
||||
Tabs.getInstance().getTab(tabId), Tabs.TabEvents.OPENED_FROM_TABS_TRAY
|
||||
);
|
||||
Tabs.getInstance().notifyListeners(tab, Tabs.TabEvents.OPENED_FROM_TABS_TRAY);
|
||||
}
|
||||
|
||||
mVelocityTracker.recycle();
|
||||
mVelocityTracker = null;
|
||||
|
|
|
@ -132,10 +132,15 @@ public abstract class TabsLayout extends RecyclerView
|
|||
public void onItemClicked(RecyclerView recyclerView, int position, View v) {
|
||||
final TabsLayoutItemView item = (TabsLayoutItemView) v;
|
||||
final int tabId = item.getTabId();
|
||||
final Tabs tabs = Tabs.getInstance();
|
||||
tabs.selectTab(tabId);
|
||||
final Tab tab = Tabs.getInstance().selectTab(tabId);
|
||||
if (tab == null) {
|
||||
// The tab that was clicked no longer exists in the tabs list (which can happen if you
|
||||
// tap on a tab while its remove animation is running), so ignore the click.
|
||||
return;
|
||||
}
|
||||
|
||||
autoHidePanel();
|
||||
tabs.notifyListeners(tabs.getTab(tabId), Tabs.TabEvents.OPENED_FROM_TABS_TRAY);
|
||||
Tabs.getInstance().notifyListeners(tab, Tabs.TabEvents.OPENED_FROM_TABS_TRAY);
|
||||
}
|
||||
|
||||
// Updates the selected position in the list so that it will be scrolled to the right place.
|
||||
|
@ -165,9 +170,14 @@ public abstract class TabsLayout extends RecyclerView
|
|||
private void closeTab(View view) {
|
||||
final TabsLayoutItemView itemView = (TabsLayoutItemView) view;
|
||||
final Tab tab = getTabForView(itemView);
|
||||
if (tab == null) {
|
||||
// We can be null here if this is the second closeTab call resulting from a sufficiently
|
||||
// fast double tap on the close tab button.
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean closingLastTab = tabsAdapter.getItemCount() == 1;
|
||||
Tabs.getInstance().closeTab(tab, true);
|
||||
|
||||
if (closingLastTab) {
|
||||
autoHidePanel();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче