use of org.holoeverywhere.widget.ListPopupWindow in project HoloEverywhere by Prototik.
the class ActivityChooserView method showPopupUnchecked.
/**
* Shows the popup no matter if it was already showing.
*
* @param maxActivityCount The max number of activities to display.
*/
private void showPopupUnchecked(int maxActivityCount) {
if (mAdapter.getDataModel() == null) {
throw new IllegalStateException("No data model. Did you call #setDataModel?");
}
getViewTreeObserver().addOnGlobalLayoutListener(mOnGlobalLayoutListener);
final boolean defaultActivityButtonShown = mDefaultActivityButton.getVisibility() == VISIBLE;
final int activityCount = mAdapter.getActivityCount();
final int maxActivityCountOffset = defaultActivityButtonShown ? 1 : 0;
if (maxActivityCount != ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_UNLIMITED && activityCount > maxActivityCount + maxActivityCountOffset) {
mAdapter.setShowFooterView(true);
mAdapter.setMaxActivityCount(maxActivityCount - 1);
} else {
mAdapter.setShowFooterView(false);
mAdapter.setMaxActivityCount(maxActivityCount);
}
ListPopupWindow popupWindow = getListPopupWindow();
if (!popupWindow.isShowing()) {
if (mIsSelectingDefaultActivity || !defaultActivityButtonShown) {
mAdapter.setShowDefaultActivity(true, defaultActivityButtonShown);
} else {
mAdapter.setShowDefaultActivity(false, false);
}
final int contentWidth = Math.min(mAdapter.measureContentWidth(), mListPopupMaxWidth);
popupWindow.setContentWidth(contentWidth);
popupWindow.show();
if (mProvider != null) {
mProvider.subUiVisibilityChanged(true);
}
popupWindow.getListView().setContentDescription(getContext().getString(R.string.abc_activitychooserview_choose_application));
}
}
use of org.holoeverywhere.widget.ListPopupWindow in project HoloEverywhere by Prototik.
the class ActivityChooserView method getListPopupWindow.
/**
* Gets the list popup window which is lazily initialized.
*
* @return The popup.
*/
private ListPopupWindow getListPopupWindow() {
if (mListPopupWindow == null) {
mListPopupWindow = new ListPopupWindow(getContext());
mListPopupWindow.setAdapter(mAdapter);
mListPopupWindow.setAnchorView(ActivityChooserView.this);
mListPopupWindow.setModal(true);
mListPopupWindow.setOnItemClickListener(mCallbacks);
mListPopupWindow.setOnDismissListener(mCallbacks);
}
return mListPopupWindow;
}
use of org.holoeverywhere.widget.ListPopupWindow in project HoloEverywhere by Prototik.
the class MenuPopupHelper method tryShow.
public boolean tryShow() {
mPopup = new ListPopupWindow(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);
}
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 org.holoeverywhere.widget.ListPopupWindow 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