Example #1
0
 public virtual bool tryShow()
 {
     mPopup = new android.widget.ListPopupWindow(mContext, null, [email protected]
                                                 .popupMenuStyle);
     mPopup.setOnDismissListener(this);
     mPopup.setOnItemClickListener(this);
     mAdapter = new [email protected](this, mMenu
                                                                            );
     mPopup.setAdapter(mAdapter);
     mPopup.setModal(true);
     android.view.View anchor = mAnchorView;
     if (anchor != null)
     {
         bool addGlobalListener = mTreeObserver == null;
         mTreeObserver = anchor.getViewTreeObserver();
         // Refresh to latest
         if (addGlobalListener)
         {
             mTreeObserver.addOnGlobalLayoutListener(this);
         }
         anchor.addOnAttachStateChangeListener(this);
         mPopup.setAnchorView(anchor);
     }
     else
     {
         return(false);
     }
     mPopup.setContentWidth(System.Math.Min(measureContentWidth(mAdapter), mPopupMaxWidth
                                            ));
     mPopup.setInputMethodMode(android.widget.PopupWindow.INPUT_METHOD_NOT_NEEDED);
     mPopup.show();
     mPopup.getListView().setOnKeyListener(this);
     return(true);
 }
Example #2
0
 /// <summary>Gets the list popup window which is lazily initialized.</summary>
 /// <remarks>Gets the list popup window which is lazily initialized.</remarks>
 /// <returns>The popup.</returns>
 private android.widget.ListPopupWindow getListPopupWindow()
 {
     if (mListPopupWindow == null)
     {
         mListPopupWindow = new android.widget.ListPopupWindow(getContext());
         mListPopupWindow.setAdapter(mAdapter);
         mListPopupWindow.setAnchorView(this);
         mListPopupWindow.setModal(true);
         mListPopupWindow.setOnItemClickListener(mCallbacks);
         mListPopupWindow.setOnDismissListener(mCallbacks);
     }
     return(mListPopupWindow);
 }
Example #3
0
 public virtual void onDismiss()
 {
     mPopup = null;
     mMenu.close();
     if (mTreeObserver != null)
     {
         if (!mTreeObserver.isAlive())
         {
             mTreeObserver = mAnchorView.getViewTreeObserver();
         }
         mTreeObserver.removeGlobalOnLayoutListener(this);
         mTreeObserver = null;
     }
     mAnchorView.removeOnAttachStateChangeListener(this);
 }
Example #4
0
        /// <summary>Shows the popup no matter if it was already showing.</summary>
        /// <remarks>Shows the popup no matter if it was already showing.</remarks>
        /// <param name="maxActivityCount">The max number of activities to display.</param>
        private void showPopupUnchecked(int maxActivityCount)
        {
            if (mAdapter.getDataModel() == null)
            {
                throw new System.InvalidOperationException("No data model. Did you call #setDataModel?"
                                                           );
            }
            getViewTreeObserver().addOnGlobalLayoutListener(mOnGlobalLayoutListener);
            bool defaultActivityButtonShown = mDefaultActivityButton.getVisibility() == VISIBLE;
            int  activityCount          = mAdapter.getActivityCount();
            int  maxActivityCountOffset = defaultActivityButtonShown ? 1 : 0;

            if (maxActivityCount != android.widget.ActivityChooserView.ActivityChooserViewAdapter
                .MAX_ACTIVITY_COUNT_UNLIMITED && activityCount > maxActivityCount + maxActivityCountOffset)
            {
                mAdapter.setShowFooterView(true);
                mAdapter.setMaxActivityCount(maxActivityCount - 1);
            }
            else
            {
                mAdapter.setShowFooterView(false);
                mAdapter.setMaxActivityCount(maxActivityCount);
            }
            android.widget.ListPopupWindow popupWindow = getListPopupWindow();
            if (!popupWindow.isShowing())
            {
                if (mIsSelectingDefaultActivity || !defaultActivityButtonShown)
                {
                    mAdapter.setShowDefaultActivity(true, defaultActivityButtonShown);
                }
                else
                {
                    mAdapter.setShowDefaultActivity(false, false);
                }
                int contentWidth = System.Math.Min(mAdapter.measureContentWidth(), mListPopupMaxWidth
                                                   );
                popupWindow.setContentWidth(contentWidth);
                popupWindow.show();
                if (mProvider != null)
                {
                    mProvider.subUiVisibilityChanged(true);
                }
                popupWindow.getListView().setContentDescription(java.lang.CharSequenceProxy.Wrap(
                                                                    mContext.getString([email protected][email protected]_choose_application
                                                                                       )));
            }
        }
Example #5
0
		/// <summary>Gets the list popup window which is lazily initialized.</summary>
		/// <remarks>Gets the list popup window which is lazily initialized.</remarks>
		/// <returns>The popup.</returns>
		private android.widget.ListPopupWindow getListPopupWindow()
		{
			if (mListPopupWindow == null)
			{
				mListPopupWindow = new android.widget.ListPopupWindow(getContext());
				mListPopupWindow.setAdapter(mAdapter);
				mListPopupWindow.setAnchorView(this);
				mListPopupWindow.setModal(true);
				mListPopupWindow.setOnItemClickListener(mCallbacks);
				mListPopupWindow.setOnDismissListener(mCallbacks);
			}
			return mListPopupWindow;
		}
Example #6
0
		public virtual bool tryShow()
		{
			mPopup = new android.widget.ListPopupWindow(mContext, null, [email protected]
				.popupMenuStyle);
			mPopup.setOnDismissListener(this);
			mPopup.setOnItemClickListener(this);
			mAdapter = new [email protected](this, mMenu
				);
			mPopup.setAdapter(mAdapter);
			mPopup.setModal(true);
			android.view.View anchor = mAnchorView;
			if (anchor != null)
			{
				bool addGlobalListener = mTreeObserver == null;
				mTreeObserver = anchor.getViewTreeObserver();
				// Refresh to latest
				if (addGlobalListener)
				{
					mTreeObserver.addOnGlobalLayoutListener(this);
				}
				anchor.addOnAttachStateChangeListener(this);
				mPopup.setAnchorView(anchor);
			}
			else
			{
				return false;
			}
			mPopup.setContentWidth(System.Math.Min(measureContentWidth(mAdapter), mPopupMaxWidth
				));
			mPopup.setInputMethodMode(android.widget.PopupWindow.INPUT_METHOD_NOT_NEEDED);
			mPopup.show();
			mPopup.getListView().setOnKeyListener(this);
			return true;
		}
Example #7
0
		public virtual void onDismiss()
		{
			mPopup = null;
			mMenu.close();
			if (mTreeObserver != null)
			{
				if (!mTreeObserver.isAlive())
				{
					mTreeObserver = mAnchorView.getViewTreeObserver();
				}
				mTreeObserver.removeGlobalOnLayoutListener(this);
				mTreeObserver = null;
			}
			mAnchorView.removeOnAttachStateChangeListener(this);
		}