Search in sources :

Example 6 with OnAttachStateChangeListener

use of android.view.View.OnAttachStateChangeListener in project android_frameworks_base by DirtyUnicorns.

the class TileService method showDialog.

/**
     * Used to show a dialog.
     *
     * This will collapse the Quick Settings panel and show the dialog.
     *
     * @param dialog Dialog to show.
     *
     * @see #isLocked()
     */
public final void showDialog(Dialog dialog) {
    dialog.getWindow().getAttributes().token = mToken;
    dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_QS_DIALOG);
    dialog.getWindow().getDecorView().addOnAttachStateChangeListener(new OnAttachStateChangeListener() {

        @Override
        public void onViewAttachedToWindow(View v) {
        }

        @Override
        public void onViewDetachedFromWindow(View v) {
            try {
                mService.onDialogHidden(mTileToken);
            } catch (RemoteException e) {
            }
        }
    });
    dialog.show();
    try {
        mService.onShowDialog(mTileToken);
    } catch (RemoteException e) {
    }
}
Also used : OnAttachStateChangeListener(android.view.View.OnAttachStateChangeListener) RemoteException(android.os.RemoteException) View(android.view.View)

Example 7 with OnAttachStateChangeListener

use of android.view.View.OnAttachStateChangeListener in project android_frameworks_base by crdroidandroid.

the class TileService method showDialog.

/**
     * Used to show a dialog.
     *
     * This will collapse the Quick Settings panel and show the dialog.
     *
     * @param dialog Dialog to show.
     *
     * @see #isLocked()
     */
public final void showDialog(Dialog dialog) {
    dialog.getWindow().getAttributes().token = mToken;
    dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_QS_DIALOG);
    dialog.getWindow().getDecorView().addOnAttachStateChangeListener(new OnAttachStateChangeListener() {

        @Override
        public void onViewAttachedToWindow(View v) {
        }

        @Override
        public void onViewDetachedFromWindow(View v) {
            try {
                mService.onDialogHidden(mTileToken);
            } catch (RemoteException e) {
            }
        }
    });
    dialog.show();
    try {
        mService.onShowDialog(mTileToken);
    } catch (RemoteException e) {
    }
}
Also used : OnAttachStateChangeListener(android.view.View.OnAttachStateChangeListener) RemoteException(android.os.RemoteException) View(android.view.View)

Example 8 with OnAttachStateChangeListener

use of android.view.View.OnAttachStateChangeListener in project android_frameworks_base by crdroidandroid.

the class SpTexts method add.

public int add(final TextView text) {
    if (text == null)
        return 0;
    final Resources res = mContext.getResources();
    final float fontScale = res.getConfiguration().fontScale;
    final float density = res.getDisplayMetrics().density;
    final float px = text.getTextSize();
    final int sp = (int) (px / fontScale / density);
    mTexts.put(text, sp);
    text.addOnAttachStateChangeListener(new OnAttachStateChangeListener() {

        @Override
        public void onViewDetachedFromWindow(View v) {
        }

        @Override
        public void onViewAttachedToWindow(View v) {
            setTextSizeH(text, sp);
        }
    });
    return sp;
}
Also used : OnAttachStateChangeListener(android.view.View.OnAttachStateChangeListener) Resources(android.content.res.Resources) TextView(android.widget.TextView) View(android.view.View)

Example 9 with OnAttachStateChangeListener

use of android.view.View.OnAttachStateChangeListener in project AndroidChromium by JackyAndroid.

the class ToolbarManager method initializeWithNative.

/**
     * Initialize the manager with the components that had native initialization dependencies.
     * <p>
     * Calling this must occur after the native library have completely loaded.
     *
     * @param tabModelSelector     The selector that handles tab management.
     * @param fullscreenManager    The manager in charge of interacting with the fullscreen feature.
     * @param findToolbarManager   The manager for find in page.
     * @param overviewModeBehavior The overview mode manager.
     * @param layoutDriver         A {@link LayoutManager} instance used to watch for scene changes.
     */
