Java Code Examples for org.chromium.chrome.browser.tabmodel.TabModel#removeObserver()

The following examples show how to use org.chromium.chrome.browser.tabmodel.TabModel#removeObserver() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChromeTabbedActivity.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public void onDestroyInternal() {
    if (mLayoutManager != null) mLayoutManager.removeOverviewModeObserver(this);

    if (mTabModelSelectorTabObserver != null) {
        mTabModelSelectorTabObserver.destroy();
        mTabModelSelectorTabObserver = null;
    }

    if (mTabModelObserver != null) {
        for (TabModel model : mTabModelSelectorImpl.getModels()) {
            model.removeObserver(mTabModelObserver);
        }
    }

    if (mUndoBarPopupController != null) {
        mUndoBarPopupController.destroy();
        mUndoBarPopupController = null;
    }

    super.onDestroyInternal();
}
 
Example 2
Source File: ContextReporter.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Stops reporting context. Called when the app goes to the background.
 */
public void disable() {
    reportUsageEndedIfNecessary();

    if (mSelectorTabObserver != null) {
        mSelectorTabObserver.destroy();
        mSelectorTabObserver = null;
    }
    if (mModelObserver != null) {
        for (TabModel model : mActivity.getTabModelSelector().getModels()) {
            model.removeObserver(mModelObserver);
        }
        mModelObserver = null;
    }
    if (mContextualSearchObserver != null && mActivity.getContextualSearchManager() != null) {
        mActivity.getContextualSearchManager().removeObserver(mContextualSearchObserver);
        mContextualSearchObserver = null;
    }
}
 
Example 3
Source File: LayoutManagerChrome.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public void destroy() {
    super.destroy();
    if (mTabModelSelectorObserver != null) {
        getTabModelSelector().removeObserver(mTabModelSelectorObserver);
    }
    if (mTabModelObserver != null) {
        for (TabModel model : getTabModelSelector().getModels()) {
            model.removeObserver(mTabModelObserver);
        }
    }
    if (mTabSelectorTabObserver != null) mTabSelectorTabObserver.destroy();
    mOverviewModeObservers.clear();

    if (mOverviewLayout != null) {
        mOverviewLayout.destroy();
        mOverviewLayout = null;
    }
    mOverviewListLayout.destroy();
    mToolbarSwipeLayout.destroy();
}
 
Example 4
Source File: LayoutManagerChrome.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
public void destroy() {
    super.destroy();
    if (mTabModelSelectorObserver != null) {
        getTabModelSelector().removeObserver(mTabModelSelectorObserver);
    }
    if (mTabModelObserver != null) {
        for (TabModel model : getTabModelSelector().getModels()) {
            model.removeObserver(mTabModelObserver);
        }
    }
    if (mTabSelectorTabObserver != null) mTabSelectorTabObserver.destroy();
    mOverviewModeObservers.clear();

    if (mOverviewLayout != null) {
        mOverviewLayout.destroy();
        mOverviewLayout = null;
    }
    mOverviewListLayout.destroy();
    mToolbarSwipeLayout.destroy();
}
 
Example 5
Source File: IncognitoToggleButtonTablet.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
protected void onDetachedFromWindow() {
    if (mTabModelSelector != null) {
        mTabModelSelector.removeObserver(mTabModelSelectorObserver);
        for (TabModel model : mTabModelSelector.getModels()) {
            model.removeObserver(mTabModelObserver);
        }
    }
    super.onDetachedFromWindow();
}
 
Example 6
Source File: FindToolbar.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Call this just before closing the find toolbar.
 * @param clearSelection Whether the selection on the page should be cleared.
 */
public void deactivate(boolean clearSelection) {
    if (!mActive) return;

    if (mObserver != null) mObserver.onFindToolbarHidden();

    setResultsBarVisibility(false);

    mTabModelSelector.removeObserver(mTabModelSelectorObserver);
    for (TabModel model : mTabModelSelector.getModels()) {
        model.removeObserver(mTabModelObserver);
    }

    TabWebContentsDelegateAndroid delegate = mCurrentTab.getTabWebContentsDelegateAndroid();
    if (delegate != null) {
        delegate.setFindResultListener(null);
        delegate.setFindMatchRectsListener(null);
    }

    mCurrentTab.removeObserver(mTabObserver);

    UiUtils.hideKeyboard(mFindQuery);
    if (mFindQuery.getText().length() > 0) {
        clearResults();
        mFindInPageBridge.stopFinding(clearSelection);
    }

    mFindInPageBridge.destroy();
    mFindInPageBridge = null;
    mCurrentTab = null;
    mActive = false;
}
 
Example 7
Source File: EmptyBackgroundViewWrapper.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Unregister all dependencies and listeners.
 */
public void uninitialize() {
    for (TabModel model : mTabModelSelector.getModels()) {
        model.removeObserver(mTabModelObserver);
    }
    mTabModelSelector.removeObserver(mTabModelSelectorObserver);
}
 
Example 8
Source File: ContextualSearchManager.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/** Stops listening for notifications that should hide the Contextual Search bar. */
private void stopListeningForHideNotifications() {
    if (mTabModelSelectorTabObserver != null) mTabModelSelectorTabObserver.destroy();

    TabModelSelector selector = mActivity.getTabModelSelector();
    if (selector != null) {
        for (TabModel tabModel : selector.getModels()) {
            tabModel.removeObserver(mTabModelObserver);
        }
    }
}
 
Example 9
Source File: IncognitoToggleButtonTablet.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
protected void onDetachedFromWindow() {
    if (mTabModelSelector != null) {
        mTabModelSelector.removeObserver(mTabModelSelectorObserver);
        for (TabModel model : mTabModelSelector.getModels()) {
            model.removeObserver(mTabModelObserver);
        }
    }
    super.onDetachedFromWindow();
}
 
