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);
}
}
}
Aggregations