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();
 }
 public void handleLongPress(
     final View selectedView, final View anchorView, final View thumbnailView) {
   thumbnailView.setSelected(true);
   final PopupMenu popup = new PopupMenu(mContext, anchorView == null ? selectedView : anchorView);
   mPopup = popup;
   popup.getMenuInflater().inflate(R.menu.recent_popup_menu, popup.getMenu());
   popup.setOnMenuItemClickListener(
       new PopupMenu.OnMenuItemClickListener() {
         public boolean onMenuItemClick(MenuItem item) {
           if (item.getItemId() == R.id.recent_remove_item) {
             mRecentsContainer.removeViewInLayout(selectedView);
           } else if (item.getItemId() == R.id.recent_inspect_item) {
             ViewHolder viewHolder = (ViewHolder) selectedView.getTag();
             if (viewHolder != null && viewHolder.taskDescription != null) {
               final TaskDescription ad = viewHolder.taskDescription;
               startApplicationDetailsActivity(ad.packageName);
               show(false);
             } else {
               throw new IllegalStateException("Oops, no tag on view " + selectedView);
             }
           } else {
             return false;
           }
           return true;
         }
       });
   popup.setOnDismissListener(
       new PopupMenu.OnDismissListener() {
         public void onDismiss(PopupMenu menu) {
           thumbnailView.setSelected(false);
           mPopup = null;
         }
       });
   popup.show();
 }
 public void showPopup(View v) {
   final PopupMenu popup = new PopupMenu(this, v);
   popup.setOnMenuItemClickListener(new PopupEventListener());
   final MenuInflater inflater = popup.getMenuInflater();
   inflater.inflate(R.menu.search_activity_menu, popup.getMenu());
   popup.show();
 }
  public void showPopupMenu(View v) {
    PopupMenu popup = new PopupMenu(Home.this, v);
    popup.getMenuInflater().inflate(R.menu.sms_menu, popup.getMenu());
    popup.setOnMenuItemClickListener(
        new PopupMenu.OnMenuItemClickListener() {

          @Override
          public boolean onMenuItemClick(MenuItem item) {
            // TODO Auto-generated method stub
            switch (item.getItemId()) {
              case R.id.edit_profile:
                {
                  viewFlipper.setInAnimation(Lesson.go_next_in);
                  viewFlipper.setOutAnimation(Lesson.go_next_out);
                  viewFlipper.showNext();
                  break;
                }
              case R.id.sign_out:
                {
                  SharePreUtils.setString(Home.this, SharePreUtils.EMAIL, "");
                  SharePreUtils.setString(Home.this, SharePreUtils.PASSWORD, "");
                  SharePreUtils.setString(Home.this, SharePreUtils.FULL_NAME, "");
                  SharePreUtils.setString(Home.this, SharePreUtils.USER_ID, "");

                  Intent intent = new Intent(Home.this, MainActivity.class);
                  startActivity(intent);
                  finish();
                  break;
                }
            }
            return false;
          }
        });
    popup.show();
  }
 @Override
 public void show() {
   final Menu menu = getMenu();
   final MenuItem clearFrequents = menu.findItem(R.id.menu_clear_frequents);
   clearFrequents.setVisible(mPhoneFavoriteFragment.hasFrequents());
   super.show();
 }
  @Override
  public boolean onItemLongClick(
      final AdapterView<?> parent, final View view, final int position, final long id) {
    if (parent == mLvDebug) {
      final IITC_LogAdapter adapter = ((IITC_LogAdapter) parent.getAdapter());
      final Log.Message item = adapter.getItem(position);

      final PopupMenu popupMenu = new PopupMenu(this, view);
      popupMenu.getMenuInflater().inflate(R.menu.debug, popupMenu.getMenu());

      popupMenu.setOnMenuItemClickListener(
          new PopupMenu.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(final MenuItem menuitem) {
              switch (menuitem.getItemId()) {
                case R.id.menu_copy:
                  mIitcWebView.getJSInterface().copy(item.toString());
                  return true;
                case R.id.menu_delete:
                  adapter.remove(item);
                  return true;
              }
              return false;
            }
          });

      popupMenu.show();
    }
    return false;
  }
  private void openMenu(View menu) {

    PopupMenu popup = new PopupMenu(getActivity(), menu);

    // Inflating the Popup using xml file
    popup.getMenuInflater().inflate(R.menu.example_menu, popup.getMenu());

    // registering popup with OnMenuItemClickListener
    popup.setOnMenuItemClickListener(
        new PopupMenu.OnMenuItemClickListener() {
          public boolean onMenuItemClick(MenuItem item) {

            switch (item.getItemId()) {
              case R.id.sort:
                break;
              case R.id.favourite:
                break;
              case R.id.refresh:
                break;
              default:
                break;
            }
            return true;
          }
        });
    popup.show(); // showing popup menu
  }
