下面列出了android.view.MenuItem.OnMenuItemClickListener#org.chromium.chrome.browser.ntp.ForeignSessionHelper.ForeignSessionTab 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void openAllTabs() {
ForeignSessionTab firstTab = null;
for (ForeignSessionWindow window : mForeignSession.windows) {
for (ForeignSessionTab tab : window.tabs) {
if (firstTab == null) {
firstTab = tab;
} else {
mRecentTabsManager.openForeignSessionTab(
mForeignSession, tab, WindowOpenDisposition.NEW_BACKGROUND_TAB);
}
}
}
// Open the first tab last because calls to openForeignSessionTab after one for
// CURRENT_TAB are ignored.
if (firstTab != null) {
mRecentTabsManager.openForeignSessionTab(
mForeignSession, firstTab, WindowOpenDisposition.CURRENT_TAB);
}
}
private void openAllTabs() {
ForeignSessionTab firstTab = null;
for (ForeignSessionWindow window : mForeignSession.windows) {
for (ForeignSessionTab tab : window.tabs) {
if (firstTab == null) {
firstTab = tab;
} else {
mRecentTabsManager.openForeignSessionTab(
mForeignSession, tab, WindowOpenDisposition.NEW_BACKGROUND_TAB);
}
}
}
// Open the first tab last because calls to openForeignSessionTab after one for
// CURRENT_TAB are ignored.
if (firstTab != null) {
mRecentTabsManager.openForeignSessionTab(
mForeignSession, firstTab, WindowOpenDisposition.CURRENT_TAB);
}
}
private void openAllTabs() {
ForeignSessionTab firstTab = null;
for (ForeignSessionWindow window : mForeignSession.windows) {
for (ForeignSessionTab tab : window.tabs) {
if (firstTab == null) {
firstTab = tab;
} else {
mRecentTabsManager.openForeignSessionTab(
mForeignSession, tab, WindowOpenDisposition.NEW_BACKGROUND_TAB);
}
}
}
// Open the first tab last because calls to openForeignSessionTab after one for
// CURRENT_TAB are ignored.
if (firstTab != null) {
mRecentTabsManager.openForeignSessionTab(
mForeignSession, firstTab, WindowOpenDisposition.CURRENT_TAB);
}
}
@Override
public ForeignSessionTab getChild(int childPosition) {
for (ForeignSessionWindow window : mForeignSession.windows) {
if (childPosition < window.tabs.size()) {
return window.tabs.get(childPosition);
}
childPosition -= window.tabs.size();
}
assert false;
return null;
}
@Override
public void configureChildView(int childPosition, ViewHolder viewHolder) {
ForeignSessionTab sessionTab = getChild(childPosition);
viewHolder.textView.setText(TextUtils.isEmpty(sessionTab.title) ? sessionTab.url
: sessionTab.title);
loadSyncedFavicon(viewHolder, sessionTab.url);
}
@Override
public boolean onChildClick(int childPosition) {
RecordHistogram.recordEnumeratedHistogram("HistoryPage.OtherDevicesMenu",
OtherSessionsActions.LINK_CLICKED, OtherSessionsActions.LIMIT);
ForeignSessionTab foreignSessionTab = getChild(childPosition);
mRecentTabsManager.openForeignSessionTab(mForeignSession, foreignSessionTab,
WindowOpenDisposition.CURRENT_TAB);
return true;
}
@Override
public void onCreateContextMenuForChild(int childPosition, ContextMenu menu,
Activity activity) {
final ForeignSessionTab foreignSessionTab = getChild(childPosition);
OnMenuItemClickListener listener = new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
mRecentTabsManager.openForeignSessionTab(mForeignSession, foreignSessionTab,
WindowOpenDisposition.NEW_BACKGROUND_TAB);
return true;
}
};
menu.add(R.string.contextmenu_open_in_new_tab).setOnMenuItemClickListener(listener);
}
@Override
public ForeignSessionTab getChild(int childPosition) {
for (ForeignSessionWindow window : mForeignSession.windows) {
if (childPosition < window.tabs.size()) {
return window.tabs.get(childPosition);
}
childPosition -= window.tabs.size();
}
assert false;
return null;
}
@Override
public void configureChildView(int childPosition, ViewHolder viewHolder) {
ForeignSessionTab sessionTab = getChild(childPosition);
viewHolder.textView.setText(TextUtils.isEmpty(sessionTab.title) ? sessionTab.url
: sessionTab.title);
loadSyncedFavicon(viewHolder, sessionTab.url);
}
@Override
public boolean onChildClick(int childPosition) {
RecordHistogram.recordEnumeratedHistogram("HistoryPage.OtherDevicesMenu",
OtherSessionsActions.LINK_CLICKED, OtherSessionsActions.LIMIT);
ForeignSessionTab foreignSessionTab = getChild(childPosition);
mRecentTabsManager.openForeignSessionTab(mForeignSession, foreignSessionTab,
WindowOpenDisposition.CURRENT_TAB);
return true;
}
@Override
public void onCreateContextMenuForChild(int childPosition, ContextMenu menu,
Activity activity) {
final ForeignSessionTab foreignSessionTab = getChild(childPosition);
OnMenuItemClickListener listener = new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
mRecentTabsManager.openForeignSessionTab(mForeignSession, foreignSessionTab,
WindowOpenDisposition.NEW_BACKGROUND_TAB);
return true;
}
};
menu.add(R.string.contextmenu_open_in_new_tab).setOnMenuItemClickListener(listener);
}
@Override
public ForeignSessionTab getChild(int childPosition) {
for (ForeignSessionWindow window : mForeignSession.windows) {
if (childPosition < window.tabs.size()) {
return window.tabs.get(childPosition);
}
childPosition -= window.tabs.size();
}
assert false;
return null;
}
@Override
public void configureChildView(int childPosition, ViewHolder viewHolder) {
ForeignSessionTab sessionTab = getChild(childPosition);
viewHolder.textView.setText(TextUtils.isEmpty(sessionTab.title) ? sessionTab.url
: sessionTab.title);
loadSyncedFavicon(viewHolder, sessionTab.url);
}
@Override
public boolean onChildClick(int childPosition) {
RecordHistogram.recordEnumeratedHistogram("HistoryPage.OtherDevicesMenu",
OtherSessionsActions.LINK_CLICKED, OtherSessionsActions.LIMIT);
ForeignSessionTab foreignSessionTab = getChild(childPosition);
mRecentTabsManager.openForeignSessionTab(mForeignSession, foreignSessionTab,
WindowOpenDisposition.CURRENT_TAB);
return true;
}
@Override
public void onCreateContextMenuForChild(int childPosition, ContextMenu menu,
Activity activity) {
final ForeignSessionTab foreignSessionTab = getChild(childPosition);
OnMenuItemClickListener listener = new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
mRecentTabsManager.openForeignSessionTab(mForeignSession, foreignSessionTab,
WindowOpenDisposition.NEW_BACKGROUND_TAB);
return true;
}
};
menu.add(R.string.contextmenu_open_in_new_tab).setOnMenuItemClickListener(listener);
}
/**
* Opens a new tab navigating to ForeignSessionTab.
*
* @param session The foreign session that the tab belongs to.
* @param tab The tab to open.
* @param windowDisposition The WindowOpenDisposition flag.
*/
public void openForeignSessionTab(ForeignSession session, ForeignSessionTab tab,
int windowDisposition) {
if (mIsDestroyed) return;
NewTabPageUma.recordAction(NewTabPageUma.ACTION_OPENED_FOREIGN_SESSION);
mForeignSessionHelper.openForeignSessionTab(mTab, session, tab, windowDisposition);
}
/**
* Opens a new tab navigating to ForeignSessionTab.
*
* @param session The foreign session that the tab belongs to.
* @param tab The tab to open.
* @param windowDisposition The WindowOpenDisposition flag.
*/
public void openForeignSessionTab(ForeignSession session, ForeignSessionTab tab,
int windowDisposition) {
if (mIsDestroyed) return;
NewTabPageUma.recordAction(NewTabPageUma.ACTION_OPENED_FOREIGN_SESSION);
mForeignSessionHelper.openForeignSessionTab(mTab, session, tab, windowDisposition);
}
/**
* Opens a new tab navigating to ForeignSessionTab.
*
* @param session The foreign session that the tab belongs to.
* @param tab The tab to open.
* @param windowDisposition The WindowOpenDisposition flag.
*/
public void openForeignSessionTab(ForeignSession session, ForeignSessionTab tab,
int windowDisposition) {
if (mIsDestroyed) return;
RecordUserAction.record("MobileRecentTabManagerTabFromOtherDeviceOpened");
mForeignSessionHelper.openForeignSessionTab(mTab, session, tab, windowDisposition);
}