use of org.chromium.chrome.browser.toolbar.ToolbarManager in project AndroidChromium by JackyAndroid.
the class ChromeActivity method initializeToolbar.
/**
* Constructs {@link ToolbarManager} and the handler necessary for controlling the menu on the
* {@link Toolbar}. Extending classes can override this call to avoid creating the toolbar.
*/
protected void initializeToolbar() {
final View controlContainer = findViewById(R.id.control_container);
assert controlContainer != null;
ToolbarControlContainer toolbarContainer = (ToolbarControlContainer) controlContainer;
mAppMenuPropertiesDelegate = createAppMenuPropertiesDelegate();
mAppMenuHandler = sAppMenuHandlerFactory.get(this, mAppMenuPropertiesDelegate, getAppMenuLayoutId());
mToolbarManager = new ToolbarManager(this, toolbarContainer, mAppMenuHandler, mAppMenuPropertiesDelegate, getCompositorViewHolder().getInvalidator());
mAppMenuHandler.addObserver(new AppMenuObserver() {
@Override
public void onMenuVisibilityChanged(boolean isVisible) {
if (isVisible && !isInOverviewMode()) {
// The app menu badge should be removed the first time the menu is opened.
if (mToolbarManager.getToolbar().isShowingAppMenuUpdateBadge()) {
mToolbarManager.getToolbar().removeAppMenuUpdateBadge(true);
mCompositorViewHolder.requestRender();
}
}
if (!isVisible) {
mAppMenuPropertiesDelegate.onMenuDismissed();
MenuItem updateMenuItem = mAppMenuHandler.getAppMenu().getMenu().findItem(R.id.update_menu_id);
if (updateMenuItem != null && updateMenuItem.isVisible()) {
UpdateMenuItemHelper.getInstance().onMenuDismissed();
}
}
}
});
}
Aggregations