Search in sources :

Example 1 with View_HasStateListenerSupport

use of com.actionbarsherlock.internal.view.View_HasStateListenerSupport in project httpclient by pixmob.

the class MenuPopupHelper method tryShow.

public boolean tryShow() {
    mPopup = new IcsListPopupWindow(mContext, null, R.attr.popupMenuStyle);
    mPopup.setOnDismissListener(this);
    mPopup.setOnItemClickListener(this);
    mAdapter = new MenuAdapter(mMenu);
    mPopup.setAdapter(mAdapter);
    mPopup.setModal(true);
    View anchor = mAnchorView;
    if (anchor != null) {
        final boolean addGlobalListener = mTreeObserver == null;
        // Refresh to latest
        mTreeObserver = anchor.getViewTreeObserver();
        if (addGlobalListener)
            mTreeObserver.addOnGlobalLayoutListener(this);
        ((View_HasStateListenerSupport) anchor).addOnAttachStateChangeListener(this);
        mPopup.setAnchorView(anchor);
    } else {
        return false;
    }
    mPopup.setContentWidth(Math.min(measureContentWidth(mAdapter), mPopupMaxWidth));
    mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
    mPopup.show();
    mPopup.getListView().setOnKeyListener(this);
    return true;
}
Also used : View_HasStateListenerSupport(com.actionbarsherlock.internal.view.View_HasStateListenerSupport) View(android.view.View) AdapterView(android.widget.AdapterView) IcsListPopupWindow(com.actionbarsherlock.internal.widget.IcsListPopupWindow)

Example 2 with View_HasStateListenerSupport

use of com.actionbarsherlock.internal.view.View_HasStateListenerSupport in project Libraries-for-Android-Developers by eoecn.

the class MenuPopupHelper method tryShow.

public boolean tryShow() {
    mPopup = new IcsListPopupWindow(mContext, null, R.attr.popupMenuStyle);
    mPopup.setOnDismissListener(this);
    mPopup.setOnItemClickListener(this);
    mAdapter = new MenuAdapter(mMenu);
    mPopup.setAdapter(mAdapter);
    mPopup.setModal(true);
    View anchor = mAnchorView;
    if (anchor != null) {
        // Don't attach to the VTO unless the anchor itself is attached to avoid VTO-related leaks.
        if (anchor.getWindowToken() != null) {
            ViewTreeObserver vto = anchor.getViewTreeObserver();
            if (vto != mTreeObserver) {
                if (mTreeObserver != null && mTreeObserver.isAlive()) {
                    mTreeObserver.removeGlobalOnLayoutListener(this);
                }
                if ((mTreeObserver = vto) != null) {
                    vto.addOnGlobalLayoutListener(this);
                }
            }
        } else if (anchor instanceof View_HasStateListenerSupport) {
            ((View_HasStateListenerSupport) anchor).addOnAttachStateChangeListener(this);
        }
        mPopup.setAnchorView(anchor);
    } else {
        return false;
    }
    mPopup.setContentWidth(Math.min(measureContentWidth(mAdapter), mPopupMaxWidth));
    mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
    mPopup.show();
    mPopup.getListView().setOnKeyListener(this);
    return true;
}
Also used : View_HasStateListenerSupport(com.actionbarsherlock.internal.view.View_HasStateListenerSupport) View(android.view.View) AdapterView(android.widget.AdapterView) ViewTreeObserver(android.view.ViewTreeObserver) IcsListPopupWindow(com.actionbarsherlock.internal.widget.IcsListPopupWindow)

Example 3 with View_HasStateListenerSupport

use of com.actionbarsherlock.internal.view.View_HasStateListenerSupport in project little-bear-dictionary by daimajia.

the class MenuPopupHelper method tryShow.

public boolean tryShow() {
    mPopup = new IcsListPopupWindow(mContext, null, R.attr.popupMenuStyle);
    mPopup.setOnDismissListener(this);
    mPopup.setOnItemClickListener(this);
    mAdapter = new MenuAdapter(mMenu);
    mPopup.setAdapter(mAdapter);
    mPopup.setModal(true);
    View anchor = mAnchorView;
    if (anchor != null) {
        final boolean addGlobalListener = mTreeObserver == null;
        // Refresh to latest
        mTreeObserver = anchor.getViewTreeObserver();
        if (addGlobalListener)
            mTreeObserver.addOnGlobalLayoutListener(this);
        ((View_HasStateListenerSupport) anchor).addOnAttachStateChangeListener(this);
        mPopup.setAnchorView(anchor);
    } else {
        return false;
    }
    mPopup.setContentWidth(Math.min(measureContentWidth(mAdapter), mPopupMaxWidth));
    mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
    mPopup.show();
    mPopup.getListView().setOnKeyListener(this);
    return true;
}
Also used : View_HasStateListenerSupport(com.actionbarsherlock.internal.view.View_HasStateListenerSupport) View(android.view.View) AdapterView(android.widget.AdapterView) IcsListPopupWindow(com.actionbarsherlock.internal.widget.IcsListPopupWindow)