public void initializeWithNative(TabModelSelector tabModelSelector, ChromeFullscreenManager fullscreenManager, final FindToolbarManager findToolbarManager, final OverviewModeBehavior overviewModeBehavior, final LayoutManager layoutDriver, OnClickListener tabSwitcherClickHandler, OnClickListener newTabClickHandler, OnClickListener bookmarkClickHandler, OnClickListener customTabsBackClickHandler) {
    assert !mInitializedWithNative;
    mTabModelSelector = tabModelSelector;
    mToolbar.getLocationBar().updateVisualsForState();
    mToolbar.getLocationBar().setUrlToPageUrl();
    mToolbar.setFullscreenManager(fullscreenManager);
    mToolbar.setOnTabSwitcherClickHandler(tabSwitcherClickHandler);
    mToolbar.setOnNewTabClickHandler(newTabClickHandler);
    mToolbar.setBookmarkClickHandler(bookmarkClickHandler);
    mToolbar.setCustomTabCloseClickHandler(customTabsBackClickHandler);
    mToolbar.setLayoutUpdateHost(layoutDriver);
    mToolbarModel.initializeWithNative();
    mToolbar.addOnAttachStateChangeListener(new OnAttachStateChangeListener() {

        @Override
        public void onViewDetachedFromWindow(View v) {
            Context context = mToolbar.getContext();
            HomepageManager.getInstance(context).removeListener(mHomepageStateListener);
            mTabModelSelector.removeObserver(mTabModelSelectorObserver);
            for (TabModel model : mTabModelSelector.getModels()) {
                model.removeObserver(mTabModelObserver);
            }
            if (mBookmarkBridge != null) {
                mBookmarkBridge.destroy();
                mBookmarkBridge = null;
            }
            if (mTemplateUrlObserver != null) {
                TemplateUrlService.getInstance().removeObserver(mTemplateUrlObserver);
                mTemplateUrlObserver = null;
            }
            // Remove all previously attached observers from the FindToolbarManager.
            if (mFindToolbarManager != null) {
                for (FindToolbarObserver observer : mFindToolbarObservers) {
                    mFindToolbarManager.removeObserver(observer);
                }
            }
            if (overviewModeBehavior != null) {
                overviewModeBehavior.removeOverviewModeObserver(mOverviewModeObserver);
            }
            if (layoutDriver != null) {
                layoutDriver.removeSceneChangeObserver(mSceneChangeObserver);
            }
        }

        @Override
        public void onViewAttachedToWindow(View v) {
            // As we have only just registered for notifications, any that were sent prior to
            // this may have been missed.
            // Calling refreshSelectedTab in case we missed the initial selection notification.
            refreshSelectedTab();
        }
    });
    mFindToolbarManager = findToolbarManager;
    assert fullscreenManager != null;
    mFullscreenManager = fullscreenManager;
    mNativeLibraryReady = false;
    // Add observers to the FindToolbarManager.
    if (mFindToolbarManager != null) {
        for (FindToolbarObserver observer : mFindToolbarObservers) {
            mFindToolbarManager.addObserver(observer);
        }
    }
    if (overviewModeBehavior != null) {
        overviewModeBehavior.addOverviewModeObserver(mOverviewModeObserver);
    }
    if (layoutDriver != null)
        layoutDriver.addSceneChangeObserver(mSceneChangeObserver);
    onNativeLibraryReady();
    mInitializedWithNative = true;
}
Also used : Context(android.content.Context) FindToolbarObserver(org.chromium.chrome.browser.widget.findinpage.FindToolbarObserver) OnAttachStateChangeListener(android.view.View.OnAttachStateChangeListener) View(android.view.View) TabModel(org.chromium.chrome.browser.tabmodel.TabModel)

Example 10 with OnAttachStateChangeListener

use of android.view.View.OnAttachStateChangeListener in project platform_frameworks_base by android.

the class TileService method showDialog.

/**
     * Used to show a dialog.
     *
     * This will collapse the Quick Settings panel and show the dialog.
     *
     * @param dialog Dialog to show.
     *
     * @see #isLocked()
     */
public final void showDialog(Dialog dialog) {
    dialog.getWindow().getAttributes().token = mToken;
    dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_QS_DIALOG);
    dialog.getWindow().getDecorView().addOnAttachStateChangeListener(new OnAttachStateChangeListener() {

        @Override
        public void onViewAttachedToWindow(View v) {
        }

        @Override
        public void onViewDetachedFromWindow(View v) {
            try {
                mService.onDialogHidden(mTileToken);
            } catch (RemoteException e) {
            }
        }
    });
    dialog.show();
    try {
        mService.onShowDialog(mTileToken);
    } catch (RemoteException e) {
    }
}
Also used : OnAttachStateChangeListener(android.view.View.OnAttachStateChangeListener) RemoteException(android.os.RemoteException) View(android.view.View)

Aggregations

View (android.view.View)14 OnAttachStateChangeListener (android.view.View.OnAttachStateChangeListener)14 Resources (android.content.res.Resources)5 RemoteException (android.os.RemoteException)5 TextView (android.widget.TextView)5 ViewGroup (android.view.ViewGroup)2 Context (android.content.Context)1 ViewStub (android.view.ViewStub)1 TabModel (org.chromium.chrome.browser.tabmodel.TabModel)1 FindToolbarObserver (org.chromium.chrome.browser.widget.findinpage.FindToolbarObserver)1