Beispiel #8
0
        @Override
        public void onClick(final View v) {
          final ViewHolder viewHolder = (ViewHolder) v.getTag();

          final PlaylistType.Item playListItem = new PlaylistType.Item();
          playListItem.artistid = viewHolder.artistId;

          final PopupMenu popupMenu = new PopupMenu(getActivity(), v);
          popupMenu.getMenuInflater().inflate(R.menu.musiclist_item, popupMenu.getMenu());
          popupMenu.setOnMenuItemClickListener(
              new PopupMenu.OnMenuItemClickListener() {
                @Override
                public boolean onMenuItemClick(MenuItem item) {
                  switch (item.getItemId()) {
                    case R.id.action_play:
                      MediaPlayerUtils.play(ArtistListFragment.this, playListItem);
                      return true;
                    case R.id.action_queue:
                      MediaPlayerUtils.queueAudio(ArtistListFragment.this, playListItem);
                      return true;
                  }
                  return false;
                }
              });
          popupMenu.show();
        }
 private void showPopupMenu(View view, PopupMenu.OnMenuItemClickListener listener) {
   PopupMenu popup = new PopupMenu(mActivity, view);
   popup.setOnMenuItemClickListener(listener);
   MenuInflater inflater = popup.getMenuInflater();
   inflater.inflate(R.menu.card_score_list, popup.getMenu());
   popup.show();
 }
  public void showPopupOfLessonItem(View v, int position) {
    final int index = position;
    PopupMenu popup = new PopupMenu(Home.this, v);
    popup.getMenuInflater().inflate(R.menu.list_lesson_menu, popup.getMenu());
    popup.setOnMenuItemClickListener(
        new PopupMenu.OnMenuItemClickListener() {

          @Override
          public boolean onMenuItemClick(MenuItem item) {
            // TODO Auto-generated method stub
            switch (item.getItemId()) {
              case R.id.show_lesson_detail:
                {
                  createDialog(Home.this, index);
                  break;
                }
              case R.id.delete_lesson:
                {
                  break;
                }
            }
            return false;
          }
        });
    popup.show();
  }
Beispiel #11
0
 @Override
 public void onClick(View v) {
   PopupMenu popup = new PopupMenu(v.getContext(), v);
   popup.inflate(R.menu.mnu);
   popup.setOnMenuItemClickListener(this);
   popup.show();
 }
  // 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();
  }
  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();
  }
Beispiel #14
0
  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();
  }
  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();
  }
