android.widget.PopupMenu Java Examples

The following examples show how to use android.widget.PopupMenu. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FloatingActionMode.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public FloatingActionMode(Context context, ActionMode.Callback2 callback, View originatingView, FloatingToolbar floatingToolbar) {
    mContext = context;
    mCallback = callback;

    PopupMenu p = new PopupMenu(context, null);
    mMenu = p.getMenu();
    setType(ActionMode.TYPE_FLOATING);
    p.setOnMenuItemClickListener(menuItem -> mCallback.onActionItemClicked(FloatingActionMode.this, menuItem));
    mContentRect = new Rect();
    mContentRectOnScreen = new Rect();
    mPreviousContentRectOnScreen = new Rect();
    mViewPositionOnScreen = new int[2];
    mPreviousViewPositionOnScreen = new int[2];
    mRootViewPositionOnScreen = new int[2];
    mViewRectOnScreen = new Rect();
    mPreviousViewRectOnScreen = new Rect();
    mScreenRect = new Rect();
    mOriginatingView = originatingView;
    mOriginatingView.getLocationOnScreen(mViewPositionOnScreen);
    mBottomAllowance = AndroidUtilities.dp(20);
    mDisplaySize = new Point();
    setFloatingToolbar(floatingToolbar);
}
 
Example #2
Source File: AdapterViewUsersList.java    From stockita-point-of-sale with MIT License 6 votes vote down vote up
@Override
protected void onFinishInflate() {
    super.onFinishInflate();

    // Initialize the PopupMenu object, and pass the View object in the second argument
    mPopupMenu = new PopupMenu(getContext(), mPopupMenuViewObject);

    // Get the menu inflater to inflate the xml file
    mPopupMenu.getMenuInflater().inflate(R.menu.popup_menu_adapter_view_item_list, mPopupMenu.getMenu());

    /**
     * Now we need to add a click listener on the view object, so when the user click
     * this view object the menu will popup, this can be done using show() method.
     */
    mPopupMenuViewObject.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {

            // Invoke show() to popup the menu.
            mPopupMenu.show();
        }
    });
}
 
Example #3
Source File: ActivityGlobalAbstract.java    From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void showMoreOptions(View view) {
    PopupMenu popupMenu = new PopupMenu(this, view, Gravity.BOTTOM);
    try {
        Field[] fields = popupMenu.getClass().getDeclaredFields();
        for (Field field : fields) {
            if ("mPopup".equals(field.getName())) {
                field.setAccessible(true);
                Object menuPopupHelper = field.get(popupMenu);
                Class<?> classPopupHelper = Class.forName(menuPopupHelper.getClass().getName());
                Method setForceIcons = classPopupHelper.getMethod("setForceShowIcon", boolean.class);
                setForceIcons.invoke(menuPopupHelper, true);
                break;
            }
        }
    } catch (Exception e) {
        Timber.e(e);
    }
    popupMenu.getMenuInflater().inflate(R.menu.home_menu, popupMenu.getMenu());
    popupMenu.setOnMenuItemClickListener(item -> {
        analyticsHelper.setEvent(SHOW_HELP, CLICK, SHOW_HELP);
        showTutorial(false);
        return false;
    });
    popupMenu.show();
}
 
Example #4
Source File: DialtactsActivity.java    From coursera-android with MIT License 6 votes vote down vote up
@Override
public void onClick(View view) {
    switch (view.getId()) {
        case R.id.searchButton: {
            enterSearchUi();
            break;
        }
        case R.id.overflow_menu: {
            if (mDialpadFragment != null) {
                PopupMenu popup = mDialpadFragment.constructPopupMenu(view);
                if (popup != null) {
                    popup.show();
                }
            } else {
                Log.w(TAG, "DialpadFragment is null during onClick() event for " + view);
            }
            break;
        }
        default: {
            Log.wtf(TAG, "Unexpected onClick event from " + view);
            break;
        }
    }
}
 
