Search in sources :

Example 6 with View_HasStateListenerSupport

use of com.actionbarsherlock.internal.view.View_HasStateListenerSupport in project Ushahidi_Android by ushahidi.

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 7 with View_HasStateListenerSupport

use of com.actionbarsherlock.internal.view.View_HasStateListenerSupport in project AndroidTraining by mixi-inc.

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 8 with View_HasStateListenerSupport

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

the class PopupMenuHelper method tryShow.

public boolean tryShow() {
    mPopup = new ListPopupWindow(mContext);
    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;
        mTreeObserver = anchor.getViewTreeObserver();
        if (addGlobalListener) {
            mTreeObserver.addOnGlobalLayoutListener(this);
            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) ListPopupWindow(org.holoeverywhere.widget.ListPopupWindow) View(android.view.View) AdapterView(android.widget.AdapterView)

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