Beispiel #16
0
  /**
   * Shows "call via" menu allowing user to selected from multiple providers.
   *
   * @param context the android context
   * @param v the View that will contain the popup menu.
   * @param destination target callee name.
   */
  private static void showCallViaMenu(final Context context, View v, final String destination) {
    PopupMenu popup = new PopupMenu(context, v);

    Menu menu = popup.getMenu();

    Iterator<ProtocolProviderService> registeredProviders =
        AccountUtils.getRegisteredProviders().iterator();

    while (registeredProviders.hasNext()) {
      final ProtocolProviderService provider = registeredProviders.next();
      String accountAddress = provider.getAccountID().getAccountAddress();

      MenuItem menuItem = menu.add(Menu.NONE, Menu.NONE, Menu.NONE, accountAddress);

      menuItem.setOnMenuItemClickListener(
          new MenuItem.OnMenuItemClickListener() {
            public boolean onMenuItemClick(MenuItem item) {
              createCall(context, destination, provider);

              return false;
            }
          });
    }

    popup.show();
  }
Beispiel #17
0
  @Override
  public boolean onLongClick(View v) {
    switch (v.getId()) {
      case R.id.questionimage:
        if (null != bitmap) {
          PopupMenu popupMenu = new PopupMenu(this, image);
          popupMenu.getMenuInflater().inflate(R.menu.popupmenu_deleteimage, popupMenu.getMenu());
          popupMenu.setOnMenuItemClickListener(
              new PopupMenu.OnMenuItemClickListener() {
                @Override
                public boolean onMenuItemClick(MenuItem item) {
                  switch (item.getItemId()) {
                    case R.id.deleteimage:
                      bitmap.recycle();
                      bitmap = null;
                      image.setScaleType(ImageView.ScaleType.CENTER);
                      image.setImageDrawable(
                          getResources().getDrawable(R.mipmap.img_questionimage));
                      hint.setText(getString(R.string.question_addimage_hint));
                      return true;
                  }
                  return false;
                }
              });
          popupMenu.show();
        }

        break;
    }
    return false;
  }
 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();
 }
  private void showPopupMenu(View view) {
    // Create a PopupMenu, giving it the clicked view for an anchor
    PopupMenu popup = new PopupMenu(adapter.getFragment().getActivity(), view);

    // Inflate our menu resource into the PopupMenu's Menu
    popup.getMenuInflater().inflate(R.menu.chapter_single, popup.getMenu());

    // Set a listener so we are notified if a menu item is clicked
    popup.setOnMenuItemClickListener(
        menuItem -> {
          Observable<Chapter> chapter = Observable.just(item);

          switch (menuItem.getItemId()) {
            case R.id.action_mark_as_read:
              return adapter.getFragment().onMarkAsRead(chapter);
            case R.id.action_mark_as_unread:
              return adapter.getFragment().onMarkAsUnread(chapter);
            case R.id.action_download:
              return adapter.getFragment().onDownload(chapter);
            case R.id.action_delete:
              return adapter.getFragment().onDelete(chapter);
            case R.id.action_mark_previous_as_read:
              return adapter.getFragment().onMarkPreviousAsRead(item);
          }
          return false;
        });

    // Finally show the PopupMenu
    popup.show();
  }
 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();
 }
