コード例 #1
0
 public void showMenu(View v) {
   PopupMenu popup = new PopupMenu(activity, v);
   popup.setOnMenuItemClickListener(this);
   if (isPlanner) {
     popup.inflate(R.menu.menu_event_list);
   } else {
     popup.inflate(R.menu.bidder_menu_item_list);
   }
   // Force icons to show
   Object menuHelper;
   Class[] argTypes;
   try {
     Field fMenuHelper = PopupMenu.class.getDeclaredField("mPopup");
     fMenuHelper.setAccessible(true);
     menuHelper = fMenuHelper.get(popup);
     argTypes = new Class[] {boolean.class};
     menuHelper
         .getClass()
         .getDeclaredMethod("setForceShowIcon", argTypes)
         .invoke(menuHelper, true);
   } catch (Exception e) {
     popup.show();
     return;
   }
   popup.show();
 }
コード例 #2
0
ファイル: MainActivity.java プロジェクト: mcamana/Android
 @Override
 public void onClick(View v) {
   PopupMenu popup = new PopupMenu(v.getContext(), v);
   popup.inflate(R.menu.mnu);
   popup.setOnMenuItemClickListener(this);
   popup.show();
 }
コード例 #3
0
  private void showSecurityMenu() {
    PopupMenu popup = new PopupMenu(getActivity(), securityButton);
    popup.inflate(R.menu.security);
    popup.setOnMenuItemClickListener(this);

    Menu menu = popup.getMenu();

    SecurityLevel securityLevel = OTRManager.getInstance().getSecurityLevel(account, user);

    if (securityLevel == SecurityLevel.plain) {
      menu.findItem(R.id.action_start_encryption)
          .setVisible(true)
          .setEnabled(
              SettingsManager.securityOtrMode() != SettingsManager.SecurityOtrMode.disabled);
    } else {
      menu.findItem(R.id.action_restart_encryption).setVisible(true);
    }

    boolean isEncrypted = securityLevel != SecurityLevel.plain;

    menu.findItem(R.id.action_stop_encryption).setEnabled(isEncrypted);
    menu.findItem(R.id.action_verify_with_fingerprint).setEnabled(isEncrypted);
    menu.findItem(R.id.action_verify_with_question).setEnabled(isEncrypted);
    menu.findItem(R.id.action_verify_with_shared_secret).setEnabled(isEncrypted);

    popup.show();
  }
コード例 #4
0
  void popupNavi(View view) {
    PopupMenu popupMenu = new PopupMenu(getActivity(), view);
    popupMenu.inflate(R.menu.navi_menu);
    popupMenu.setOnMenuItemClickListener(
        new PopupMenu.OnMenuItemClickListener() {
          @Override
          public boolean onMenuItemClick(MenuItem item) {

            switch (item.getItemId()) {
              case R.id.action_autonavi:
                if (isAppInstalled(getActivity(), "com.autonavi.minimap")) {
                  shareToAutoNavi();
                } else {
                  showToast("高德地图未安装");
                }
                break;
              case R.id.action_baidunavi:
                if (isAppInstalled(getActivity(), "com.baidu.BaiduMap")) {
                  shareToBaidu();
                } else {
                  showToast("百度地图未安装");
                }
                break;
            }
            return true;
          }
        });
    popupMenu.show();
  }
コード例 #5
0
  // Open menu for choosing adding new movie mode: manual or via internet
  // by click on Plus icon.
  public void imageViewPlusIcon_onClick(View view) {
    PopupMenu popupMenu = new PopupMenu(this, view);
    popupMenu.inflate(R.menu.menu_plus_button);
    popupMenu.setOnMenuItemClickListener(
        new PopupMenu.OnMenuItemClickListener() {
          public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
              case R.id.action_plus_manual:
                Intent intent = new Intent(MainActivity.this, EditorActivity.class);
                intent.putExtra(Constants.KEY_ID, Constants.VALUE_NEW_MOVIE);
                startActivityForResult(intent, REQUEST_EDITOR);
                break;

              case R.id.action_plus_search:
                if (Helper.isNetworkAvailable(MainActivity.this)) {
                  Intent intentSearch = new Intent(MainActivity.this, SearchActivity.class);
                  startActivityForResult(intentSearch, REQUEST_SEARCH);
                } else {
                  Toast.makeText(
                          MainActivity.this,
                          R.string.no_internet_connection_warning,
                          Toast.LENGTH_LONG)
                      .show();
                }
                break;
            }
            return true;
          }
        });
    popupMenu.show();
  }
