Java Code Examples for android.widget.PopupMenu#getMenuInflater()

The following examples show how to use android.widget.PopupMenu#getMenuInflater() . 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: IssueEditorActivity.java    From BotLibre with Eclipse Public License 1.0 7 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_edit_issue, popup.getMenu());
	onPrepareOptionsMenu(popup.getMenu());
	popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
		@Override
		public boolean onMenuItemClick(MenuItem item) {
			return onOptionsItemSelected(item);
		}
	});
	popup.show();
}
 
Example 2
Source File: ForumPostActivity.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_post, popup.getMenu());
	onPrepareOptionsMenu(popup.getMenu());
	popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
		@Override
		public boolean onMenuItemClick(MenuItem item) {
			return onOptionsItemSelected(item);
		}
	});
	popup.show();
}
 
Example 3
Source File: MainActivity.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_main, popup.getMenu());
	onPrepareOptionsMenu(popup.getMenu());
	popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
		@Override
		public boolean onMenuItemClick(MenuItem item) {
			return onOptionsItemSelected(item);
		}
	});
	popup.show();
}
 
Example 4
Source File: TrainingActivity.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_training, popup.getMenu());
    onPrepareOptionsMenu(popup.getMenu());
    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            return onOptionsItemSelected(item);
        }
    });
    popup.show();
}
 
Example 5
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.layout.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 6
Source File: MainActivity.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_main, popup.getMenu());
	onPrepareOptionsMenu(popup.getMenu());
	popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
		@Override
		public boolean onMenuItemClick(MenuItem item) {
			return onOptionsItemSelected(item);
		}
	});
	popup.show();
}
 
Example 7
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 8
Source File: ForumSearchActivity.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_search_forum, popup.getMenu());
    onPrepareOptionsMenu(popup.getMenu());
    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            return onOptionsItemSelected(item);
        }
    });
    popup.show();
}
 
Example 9
Source File: ViewUserActivity.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_view_user, popup.getMenu());
    onPrepareOptionsMenu(popup.getMenu());
    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            return onOptionsItemSelected(item);
        }
    });
    popup.show();
}
 
Example 10
Source File: BrowseIssueActivity.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_browse_issue, popup.getMenu());
    onPrepareOptionsMenu(popup.getMenu());
    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            return onOptionsItemSelected(item);
        }
    });
    popup.show();
}
 
Example 11
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 12
Source File: MainActivity.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_main, popup.getMenu());
	onPrepareOptionsMenu(popup.getMenu());
	popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
		@Override
		public boolean onMenuItemClick(MenuItem item) {
			return onOptionsItemSelected(item);
		}
	});
	popup.show();
}
 
Example 13
Source File: ForumActivity.java    From BotLibre with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void menu(View view) {
	PopupMenu popup = new PopupMenu(this, view);
    MenuInflater inflater = popup.getMenuInflater();
    inflater.inflate(R.layout.menu_forum, popup.getMenu());
    onPrepareOptionsMenu(popup.getMenu());
    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            return onOptionsItemSelected(item);
        }
    });
    popup.show();
}
 
Example 14
Source File: BrowsePostActivity.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_browse_post, popup.getMenu());
    onPrepareOptionsMenu(popup.getMenu());
    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            return onOptionsItemSelected(item);
        }
    });
    popup.show();
}
 
Example 15
Source File: CardsFragment.java    From yandex-money-sdk-android with MIT License 5 votes vote down vote up
private void showPopup(@NonNull View v, View cardView, @Nullable ExternalCard card) {
    menu = new PopupMenu(getPaymentActivity(), v);
    MenuInflater inflater = menu.getMenuInflater();
    inflater.inflate(R.menu.ym_card_actions, menu.getMenu());
    menu.setOnMenuItemClickListener(new MenuItemClickListener(card, cardView));
    menu.show();
}
 
Example 16
Source File: BrowsePostActivity.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_browse_post, popup.getMenu());
    onPrepareOptionsMenu(popup.getMenu());
    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            return onOptionsItemSelected(item);
        }
    });
    popup.show();
}
 
Example 17
Source File: QueueRecyclerAdapter.java    From PainlessMusicPlayer with Apache License 2.0 5 votes vote down vote up
private void onMenuClick(@NonNull final View itemView, final int position) {
    final PopupMenu popup = new PopupMenu(itemView.getContext(), itemView);
    final Menu popupMenu = popup.getMenu();

    final MenuInflater inflater = popup.getMenuInflater();
    inflater.inflate(R.menu.list_item_media, popupMenu);

    final Media item = getItem(position);
    popup.setOnMenuItemClickListener(menuItem -> onMenuItemClick(menuItem, item));
    popup.show();
}
 
