Search in sources :

Example 1 with EmptyTabModelObserver

use of org.chromium.chrome.browser.tabmodel.EmptyTabModelObserver in project AndroidChromium by JackyAndroid.

the class IncognitoToggleButtonTablet method setTabModelSelector.

/**
 * Sets the {@link TabModelSelector} that will be queried for information about the state of
 * the system.
 * @param selector A {@link TabModelSelector} that represents the state of the system.
 */
public void setTabModelSelector(TabModelSelector selector) {
    mTabModelSelector = selector;
    if (selector != null) {
        updateButtonResource();
        updateButtonVisibility();
        mTabModelSelectorObserver = new EmptyTabModelSelectorObserver() {

            @Override
            public void onTabModelSelected(TabModel newModel, TabModel oldModel) {
                updateButtonResource();
            }
        };
        mTabModelSelector.addObserver(mTabModelSelectorObserver);
        mTabModelObserver = new EmptyTabModelObserver() {

            @Override
            public void didAddTab(Tab tab, TabLaunchType type) {
                updateButtonVisibility();
            }

            @Override
            public void willCloseTab(Tab tab, boolean animate) {
                updateButtonVisibility();
            }

            @Override
            public void tabRemoved(Tab tab) {
                updateButtonVisibility();
            }
        };
        for (TabModel model : mTabModelSelector.getModels()) {
            model.addObserver(mTabModelObserver);
        }
    }
}
Also used : EmptyTabModelSelectorObserver(org.chromium.chrome.browser.tabmodel.EmptyTabModelSelectorObserver) Tab(org.chromium.chrome.browser.tab.Tab) TabLaunchType(org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType) TabModel(org.chromium.chrome.browser.tabmodel.TabModel) EmptyTabModelObserver(org.chromium.chrome.browser.tabmodel.EmptyTabModelObserver)

Aggregations

Tab (org.chromium.chrome.browser.tab.Tab)1 EmptyTabModelObserver (org.chromium.chrome.browser.tabmodel.EmptyTabModelObserver)1 EmptyTabModelSelectorObserver (org.chromium.chrome.browser.tabmodel.EmptyTabModelSelectorObserver)1 TabModel (org.chromium.chrome.browser.tabmodel.TabModel)1 TabLaunchType (org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType)1