Search in sources :

Example 1 with OnAttachStateChangeListener

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

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 2 with OnAttachStateChangeListener

use of android.view.View.OnAttachStateChangeListener in project Conductor by bluelinelabs.

the class ViewAttachHandler method listenForDeepestChildAttach.

void listenForDeepestChildAttach(final View view, final ChildAttachListener attachListener) {
    if (!(view instanceof ViewGroup)) {
        attachListener.onAttached();
        return;
    }
    ViewGroup viewGroup = (ViewGroup) view;
    if (viewGroup.getChildCount() == 0) {
        attachListener.onAttached();
        return;
    }
    childOnAttachStateChangeListener = new OnAttachStateChangeListener() {

        boolean attached = false;

        @Override
        public void onViewAttachedToWindow(View v) {
            if (!attached) {
                attached = true;
                attachListener.onAttached();
                v.removeOnAttachStateChangeListener(this);
                childOnAttachStateChangeListener = null;
            }
        }

        @Override
        public void onViewDetachedFromWindow(View v) {
        }
    };
    findDeepestChild(viewGroup).addOnAttachStateChangeListener(childOnAttachStateChangeListener);
}
Also used : ViewGroup(android.view.ViewGroup) OnAttachStateChangeListener(android.view.View.OnAttachStateChangeListener) View(android.view.View)

Example 3 with OnAttachStateChangeListener

use of android.view.View.OnAttachStateChangeListener in project Conductor by bluelinelabs.

the class ViewUtils method reportAttached.

public static void reportAttached(View view, boolean attached, boolean propogateToChildren) {
    if (view instanceof AttachFakingFrameLayout) {
        ((AttachFakingFrameLayout) view).setAttached(attached, false);
    }
    List<OnAttachStateChangeListener> listeners = getAttachStateListeners(view);
    // Add, then remove an OnAttachStateChangeListener to initialize the attachStateListeners variable inside a view
    if (listeners == null) {
        OnAttachStateChangeListener tmpListener = new OnAttachStateChangeListener() {

            @Override
            public void onViewAttachedToWindow(View v) {
            }

            @Override
            public void onViewDetachedFromWindow(View v) {
            }
        };
        view.addOnAttachStateChangeListener(tmpListener);
        view.removeOnAttachStateChangeListener(tmpListener);
        listeners = getAttachStateListeners(view);
    }
    for (OnAttachStateChangeListener listener : listeners) {
        if (attached) {
            listener.onViewAttachedToWindow(view);
        } else {
            listener.onViewDetachedFromWindow(view);
        }
    }
    if (propogateToChildren && view instanceof ViewGroup) {
        ViewGroup viewGroup = (ViewGroup) view;
        int childCount = viewGroup.getChildCount();
        for (int i = 0; i < childCount; i++) {
            reportAttached(viewGroup.getChildAt(i), attached, true);
        }
    }
}
Also used : ViewGroup(android.view.ViewGroup) OnAttachStateChangeListener(android.view.View.OnAttachStateChangeListener) View(android.view.View)

Example 4 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 5 with OnAttachStateChangeListener

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

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)

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