Example 18
Source File: MainActivity.java    From android-storage with Apache License 2.0 5 votes vote down vote up
private void showPathMenu() {
    PopupMenu popupmenu = new PopupMenu(this, mPathView);
    MenuInflater inflater = popupmenu.getMenuInflater();
    inflater.inflate(R.menu.path_menu, popupmenu.getMenu());

    popupmenu.getMenu().findItem(R.id.go_internal).setVisible(!mInternal);
    popupmenu.getMenu().findItem(R.id.go_external).setVisible(mInternal);

    popupmenu.show();

    popupmenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
                case R.id.go_up:
                    String previousPath = getPreviousPath();
                    mTreeSteps = 0;
                    showFiles(previousPath);
                    break;
                case R.id.go_internal:
                    showFiles(mStorage.getInternalFilesDirectory());
                    mInternal = true;
                    break;
                case R.id.go_external:
                    showFiles(mStorage.getExternalStorageDirectory());
                    mInternal = false;
                    break;
            }
            return true;
        }
    });
}
 
Example 19
Source File: WebMediumActivity.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_webmedium, popup.getMenu());
    onPrepareOptionsMenu(popup.getMenu());
    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            return onOptionsItemSelected(item);
        }
    });
    popup.show();
}
 
Example 20
Source File: RepoFilesFragment.java    From mvvm-template with GNU General Public License v3.0 4 votes vote down vote up
public void onMenuClicked(View v, @NonNull RepoFile item) {
        if (isRefreshing) return;

        boolean isOwner = repoDetailViewModel.isOwnerOrCollaborator();

        PopupMenu popup = new PopupMenu(getContext(), v);
        MenuInflater inflater = popup.getMenuInflater();
        inflater.inflate(R.menu.download_share_menu, popup.getMenu());
        popup.getMenu().findItem(R.id.download).setVisible(item.getType() == FilesType.file);
        boolean canOpen = canOpen(item);
        popup.getMenu().findItem(R.id.editFile).setVisible(isOwner && item.getType() == FilesType.file && canOpen);
        popup.getMenu().findItem(R.id.deleteFile).setVisible(isOwner && item.getType() == FilesType.file);
        popup.setOnMenuItemClickListener(item1 -> {
            switch (item1.getItemId()) {
                case R.id.share:
                    ActivityHelper.shareUrl(getContext(), item.getHtmlUrl());
                    break;
                case R.id.download:
                    if (ActivityHelper.checkAndRequestReadWritePermission(getActivity())) {
                        DownloadHelper.downloadFile(getContext().getApplicationContext(), item.getDownloadUrl());
                    }
                    break;
                case R.id.copy:
                    AppHelper.copyToClipboard(getContext(), !InputHelper.isEmpty(item.getHtmlUrl()) ? item.getHtmlUrl() : item.getUrl());
                    break;
                case R.id.editFile:
                    AlertUtils.showToastShortMessage(getContext(), "Coming soon...");
//                    if (PrefGetter.isProEnabled() || PrefGetter.isAllFeaturesUnlocked()) {
//                        if (canOpen) {
//                            EditRepoFileModel fileModel = new EditRepoFileModel(getPresenter().login, getPresenter().repoId,
//                                    item.getPath(), getPresenter().ref, item.getSha(), item.getDownloadUrl(), item.getName(), true);
//                            EditRepoFileActivity.Companion.startForResult(this, fileModel, isEnterprise());
//                        }
//                    } else {
//                        PremiumActivity.Companion.startActivity(getContext());
//                    }
                    break;
                case R.id.deleteFile:
                    AlertUtils.showToastShortMessage(getContext(), "Coming soon...");
//                    if (PrefGetter.isProEnabled() || PrefGetter.isAllFeaturesUnlocked()) {
//                        DeleteFileBottomSheetFragment.Companion.newInstance(position, item.getName())
//                                .show(getChildFragmentManager(), DeleteFileBottomSheetFragment.class.getSimpleName());
//                    } else {
//                        PremiumActivity.Companion.startActivity(getContext());
//                    }
                    break;
            }
            return true;
        });
        popup.show();
    }