Example 4 with View_HasStateListenerSupport

use of com.actionbarsherlock.internal.view.View_HasStateListenerSupport in project cw-omnibus by commonsguy.

the class MenuPopupHelper method tryShow.

public boolean tryShow() {
    mPopup = new IcsListPopupWindow(mContext, null, R.attr.popupMenuStyle);
    mPopup.setOnDismissListener(this);
    mPopup.setOnItemClickListener(this);
    mAdapter = new MenuAdapter(mMenu);
    mPopup.setAdapter(mAdapter);
    mPopup.setModal(true);
    View anchor = mAnchorView;
    if (anchor != null) {
        final boolean addGlobalListener = mTreeObserver == null;
        // Refresh to latest
        mTreeObserver = anchor.getViewTreeObserver();
        if (addGlobalListener)
            mTreeObserver.addOnGlobalLayoutListener(this);
        ((View_HasStateListenerSupport) anchor).addOnAttachStateChangeListener(this);
        mPopup.setAnchorView(anchor);
    } else {
        return false;
    }
    mPopup.setContentWidth(Math.min(measureContentWidth(mAdapter), mPopupMaxWidth));
    mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
    mPopup.show();
    mPopup.getListView().setOnKeyListener(this);
    return true;
}
Also used : View_HasStateListenerSupport(com.actionbarsherlock.internal.view.View_HasStateListenerSupport) View(android.view.View) AdapterView(android.widget.AdapterView) IcsListPopupWindow(com.actionbarsherlock.internal.widget.IcsListPopupWindow)

Example 5 with View_HasStateListenerSupport

use of com.actionbarsherlock.internal.view.View_HasStateListenerSupport in project ActionBarSherlock by JakeWharton.

the class MenuPopupHelper method tryShow.

public boolean tryShow() {
    mPopup = new IcsListPopupWindow(mContext, null, R.attr.popupMenuStyle);
    mPopup.setOnDismissListener(this);
    mPopup.setOnItemClickListener(this);
    mAdapter = new MenuAdapter(mMenu);
    mPopup.setAdapter(mAdapter);
    mPopup.setModal(true);
    View anchor = mAnchorView;
    if (anchor != null) {
        // Don't attach to the VTO unless the anchor itself is attached to avoid VTO-related leaks.
        if (anchor.getWindowToken() != null) {
            ViewTreeObserver vto = anchor.getViewTreeObserver();
            if (vto != mTreeObserver) {
                if (mTreeObserver != null && mTreeObserver.isAlive()) {
                    mTreeObserver.removeGlobalOnLayoutListener(this);
                }
                if ((mTreeObserver = vto) != null) {
                    vto.addOnGlobalLayoutListener(this);
                }
            }
        } else if (anchor instanceof View_HasStateListenerSupport) {
            ((View_HasStateListenerSupport) anchor).addOnAttachStateChangeListener(this);
        }
        mPopup.setAnchorView(anchor);
    } else {
        return false;
    }
    mPopup.setContentWidth(Math.min(measureContentWidth(mAdapter), mPopupMaxWidth));
    mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
    mPopup.show();
    mPopup.getListView().setOnKeyListener(this);
    return true;
}
Also used : View_HasStateListenerSupport(com.actionbarsherlock.internal.view.View_HasStateListenerSupport) View(android.view.View) AdapterView(android.widget.AdapterView) ViewTreeObserver(android.view.ViewTreeObserver) IcsListPopupWindow(com.actionbarsherlock.internal.widget.IcsListPopupWindow)

Aggregations

View (android.view.View)8 AdapterView (android.widget.AdapterView)8 View_HasStateListenerSupport (com.actionbarsherlock.internal.view.View_HasStateListenerSupport)8 IcsListPopupWindow (com.actionbarsherlock.internal.widget.IcsListPopupWindow)7 ViewTreeObserver (android.view.ViewTreeObserver)3 ListPopupWindow (org.holoeverywhere.widget.ListPopupWindow)1