コード例 #6
0
ファイル: CreatAd.java プロジェクト: Brijatov/Companions
  private void showPopupMenu(View v) {
    PopupMenu popupMenu = new PopupMenu(this, v);
    popupMenu.inflate(R.menu.popupmenu_currency);

    popupMenu.setOnMenuItemClickListener(
        new PopupMenu.OnMenuItemClickListener() {
          @Override
          public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
              case R.id.$:
                editTextCurrency.setText("$");
                return true;
              case R.id.€:
                editTextCurrency.setText("€");
                return true;
              case R.id.₴:
                editTextCurrency.setText("₴");
                return true;
              default:
                return false;
            }
          }
        });
    popupMenu.show();
  }
コード例 #7
0
 public void abrirPopupMenu(DetallePedido detalle) {
   detalle_seleccionado = detalle;
   PopupMenu popupMenu = new PopupMenu(activity, ibtnMas);
   popupMenu.setOnMenuItemClickListener(this);
   popupMenu.inflate(R.menu.popup_menu_detalle_venta);
   popupMenu.show();
 }
コード例 #8
0
  private PopupMenu constructPopupMenu(View anchorView) {

    final PopupMenu popupMenu = new PopupMenu(this, anchorView);
    popupMenu.inflate(R.menu.main_activity);
    popupMenu.setOnMenuItemClickListener(listener);

    return popupMenu;
  }
コード例 #9
0
 private void showPopupMenu(Context context, View view) {
   if (popupMenu == null) {
     popupMenu = new PopupMenu(context, view);
     popupMenu.inflate(R.menu.popup_menu);
     popupMenu.setOnMenuItemClickListener(HomeActivity.this);
   }
   popupMenu.show();
 }
コード例 #10
0
 @Override
 public void onClick(View view) {
   final PopupMenu popupMenu = new PopupMenu(DialtactsActivity.this, view);
   final Menu menu = popupMenu.getMenu();
   popupMenu.inflate(R.menu.dialtacts_search_options);
   final MenuItem filterOptionMenuItem = menu.findItem(R.id.filter_option);
   filterOptionMenuItem.setOnMenuItemClickListener(mFilterOptionsMenuItemClickListener);
   final MenuItem addContactOptionMenuItem = menu.findItem(R.id.add_contact);
   addContactOptionMenuItem.setIntent(
       new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI));
   popupMenu.show();
 }
コード例 #11
0
 @Override
 public void onPopupMenuClick(View v, final int seasonTvdbId, final int seasonNumber) {
   PopupMenu popupMenu = new PopupMenu(v.getContext(), v);
   popupMenu.inflate(R.menu.seasons_popup_menu);
   popupMenu.setOnMenuItemClickListener(
       new PopupMenu.OnMenuItemClickListener() {
         @Override
         public boolean onMenuItemClick(MenuItem item) {
           switch (item.getItemId()) {
             case R.id.menu_action_seasons_watched_all:
               {
                 onFlagSeasonWatched(seasonTvdbId, seasonNumber, true);
                 fireTrackerEventContextMenu("Flag all watched");
                 return true;
               }
             case R.id.menu_action_seasons_watched_none:
               {
                 onFlagSeasonWatched(seasonTvdbId, seasonNumber, false);
                 fireTrackerEventContextMenu("Flag all unwatched");
                 return true;
               }
             case R.id.menu_action_seasons_collection_add:
               {
                 onFlagSeasonCollected(seasonTvdbId, seasonNumber, true);
                 fireTrackerEventContextMenu("Flag all collected");
                 return true;
               }
             case R.id.menu_action_seasons_collection_remove:
               {
                 onFlagSeasonCollected(seasonTvdbId, seasonNumber, false);
                 fireTrackerEventContextMenu("Flag all uncollected");
                 return true;
               }
             case R.id.menu_action_seasons_skip:
               {
                 onFlagSeasonSkipped(seasonTvdbId, seasonNumber);
                 fireTrackerEventContextMenu("Flag all skipped");
                 return true;
               }
             case R.id.menu_action_seasons_manage_lists:
               {
                 ManageListsDialogFragment.showListsDialog(
                     seasonTvdbId, ListItemTypes.SEASON, getFragmentManager());
                 fireTrackerEventContextMenu("Manage lists");
                 return true;
               }
           }
           return false;
         }
       });
   popupMenu.show();
 }