Example 10
Source File: FindToolbar.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Call this just before closing the find toolbar.
 * @param clearSelection Whether the selection on the page should be cleared.
 */
public void deactivate(boolean clearSelection) {
    if (!mActive) return;

    if (mObserver != null) mObserver.onFindToolbarHidden();

    setResultsBarVisibility(false);

    mTabModelSelector.removeObserver(mTabModelSelectorObserver);
    for (TabModel model : mTabModelSelector.getModels()) {
        model.removeObserver(mTabModelObserver);
    }

    mCurrentTab.getTabWebContentsDelegateAndroid().setFindResultListener(null);
    mCurrentTab.getTabWebContentsDelegateAndroid().setFindMatchRectsListener(null);
    mCurrentTab.removeObserver(mTabObserver);

    UiUtils.hideKeyboard(mFindQuery);
    if (mFindQuery.getText().length() > 0) {
        clearResults();
        mFindInPageBridge.stopFinding(clearSelection);
    }

    mFindInPageBridge.destroy();
    mFindInPageBridge = null;
    mCurrentTab = null;
    mActive = false;
}
 
Example 11
Source File: EmptyBackgroundViewWrapper.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Unregister all dependencies and listeners.
 */
public void uninitialize() {
    for (TabModel model : mTabModelSelector.getModels()) {
        model.removeObserver(mTabModelObserver);
    }
    mTabModelSelector.removeObserver(mTabModelSelectorObserver);
}
 
Example 12
Source File: ContextualSearchManager.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Stops listening for notifications that should hide the Contextual Search bar.
 */
private void stopListeningForHideNotifications() {
    if (mTabModelSelectorTabObserver != null) mTabModelSelectorTabObserver.destroy();

    TabModelSelector selector = mActivity.getTabModelSelector();
    if (selector != null) {
        for (TabModel tabModel : selector.getModels()) {
            tabModel.removeObserver(mTabModelObserver);
        }
    }
}
 
Example 13
Source File: IncognitoToggleButtonTablet.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
protected void onDetachedFromWindow() {
    if (mTabModelSelector != null) {
        mTabModelSelector.removeObserver(mTabModelSelectorObserver);
        for (TabModel model : mTabModelSelector.getModels()) {
            model.removeObserver(mTabModelObserver);
        }
    }
    super.onDetachedFromWindow();
}
 
Example 14
Source File: FindToolbar.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Call this just before closing the find toolbar.
 * @param clearSelection Whether the selection on the page should be cleared.
 */
public void deactivate(boolean clearSelection) {
    if (!mActive) return;

    if (mObserver != null) mObserver.onFindToolbarHidden();

    setResultsBarVisibility(false);

    mTabModelSelector.removeObserver(mTabModelSelectorObserver);
    for (TabModel model : mTabModelSelector.getModels()) {
        model.removeObserver(mTabModelObserver);
    }

    mCurrentTab.getTabWebContentsDelegateAndroid().setFindResultListener(null);
    mCurrentTab.getTabWebContentsDelegateAndroid().setFindMatchRectsListener(null);
    mCurrentTab.removeObserver(mTabObserver);

    UiUtils.hideKeyboard(mFindQuery);
    if (mFindQuery.getText().length() > 0) {
        clearResults();
        mFindInPageBridge.stopFinding(clearSelection);
    }

    mFindInPageBridge.destroy();
    mFindInPageBridge = null;
    mCurrentTab = null;
    mActive = false;
}
 
Example 15
Source File: EmptyBackgroundViewWrapper.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Unregister all dependencies and listeners.
 */
public void uninitialize() {
    for (TabModel model : mTabModelSelector.getModels()) {
        model.removeObserver(mTabModelObserver);
    }
    mTabModelSelector.removeObserver(mTabModelSelectorObserver);
}
 
Example 16
Source File: ContextualSearchManager.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Stops listening for notifications that should hide the Contextual Search bar.
 */
private void stopListeningForHideNotifications() {
    if (mTabModelSelectorTabObserver != null) mTabModelSelectorTabObserver.destroy();

    TabModelSelector selector = mActivity.getTabModelSelector();
    if (selector != null) {
        for (TabModel tabModel : selector.getModels()) {
            tabModel.removeObserver(mTabModelObserver);
        }
    }
}
 
Example 17
Source File: ActivityTabTaskDescriptionHelper.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Destroys all dependent components of the task description helper.
 */
public void destroy() {
    mFaviconHelper.destroy();

    if (mCurrentTab != null) {
        mCurrentTab.removeObserver(mTabObserver);
    }

    mTabModelSelector.removeObserver(mTabModelSelectorObserver);
    for (TabModel model : mTabModelSelector.getModels()) {
        model.removeObserver(mTabModelObserver);
    }
}
 
Example 18
Source File: UndoBarController.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * Cleans up this class, unregistering for application notifications from the
 * {@link TabModelSelector}.
 */
public void destroy() {
    TabModel model = mTabModelSelector.getModel(false);
    if (model != null) model.removeObserver(mTabModelObserver);
}
 
Example 19
Source File: UndoBarController.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * Cleans up this class, unregistering for application notifications from the
 * {@link TabModelSelector}.
 */
public void destroy() {
    TabModel model = mTabModelSelector.getModel(false);
    if (model != null) model.removeObserver(mTabModelObserver);
}
 
Example 20
Source File: UndoBarController.java    From delion with Apache License 2.0 4 votes vote down vote up
/**
 * Cleans up this class, unregistering for application notifications from the
 * {@link TabModelSelector}.
 */
public void destroy() {
    TabModel model = mTabModelSelector.getModel(false);
    if (model != null) model.removeObserver(mTabModelObserver);
}