Example #5
Source File: SelectSourceDialog.java    From a with GNU General Public License v3.0 6 votes vote down vote up
public void upGroupMenu() {

        List<String> groupList = BookSourceManager.getGroupList();
        if (groupList.size() == 0) {
            IbGroups.setVisibility(View.INVISIBLE);
        }else{
            IbGroups.setVisibility(View.VISIBLE);

            //创建弹出式菜单对象(最低版本11)
            popup = new PopupMenu(this.context, IbGroups);//第二个参数是绑定的那个view
            for (String groupName : new ArrayList<>(groupList)) {
                popup.getMenu().add(groupName);
            }

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

                    searchView.setQuery(item.getTitle(), true);
                    return false;
                }
            });


        }
    }
 
Example #6
Source File: TVShowEpisodeListFragment.java    From Kore with Apache License 2.0 6 votes vote down vote up
@Override
public void onClick(final View v) {
    final ViewHolder viewHolder = (ViewHolder)v.getTag();

    final PlaylistType.Item playListItem = new PlaylistType.Item();
    playListItem.episodeid = viewHolder.dataHolder.getId();

    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(TVShowEpisodeListFragment.this, playListItem);
                    return true;
                case R.id.action_queue:
                    MediaPlayerUtils.queue(TVShowEpisodeListFragment.this, playListItem, PlaylistType.GetPlaylistsReturnType.VIDEO);
                    return true;
            }
            return false;
        }
    });
    popupMenu.show();
}
 
Example #7
Source File: GaugePanel.java    From trekarta with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onLongClick(View v) {
    Context context = getContext();
    PopupMenu popup = new PopupMenu(context, v);
    Menu menu = popup.getMenu();
    int type = 0;
    if (v instanceof Gauge) {
        Gauge gauge = (Gauge) v;
        menu.add(0, gauge.getType(), Menu.NONE, context.getString(R.string.remove_gauge, getGaugeName(gauge.getType())));
        gauge.getType();
    }
    ArrayList<Integer> availableGauges = getAvailableGauges(type);
    for (int availableGauge : availableGauges) {
        menu.add(0, availableGauge, Menu.NONE, context.getString(R.string.add_gauge, getGaugeName(availableGauge)));
    }
    popup.setOnMenuItemClickListener(this);
    popup.show();
    return true;
}
 
Example #8
Source File: OrgUnitCascadeHolder.java    From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void setMenu(List<Trio<String, String, Boolean>> data) {
    menu = new PopupMenu(binding.levelText.getContext(), binding.levelText, Gravity.BOTTOM);

    for (Trio<String, String, Boolean> ou : data)
        menu.getMenu().add(Menu.NONE, Menu.NONE, data.indexOf(ou), ou.val1());

    menu.setOnMenuItemClickListener(item -> {
        selectedOrgUnit = item.getOrder() < 0 ? null : ouItem.getLevelOrgUnits().get(item.getOrder()).val0();
        binding.levelText.setText(item.getOrder() < 0 ? data.get(0).val1() : data.get(item.getOrder()).val1());
        ouItem.setName(item.getOrder() < 0 ? data.get(0).val1() : data.get(item.getOrder()).val1());
        ouItem.setUid(item.getOrder() < 0 ? data.get(0).val0() : data.get(item.getOrder()).val0());
        adapter.setSelectedLevel(
                getAdapterPosition() + 1,
                selectedOrgUnit,
                selectionType == OrgUnitCascadeDialog.OUSelectionType.SEARCH ?
                        ouRepository.uid(selectedOrgUnit).blockingExists():
                        ouRepository.byOrganisationUnitScope(OrganisationUnit.Scope.SCOPE_DATA_CAPTURE).uid(selectedOrgUnit).blockingExists()
                );
        return false;
    });
}
 