コード例 #12
0
 @SuppressLint("NewApi")
 private void showProfilePopup(View view) {
   PopupMenu popupMenu = new PopupMenu(BaseActivity.this, view);
   popupMenu.inflate(R.menu.profile_popup);
   popupMenu.setOnMenuItemClickListener(
       new OnMenuItemClickListener() {
         @Override
         public boolean onMenuItemClick(MenuItem item) {
           return onProfilePopupItemClick(item);
         }
       });
   popupMenu.show();
 }
コード例 #13
0
  public void setupFakeActionBarItems() {
    mMenuButton = findViewById(R.id.overflow_menu);
    if (mMenuButton != null) {
      mMenuButton.setOnClickListener(this);

      mOverflowMenu = new OverflowPopupMenu(DialtactsActivity.this, mMenuButton);
      final Menu menu = mOverflowMenu.getMenu();
      mOverflowMenu.inflate(R.menu.dialtacts_options);
      mOverflowMenu.setOnMenuItemClickListener(this);
      mMenuButton.setOnTouchListener(mOverflowMenu.getDragToOpenListener());
    }

    mCallHistoryButton = findViewById(R.id.call_history_button);
    // mCallHistoryButton.setMinimumWidth(fakeMenuItemWidth);
    mCallHistoryButton.setOnClickListener(this);

    mDialpadButton = findViewById(R.id.dialpad_button);
    // DialpadButton.setMinimumWidth(fakeMenuItemWidth);
    mDialpadButton.setOnClickListener(this);
  }
コード例 #14
0
  @Override
  public void onMessageClick(View caller, int position) {
    int itemViewType = chatMessageAdapter.getItemViewType(position);

    if (itemViewType == ChatMessageAdapter.VIEW_TYPE_INCOMING_MESSAGE
        || itemViewType == ChatMessageAdapter.VIEW_TYPE_OUTGOING_MESSAGE) {

      clickedMessageItem = chatMessageAdapter.getMessageItem(position);

      PopupMenu popup = new PopupMenu(getActivity(), caller);
      popup.inflate(R.menu.chat_context_menu);
      popup.setOnMenuItemClickListener(this);

      final Menu menu = popup.getMenu();

      if (clickedMessageItem.isError()) {
        menu.findItem(R.id.action_message_repeat).setVisible(true);
      }

      if (clickedMessageItem.isUploadFileMessage()) {
        menu.findItem(R.id.action_message_copy).setVisible(false);
        menu.findItem(R.id.action_message_quote).setVisible(false);
        menu.findItem(R.id.action_message_remove).setVisible(false);
      }

      final File file = clickedMessageItem.getFile();

      if (file != null && file.exists()) {
        menu.findItem(R.id.action_message_open_file).setVisible(true);
        menu.findItem(R.id.action_message_save_file).setVisible(true);
      }

      if (clickedMessageItem.isIncoming() && MUCManager.getInstance().hasRoom(account, user)) {
        menu.findItem(R.id.action_message_open_muc_private_chat).setVisible(true);
      }

      popup.show();
    }
  }
コード例 #15
0
        @Override
        public void onItemClick(AdapterView<?> parent, View view, final int position, long id) {

          PopupMenu menu = new PopupMenu(getActivity(), view);
          menu.inflate(R.menu.popup);

          menu.setOnMenuItemClickListener(
              new OnMenuItemClickListener() {
                @Override
                public boolean onMenuItemClick(MenuItem item) {

                  if (item.getItemId() == R.id.popup_playall) {
                    Control.sendSelectList(PlayService.LIST_ALL_DROPBOX, position);
                    Control.selectFragment(0);
                  } else {
                    Control.sendAddItem(PlayService.LIST_ALL_DROPBOX, position);
                  }

                  return true;
                }
              });
          menu.show();
        }
コード例 #16
0
  @Override
  public void onClick(View v) {

    switch (v.getId()) {
      case R.id.btnProfileMode:
        PopupMenu popup = new PopupMenu(getActivity(), v);
        popup.setOnMenuItemClickListener(instance);
        popup.inflate(R.menu.menu_profile);
        popup.show();
        break;
      case R.id.selectTimeFrom:
        showTimeDialog(txtTimeFrom, timeFrom);
        break;

      case R.id.selectTimeTo:
        showTimeDialog(txtTimeTo, timeTo);
        break;

      case R.id.selectRepeat:
        DaysOptionsFragment daysOptionsFragment = new DaysOptionsFragment();
        daysOptionsFragment.show(getFragmentManager(), "dialog");
        break;
    }
  }
コード例 #17
0
 public void showPopup(View v) {
   PopupMenu popup = new PopupMenu(this, v);
   popup.setOnMenuItemClickListener(this);
   popup.inflate(R.menu.main_menu);
   popup.show();
 }