Beispiel #21
0
 @Override
 public boolean onRecyclerItemLongClick(
     RecyclerView recyclerView, View view, int position, long id, int viewHolderLayoutID) {
   switch (viewHolderLayoutID) {
     case R.layout.reportlist_item:
       PopupMenu popUpMenu = new PopupMenu(this, view);
       Menu menu = popUpMenu.getMenu();
       popUpMenu.getMenuInflater().inflate(R.menu.context_fragment_report_selection, menu);
       for (int i = 0; i < menu.size(); i++) {
         Intent intent = new Intent();
         intent.putExtra(ID, id);
         menu.getItem(i).setIntent(intent);
       }
       popUpMenu.setOnMenuItemClickListener(this);
       popUpMenu.show();
       return true;
     case R.layout.finanzuebersicht_item:
       DialogFragmentKontoEdit d =
           DialogFragmentKontoEdit.newInstance(DBDefinition.Account, id, MainAction.EDIT);
       d.show(getSupportFragmentManager(), null);
       return true;
     case R.layout.depotuebersicht_item:
       Intent intent = new Intent(this, ActivityWertpapiere.class);
       intent.putExtra(ACCOUNTID, (int) id);
       intent.putExtra(ACTION, (Parcelable) Action.ShowBuchungen);
       startActivity(intent);
       return true;
     case R.layout.hbcipassport_item:
       final long mID = id;
       AlertDialog.Builder builder = new AlertDialog.Builder(this);
       builder.setTitle(R.string.HBCIZugangDelete);
       builder.setMessage(R.string.HBCIZugangDeleteMsg);
       builder.setPositiveButton(
           getString(R.string.awlib_btnAccept),
           new DialogInterface.OnClickListener() {
             @Override
             public void onClick(DialogInterface dialog, int which) {
               try {
                 MonMaPassport passport = new MonMaPassport(mID);
                 passport.delete(DBHelper.getInstance());
               } catch (GeschaeftsObjekt.LineNotFoundException e) {
                 // TODO Execption bearbeiten
                 e.printStackTrace();
               }
             }
           });
       builder.setNegativeButton(
           getString(R.string.awlib_btnCancel),
           new DialogInterface.OnClickListener() {
             @Override
             public void onClick(DialogInterface dialog, int which) {}
           });
       builder.create().show();
       return true;
     default:
       return false;
   }
 }
Beispiel #22
0
 protected void showAttachMenu(final View v) {
   if (this.attachment == null) {
     askChoosePicture();
   } else {
     final PopupMenu popupMenu = new PopupMenu(this, v);
     popupMenu.getMenuInflater().inflate(R.menu.attachmenu, popupMenu.getMenu());
     popupMenu.setOnMenuItemClickListener(this.attachMenuClickListener);
     popupMenu.show();
   }
 }
Beispiel #23
0
    @Override
    protected void onFinishInflate() {
      super.onFinishInflate();

      bChangeBook = V.get(this, R.id.bChangeBook);
      bChangeCode = V.get(this, R.id.bChangeCode);

      bOk = V.get(this, R.id.bOk);
      bDigitA = V.get(this, R.id.bDigitA);
      bDigitB = V.get(this, R.id.bDigitB);
      bDigitC = V.get(this, R.id.bDigitC);

      bChangeBook.setOnClickListener(
          v -> {
            final PopupMenu popupChangeBook =
                SongBookUtil.getSongBookPopupMenu(activity, false, true, bChangeBook);
            popupChangeBook.setOnMenuItemClickListener(
                SongBookUtil.getSongBookOnMenuItemClickListener(
                    new SongBookUtil.DefaultOnSongBookSelectedListener() {
                      @Override
                      public void onSongBookSelected(final String name) {
                        listener.songBookSelected(name);
                      }

                      @Override
                      public void onMoreSelected() {
                        listener.moreSelected();
                      }
                    }));

            popupChangeBook.show();
          });

      // all buttons
      for (int buttonId :
          new int[] {
            R.id.bDigit0,
            R.id.bDigit1,
            R.id.bDigit2,
            R.id.bDigit3,
            R.id.bDigit4,
            R.id.bDigit5,
            R.id.bDigit6,
            R.id.bDigit7,
            R.id.bDigit8,
            R.id.bDigit9,
            R.id.bDigitA,
            R.id.bDigitB,
            R.id.bDigitC,
            R.id.bOk,
            R.id.bBackspace,
          }) {
        V.get(this, buttonId).setOnClickListener(button_click);
      }
    }
  public boolean showPopupMenu(View view) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
      return false;
    }

    PopupMenu popup = new PopupMenu(this, view);
    MenuInflater inflater = popup.getMenuInflater();
    inflater.inflate(R.menu.popup_menu, popup.getMenu());
    popup.show();
    return true;
  }
 @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();
 }
  @Override
  public void onClick(View view) {
    if (!isMessageOpen()) {
      return; // Ignore.
    }
    switch (view.getId()) {
      case R.id.reply:
        mCallback.onReply();
        return;
      case R.id.reply_all:
        mCallback.onReplyAll();
        return;
      case R.id.forward:
        mCallback.onForward();
        return;

      case R.id.favorite:
        onClickFavorite();
        return;

      case R.id.invite_link:
        onInviteLinkClicked();
        return;

      case R.id.accept:
        onRespondToInvite(
            EmailServiceConstants.MEETING_REQUEST_ACCEPTED, R.string.message_view_invite_toast_yes);
        return;
      case R.id.maybe:
        onRespondToInvite(
            EmailServiceConstants.MEETING_REQUEST_TENTATIVE,
            R.string.message_view_invite_toast_maybe);
        return;
      case R.id.decline:
        onRespondToInvite(
            EmailServiceConstants.MEETING_REQUEST_DECLINED, R.string.message_view_invite_toast_no);
        return;

      case R.id.more:
        {
          PopupMenu popup = new PopupMenu(getActivity(), mMoreButton);
          Menu menu = popup.getMenu();
          popup.getMenuInflater().inflate(R.menu.message_header_overflow_menu, menu);

          // Remove Reply if ReplyAll icon is visible or vice versa
          menu.removeItem(mDefaultReplyAll ? R.id.reply_all : R.id.reply);
          popup.setOnMenuItemClickListener(this);
          popup.show();
          break;
        }
    }
    super.onClick(view);
  }
 @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();
 }