Example #9
Source File: PlayerActivity.java    From Exoplayer_VLC with Apache License 2.0 6 votes vote down vote up
public void showVerboseLogPopup(View v) {
  PopupMenu popup = new PopupMenu(this, v);
  Menu menu = popup.getMenu();
  menu.add(Menu.NONE, 0, Menu.NONE, R.string.logging_normal);
  menu.add(Menu.NONE, 1, Menu.NONE, R.string.logging_verbose);
  menu.setGroupCheckable(Menu.NONE, true, true);
  menu.findItem((VerboseLogUtil.areAllTagsEnabled()) ? 1 : 0).setChecked(true);
  popup.setOnMenuItemClickListener(new OnMenuItemClickListener() {
    @Override
    public boolean onMenuItemClick(MenuItem item) {
      if (item.getItemId() == 0) {
        VerboseLogUtil.setEnableAllTags(false);
      } else {
        VerboseLogUtil.setEnableAllTags(true);
      }
      return true;
    }
  });
  popup.show();
}
 
Example #10
Source File: SourceListActivity.java    From scanvine-android with MIT License 6 votes vote down vote up
public void openSectionPopup() {
       final String[] sections = {"All","World","Tech","Business","Entertainment","Sports","Life"};
       PopupMenu popupMenu = new PopupMenu(this, findViewById(R.id.action_section));
       Menu menu = popupMenu.getMenu();
       for (int i=0; i<sections.length; i++) {
       	boolean addCheck = currentSection!=null &&
       					   (currentSection.equalsIgnoreCase(sections[i]) ||
       					   currentSection.length()==0 && "All".equalsIgnoreCase(sections[i]));
       	menu.add(Menu.NONE, i, Menu.NONE, addCheck ? sections[i]+"✓" : sections[i]);
       }
       popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() {
       	@Override
		public boolean onMenuItemClick(MenuItem item) {
       		currentSection = item.getItemId()==0 ? null : (""+item.getTitle()).replace("✓","");
       		SourceListFragment slf = (SourceListFragment) getSupportFragmentManager().findFragmentById(R.id.source_list);
       		slf.refreshList(currentSection);
       		return false;
       	}
       });
       popupMenu.show();
}
 
Example #11
Source File: DetailedActivity.java    From 1Rramp-Android with MIT License 6 votes vote down vote up
private void showPopup() {
  int menu_res_id = R.menu.popup_post;
  String currentLoggedInUser = HaprampPreferenceManager.getInstance().getCurrentSteemUsername();
  ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(this, R.style.PopupMenuOverlapAnchor);
  PopupMenu popup = new PopupMenu(contextThemeWrapper, overflowBtn);
  //customize menu items
  //add Share
  popup.getMenu().add(PostMenu.Share);
  popup.getMenu().add(PostMenu.Repost);
  popup.getMenuInflater().inflate(menu_res_id, popup.getMenu());
  popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
    @Override
    public boolean onMenuItemClick(MenuItem item) {
      if (item.getTitle().equals(PostMenu.Share)) {
        ShareUtils.shareMixedContent(DetailedActivity.this, post);
        return true;
      } else if (item.getTitle().equals(PostMenu.Repost)) {
        showAlertDialogForRepost();
      }
      return false;
    }
  });
  popup.show();
}
 
Example #12
Source File: SmsTemplateListAsyncAdapter.java    From financisto with GNU General Public License v2.0 6 votes vote down vote up
@Override
public LocalViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View view = LayoutInflater.from(context).inflate(R.layout.generic_list_item, parent, false);
    view.setOnClickListener(clickedView -> {
        final PopupMenu popupMenu = new PopupMenu(context, clickedView);
        int i = 0;
        for (MenuItemInfo m : createContextMenus()) {
            if (m.enabled) {
                popupMenu.getMenu().add(0, m.menuId, i++, m.titleId);
            }
        }
        popupMenu.setOnMenuItemClickListener(item -> onItemAction(item.getItemId(), clickedView));
        popupMenu.show();
    });
    return new LocalViewHolder(view);
}
 
