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;
}
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;
}
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;
}
Aggregations