Beispiel #28
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();
 }
Beispiel #29
0
  // Overridden Methods
  void showItemMenu(View v, String name, ArrayList<SimpleMenuItem> menuItems) {
    PopupMenu popupMenu = new PopupMenu(v11.this, v);
    popupMenu.getMenu().clear();

    for (int i = 0; i < menuItems.size(); i++)
      popupMenu
          .getMenu()
          .add(
              0, menuItems.get(i).getItemId(),
              0, menuItems.get(i).getTitle());

    popupMenu.getMenu().findItem(R.id.status).setVisible(syncers.get(name) != null);

    popupMenu.setOnMenuItemClickListener(v11.this);
    popupMenu.show();
  }
Beispiel #30
0
  @Override
  public void onMoreClicked(View view, final Item item) {
    PopupMenu menu = new PopupMenu(getActivity(), view);
    menu.getMenuInflater().inflate(R.menu.popup_item, menu.getMenu());
    menu.getMenu().findItem(R.id.favorite).setTitle("Remove from favorites");
    menu.getMenu()
        .findItem(R.id.calculator)
        .setEnabled(!Utility.isInCalculator(getActivity(), item));
    menu.setOnMenuItemClickListener(
        new PopupMenu.OnMenuItemClickListener() {
          @Override
          public boolean onMenuItemClick(MenuItem menuItem) {
            switch (menuItem.getItemId()) {
              case R.id.history:
                Intent i = new Intent(getActivity(), PriceHistoryActivity.class);
                i.putExtra(PriceHistoryActivity.EXTRA_ITEM, item);
                startActivity(i);
                break;
              case R.id.favorite:
                Utility.removeFromFavorites(getActivity(), item);
                mAdapter.removeItem(item);
                break;
              case R.id.calculator:
                Utility.addToCalculator(getActivity(), item);
                menuItem.setEnabled(false);
                break;
              case R.id.backpack_tf:
                CustomTabActivityHelper.openCustomTab(
                    getActivity(),
                    new CustomTabsIntent.Builder().build(),
                    Uri.parse(item.getBackpackTfUrl()),
                    new WebViewFallback());
                break;
              case R.id.wiki:
                CustomTabActivityHelper.openCustomTab(
                    getActivity(),
                    new CustomTabsIntent.Builder().build(),
                    Uri.parse(item.getTf2WikiUrl()),
                    new WebViewFallback());
                break;
            }
            return true;
          }
        });

    menu.show();
  }