Example #13
Source File: WordDetailsActivity.java    From allenglish with Apache License 2.0 6 votes vote down vote up
private void showFilterPopup(View v) {
        PopupMenu popup = new PopupMenu(this, v);
        // Inflate the menu from xml
        popup.getMenuInflater().inflate(R.menu.popup_filter, popup.getMenu());
        // Setup menu item selection
        popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
            public boolean onMenuItemClick(MenuItem item) {
                switch (item.getItemId()) {
                    case R.id.copy:
                        StringUtils.copyToClipboard(mContext, mWord.getText().toString());
                        return true;
//                    case R.id.open_bookmark:
//                        Intent intent = new Intent(mContext, BookmarkActivity.class);
//                        startActivity(intent);
//                        return true;
                    default:
                        return false;
                }
            }
        });
        // Handle dismissal with: popup.setOnDismissListener(...);
        // Show the menu
        popup.show();
    }
 
Example #14
Source File: PlayerActivity.java    From Android-Example-HLS-ExoPlayer with Apache License 2.0 6 votes vote down vote up
public void showVerboseLogPopup(View v) {
    PopupMenu popup = new PopupMenu(this, v);
    Menu menu = popup.getMenu();
    menu.add(Menu.NONE, 0, Menu.NONE, R.string.logging_normal);
    menu.add(Menu.NONE, 1, Menu.NONE, R.string.logging_verbose);
    menu.setGroupCheckable(Menu.NONE, true, true);
    menu.findItem((VerboseLogUtil.areAllTagsEnabled()) ? 1 : 0).setChecked(true);
    popup.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            if (item.getItemId() == 0) {
                VerboseLogUtil.setEnableAllTags(false);
            } else {
                VerboseLogUtil.setEnableAllTags(true);
            }
            return true;
        }
    });
    popup.show();
}
 
Example #15
Source File: MainActivity.java    From android-kubernetes-blockchain with Apache License 2.0 6 votes vote down vote up
public void showPopup(View v) {
    PopupMenu popupMenu = new PopupMenu(this, v);
    MenuInflater inflater = popupMenu.getMenuInflater();
    inflater.inflate(R.menu.privacy, popupMenu.getMenu());
    popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem menuItem) {
            if (menuItem.getItemId() == R.id.menu_privacy) {
                Uri uri = Uri.parse("https://github.com/AnthonyAmanse/fitcoin-android/blob/master/Privacy.md");
                Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                startActivity(intent);
                return true;
            }
            return false;
        }
    });
    popupMenu.show();
}
 
Example #16
Source File: YokeActivity.java    From yoke-android with MIT License 6 votes vote down vote up
public void showOverflowMenu(View view) {
    PopupMenu popup = new PopupMenu(this, view);
    popup.inflate(R.menu.overflow);
    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
                case R.id.upgradeLayout:
                    if (currentHost != null) {
                        new DownloadFilesFromURL().execute(
                            "http://" + currentHost + ":" + Integer.toString(currentPort) + "/"
                        );
                    } else {
                        Toast.makeText(YokeActivity.this,
                            res.getString(R.string.toast_connected_to_nowhere), Toast.LENGTH_LONG
                        ).show();
                    }
                    return true;
                default:
                    return false;
            }
        }
    });
    popup.show();
}
 
Example #17
Source File: MainActivity.java    From itag with GNU General Public License v3.0 6 votes vote down vote up
public void onAppMenu(@NonNull View sender) {
    final PopupMenu popupMenu = new PopupMenu(this, sender);
    popupMenu.inflate(R.menu.app);
    popupMenu.setOnMenuItemClickListener(item -> {
        //noinspection SwitchStatementWithTooFewBranches
        switch (item.getItemId()) {
            case R.id.exit:
                ITag.close();
                Waytoday.stop();
                ITagsService.stop(this);
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                    finishAndRemoveTask();
                } else {
                    finishAffinity();
                }
                new Handler(getMainLooper()).postDelayed(() -> System.exit(0), 5000);
                break;
        }
        return true;
    });
    popupMenu.show();
}
 
Example #18
Source File: MainActivity.java    From triviums with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    initBinding();

    //load the category fragment by default
    binding.title.setText(R.string.categories);
    loadFragment(new CategoryFragment());

    binding.menuBtn.setOnClickListener(view -> {
        PopupMenu popupMenu = new PopupMenu(MainActivity.this, view);
        popupMenu.setOnMenuItemClickListener(MainActivity.this);
        popupMenu.inflate(R.menu.menu);
        popupMenu.show();
    });
}
 
Example #19
Source File: menuV4.java    From ui with Apache License 2.0 6 votes vote down vote up
@SuppressLint("NewApi")
private void showPopupMenu(View v){
	//the popupMenu didn't exist in android 2.3.3 and below, so we are checking to see what version of android
	//this is running on and then running only code we can.
	if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.HONEYCOMB) {  //should kept this demo from force closing if run on the wrong API... I think...
		PopupMenu popupM = new PopupMenu(this, v);
		popupM.inflate(R.menu.popup);
		popupM.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

			@Override
			public boolean onMenuItemClick(MenuItem item) {
				Toast.makeText(getApplicationContext(), item.toString(),Toast.LENGTH_LONG).show();
				label1.append("\n you clicked "+item.toString());
				return true;
			}
		});

		popupM.show();
	}
}
 
Example #20
Source File: DataSourceList.java    From trekarta with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    mNativeTracks = getArguments().getBoolean(ARG_NATIVE_TRACKS);

    if (mNativeTracks) {
        TextView emptyView = (TextView) getListView().getEmptyView();
        if (emptyView != null)
            emptyView.setText(R.string.msgEmptyTrackList);
    }

    mAdapter = new DataSourceListAdapter(getActivity());
    setListAdapter(mAdapter);
    getListView().setOnItemLongClickListener((parent, view, position, id) -> {
        final DataSource dataSource = mAdapter.getItem(position);
        PopupMenu popup = new PopupMenu(getContext(), view);
        popup.inflate(R.menu.context_menu_data_list);
        if (dataSource instanceof WaypointDbDataSource)
            popup.getMenu().findItem(R.id.action_delete).setVisible(false);
        popup.setOnMenuItemClickListener(item -> {
            switch (item.getItemId()) {
                case R.id.action_share:
                    mDataHolder.onDataSourceShare(dataSource);
                    return true;
                case R.id.action_delete:
                    mDataHolder.onDataSourceDelete(dataSource);
                    return true;
            }
            return false;
        });
        popup.show();
        return true;
    });
}
 
Example #21
Source File: HostListFragment.java    From Kore with Apache License 2.0 5 votes vote down vote up
@Override
public void onClick(View v) {
    final HostInfo hostInfo = (HostInfo)v.getTag();

    final PopupMenu popupMenu = new PopupMenu(getActivity(), v);
    popupMenu.getMenuInflater().inflate(R.menu.hostlist_item, popupMenu.getMenu());
    popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
                case R.id.action_remove_host:
                    DialogFragment confirmDelete = ConfirmDeleteDialogFragment
                            .getInstance(getDeleteDialogListener(hostInfo.getId()));
                    confirmDelete.show(getFragmentManager(), "confirmdelete");
                    return true;
                case R.id.action_edit_host:
                    Intent launchIntent = new Intent(getActivity(), EditHostActivity.class)
                            .addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
                            .putExtra(HostFragmentManualConfiguration.HOST_ID, hostInfo.getId());
                    startActivity(launchIntent);
                    getActivity().overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
                    return true;
                case R.id.action_wake_up:
                    // Send WoL magic packet on a new thread
                    UIUtils.sendWolAsync(getActivity(), hostInfo);
                    return true;
            }
            return false;
        }
    });
    popupMenu.show();
}
 
Example #22
Source File: BottomSheetDialogAdapter.java    From openwebnet-android with MIT License 5 votes vote down vote up
private void setupMenu() {
    // https://github.com/Flipboard/bottomsheet/blob/master/bottomsheet-commons/src/main/java/com/flipboard/bottomsheet/commons/MenuSheetView.java
    // dirty hack to get a menu instance since MenuBuilder isn't public
    this.mMenu = new PopupMenu(mContext, null).getMenu();

    MenuInflater inflater = new MenuInflater(mContext);
    inflater.inflate(R.menu.menu_bottom_sheet, mMenu);
}
 
Example #23
Source File: AvatarEditorActivity.java    From BotLibre with Eclipse Public License 1.0 5 votes vote down vote up
public void menu(View view) {
	PopupMenu popup = new PopupMenu(this, view);
    MenuInflater inflater = popup.getMenuInflater();
    inflater.inflate(R.menu.menu_avatar_editor, popup.getMenu());
    onPrepareOptionsMenu(popup.getMenu());
    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            return onOptionsItemSelected(item);
        }
    });
    popup.show();
}
 
Example #24
Source File: ConnectionsFragment.java    From FireFiles with Apache License 2.0 5 votes vote down vote up
private void showPopupMenu(View view, final int position) {
    PopupMenu popup = new PopupMenu(getActivity(), view);

    popup.getMenuInflater().inflate(R.menu.popup_connections, popup.getMenu());
    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem menuItem) {
            return onPopupMenuItemClick(menuItem, position);
        }
    });
    popup.show();
}
 
Example #25
Source File: SongMenuHelper.java    From RetroMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onClick(View v) {
    PopupMenu popupMenu = new PopupMenu(activity, v);
    popupMenu.inflate(getMenuRes());
    popupMenu.setOnMenuItemClickListener(this);
    popupMenu.show();
}
 
Example #26
Source File: ChatItemView.java    From meatspace-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void bind(final Chat chat) {
    if (chat != null) {

        Chat.Value value = chat.getValue();

        try {
            ByteArrayInputStream in = new ByteArrayInputStream(value.getMedia().getBytes());
            GifDrawable gifFromStream = new GifDrawable(in);
            gif.setImageDrawable(gifFromStream);
            gif.setVisibility(VISIBLE);
        } catch (Exception e) {
            Debug.out(e);
            gif.setVisibility(INVISIBLE);
        }

        Date date = new Date(value.getCreated());
        timestamp.setText(com.romainpiel.lib.utils.DateUtils.formatTime(getContext(), date));
        message.setText(value.getMessage());

        if (!chat.getValue().isFromMe()) {
            menuButton.setVisibility(VISIBLE);
            popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    if (item.getItemId() == R.id.menu_card_mute && onMuteClickListener != null) {
                        onMuteClickListener.onMenuClick(chat);
                    }
                    return true;
                }
            });
        } else {
            menuButton.setVisibility(INVISIBLE);
        }
    }
}
 
Example #27
Source File: MainActivity.java    From fastnfitness with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    final MenuItem alertMenuItem = menu.findItem(R.id.action_profil);

    roundProfile.setOnClickListener(v -> {
        PopupMenu popup = new PopupMenu(getActivity(), v);
        MenuInflater inflater = popup.getMenuInflater();
        inflater.inflate(R.menu.profile_actions, popup.getMenu());
        popup.setOnMenuItemClickListener(onMenuItemClick);
        popup.show();
    });

    return super.onPrepareOptionsMenu(menu);
}
 
Example #28
Source File: NativeViewHierarchyManager.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Override
public void onDismiss(PopupMenu menu) {
  if (!mConsumed) {
    mSuccess.invoke(UIManagerModuleConstants.ACTION_DISMISSED);
    mConsumed = true;
  }
}
 
Example #29
Source File: BotActivity.java    From BotLibre with Eclipse Public License 1.0 5 votes vote down vote up
public void menu(View view) {
	PopupMenu popup = new PopupMenu(this, view);
    MenuInflater inflater = popup.getMenuInflater();
    inflater.inflate(R.layout.menu_bot, popup.getMenu());
    onPrepareOptionsMenu(popup.getMenu());
    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            return onOptionsItemSelected(item);
        }
    });
    popup.show();
}
 
Example #30
Source File: BotActivity.java    From BotLibre with Eclipse Public License 1.0 5 votes vote down vote up
public void menu(View view) {
	PopupMenu popup = new PopupMenu(this, view);
    MenuInflater inflater = popup.getMenuInflater();
    inflater.inflate(R.menu.menu_bot, popup.getMenu());
    onPrepareOptionsMenu(popup.getMenu());
    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            return onOptionsItemSelected(item);
        }
    });
    popup.show();
}