@Override public void showFilteringPopUpMenu() { PopupMenu popup = new PopupMenu(getContext(), getActivity().findViewById(R.id.menu_filter)); popup.getMenuInflater().inflate(R.menu.filter_tasks, popup.getMenu()); popup.setOnMenuItemClickListener(item -> { switch (item.getItemId()) { case R.id.active: mPresenter.setFiltering(TasksFilterType.ACTIVE_TASKS); break; case R.id.completed: mPresenter.setFiltering(TasksFilterType.COMPLETED_TASKS); break; default: mPresenter.setFiltering(TasksFilterType.ALL_TASKS); break; } mPresenter.loadTasks(false); return true; }); popup.show(); }
public static void smoothScrollToUserSelectedPosition(final DiscreteScrollView scrollView, View anchor) { PopupMenu popupMenu = new PopupMenu(scrollView.getContext(), anchor); Menu menu = popupMenu.getMenu(); final RecyclerView.Adapter adapter = scrollView.getAdapter(); int itemCount = (adapter instanceof InfiniteScrollAdapter) ? ((InfiniteScrollAdapter) adapter).getRealItemCount() : adapter.getItemCount(); for (int i = 0; i < itemCount; i++) { menu.add(String.valueOf(i + 1)); } popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { int destination = Integer.parseInt(String.valueOf(item.getTitle())) - 1; if (adapter instanceof InfiniteScrollAdapter) { destination = ((InfiniteScrollAdapter) adapter).getClosestPosition(destination); } scrollView.smoothScrollToPosition(destination); return true; } }); popupMenu.show(); }
public static void popupMenu(final Activity context, View v,final int position) { rootview = v; final PopupMenu popup = new PopupMenu(context, v); popup.getMenuInflater().inflate(R.menu.list_popup_menu, popup.getMenu()); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.setAsNext: setAsNext(context,position); return true; case delete: deleteFile(context,Data.getData(position)); return true; case R.id.setAsRingtone: menu_util.setAsRingtone(context, position); return true; case R.id.musicInfo: showMusicInfo(context,position); return true; } return true; } }); popup.show(); //showing popup menu }
private void initPopupMenu() { mPopupMenu = new PopupMenu(this, mImageButton_Ellipsis); mMenu = mPopupMenu.getMenu(); // 通过XML文件添加菜单项 MenuInflater menuInflater = getMenuInflater(); menuInflater.inflate(R.menu.popupmenu, mMenu); mPopupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { /* case R.id.onekey: showMessage("功能研发中..."); break;*/ case R.id.addbox: //合箱发货 boxPopupMenuClick(); break; default: break; } return false; } }); }
private void showMenu(View v, final int position, final Connection connection) { final PopupMenu popupMenu = new PopupMenu(mContext, v); popupMenu.inflate(R.menu.menu_connection_item); popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.action_edit: ConnectionActivity.openActivity(mContext, connection); return true; case R.id.action_delete: MQTTManager.getInstance().removeClient(connection.getId()); RealmHelper.getInstance().deleteTopic(Subscription.class,connection.getId()); RealmHelper.getInstance().delete(connection); notifyItemRemoved(position); notifyItemRangeChanged(position, getItemCount()); return true; default: return false; } } }); popupMenu.show(); }
private void showMoreMenu(View view, final int position) { PopupMenu popup = new PopupMenu(mContext, view); popup.getMenuInflater() .inflate(R.menu.popup_menu, popup.getMenu()); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.edit: mOnItemClickListener.onEditClick(position); break; case R.id.delete: mOnItemClickListener.onDeleteClick(position); break; } return true; } }); popup.show(); }
private void showMoreMenu(View view, final int position) { PopupMenu popup = new PopupMenu(mContext, view); popup.getMenuInflater() .inflate(R.menu.popup_menu, popup.getMenu()); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.edit: mOnNoteItemClickListener.onEditClick(position); break; case R.id.delete: mOnNoteItemClickListener.onDeleteClick(position); break; } return true; } }); popup.show(); }
public void showFilteringPopupMenu() { PopupMenu popup = new PopupMenu(this.getContext(), MainActivity.get(this.getContext()).findViewById(R.id.menu_filter)); popup.getMenuInflater().inflate(R.menu.filter_tasks, popup.getMenu()); popup.setOnMenuItemClickListener(item -> { switch(item.getItemId()) { case R.id.active: tasksPresenter.setFiltering(TasksFilterType.ACTIVE_TASKS); break; case R.id.completed: tasksPresenter.setFiltering(TasksFilterType.COMPLETED_TASKS); break; default: tasksPresenter.setFiltering(TasksFilterType.ALL_TASKS); break; } //loadTasks(false); // reactive data source ftw return true; }); popup.show(); }
public void onMoreButtonClicked(final BookInfo bookInfo, View v) { PopupMenu popup = new PopupMenu(context, v); popup.setOnMenuItemClickListener(item -> { switch (item.getItemId()) { case R.id.book_overflow_delete_book: DialogFragment confirmBatchDownloadDialogFragment = new ConfirmBookDeleteDialogFragment(); Bundle confirmDeleteDialogFragmentBundle = new Bundle(); confirmDeleteDialogFragmentBundle.putInt(ConfirmBookDeleteDialogFragment.KEY_NUMBER_OF_BOOKS_TO_DELETE, 1); confirmDeleteDialogFragmentBundle.putInt(BooksInformationDBContract.BookInformationEntery.COLUMN_NAME_ID, bookInfo.getBookId()); confirmDeleteDialogFragmentBundle.putString(BooksInformationDBContract.BookInformationEntery.COLUMN_NAME_TITLE, bookInfo.getName()); confirmBatchDownloadDialogFragment.setArguments(confirmDeleteDialogFragmentBundle); confirmBatchDownloadDialogFragment.show(context.getSupportFragmentManager(), "ConfirmBookDeleteDialogFragment"); return true; default: return false; } }); popup.inflate(R.menu.book_card_overflow); if (bookInfo.getDownloadStatus() < DownloadsConstants.STATUS_DOWNLOAD_COMPLETED) { popup.getMenu().removeItem(R.id.book_overflow_delete_book); } popup.show(); }
public void showFilteringPopupMenu() { PopupMenu popup = new PopupMenu(getContext(), MainActivity.get(getContext()).findViewById(R.id.menu_filter)); popup.getMenuInflater().inflate(R.menu.filter_tasks, popup.getMenu()); popup.setOnMenuItemClickListener(item -> { switch(item.getItemId()) { case R.id.active: tasksPresenter.setFiltering(TasksFilterType.ACTIVE_TASKS); break; case R.id.completed: tasksPresenter.setFiltering(TasksFilterType.COMPLETED_TASKS); break; default: tasksPresenter.setFiltering(TasksFilterType.ALL_TASKS); break; } //loadTasks(false); // reactive data source ftw return true; }); popup.show(); }
private void showFilteringPopUpMenu() { PopupMenu popup = new PopupMenu(getContext(), getActivity().findViewById(R.id.menu_filter)); popup.getMenuInflater().inflate(R.menu.filter_tasks, popup.getMenu()); popup.setOnMenuItemClickListener(item -> { switch(item.getItemId()) { case R.id.active: tasksViewModel.setFiltering(TasksFilterType.ACTIVE_TASKS); break; case R.id.completed: tasksViewModel.setFiltering(TasksFilterType.COMPLETED_TASKS); break; default: tasksViewModel.setFiltering(TasksFilterType.ALL_TASKS); break; } tasksViewModel.reloadTasks(); return true; }); popup.show(); }
/** * Shows a contextual popup menu anchored to the supplied view. Item selections are passed to * the presenter. * * @param anchor * the view to anchor the menu to, not null * @param item * the LibraryItem associated with the contextual menu, not null */ private void showMenu(final View anchor, final LibraryItem item) { checkNotNull(item, "item cannot be null."); checkNotNull(anchor, "overflowButton cannot be null."); final PopupMenu menu = new PopupMenu(getContext(), anchor); menu.inflate(contextualMenuResourceId); menu.show(); // Propagate menu selections back to the presenter menu.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(final MenuItem menuItem) { for (final MenuItemSelectedListener listener : menuItemSelectedListeners) { listener.onContextualMenuItemSelected(RecyclerBodyView.this, item, menuItem); } return true; } }); }
@Override public void onClick(View view) { if (view.getId() == R.id.post_image_edit_layout) { PopupMenu popupMenu = new PopupMenu(this, mPostImageLayoutManager.getRootLayout()); popupMenu.inflate(R.menu.insert_image); if (TextUtils.isEmpty(mPost.getFeatureImage())) { MenuItem removeImageItem = popupMenu.getMenu().findItem(R.id.action_image_remove); removeImageItem.setVisible(false); } popupMenu.setOnMenuItemClickListener(item -> { if (item.getItemId() == R.id.action_insert_image_url) { mPostEditFragment.onInsertImageUrlClicked(getInsertImageDoneAction()); } else if (item.getItemId() == R.id.action_insert_image_upload) { mPostEditFragment.onInsertImageUploadClicked(getInsertImageDoneAction()); } else if (item.getItemId() == R.id.action_image_remove) { getInsertImageDoneAction().call(""); } return true; }); popupMenu.show(); } }
public void showPopupMenu(View view) throws NoSuchFieldException, IllegalAccessException { PopupMenu popupMenu = new PopupMenu(this, view); //设置 PopupMenu 的显示菜单项 popupMenu.inflate(R.menu.main); // popupMenu.getMenuInflater().inflate(R.menu.main, popupMenu.getMenu());//与一行没什么区别 //默认 PopupMenu 不显示条目icon,可以通过反射来强制使其显示icon Field field = popupMenu.getClass().getDeclaredField("mPopup"); field.setAccessible(true); MenuPopupHelper mHelper = (MenuPopupHelper) field.get(popupMenu); mHelper.setForceShowIcon(true); //设置 PopupMenu 的条目点击事件(点击后会自动dismiss) popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { Toast.makeText(getApplicationContext(), item.getTitle(), Toast.LENGTH_SHORT).show(); return false; } }); //显示 PopupMenu popupMenu.show(); }
public void setOnItemClickListenerToAdapter(){ rvAdapter.setOnItemClickListener((view, position, data) -> { popupMenu= new PopupMenu(view.getContext(),view); popupMenu.getMenuInflater().inflate(R.menu.popup_menu,popupMenu.getMenu()); popupMenu.setOnMenuItemClickListener(item -> { if (item.getItemId() == R.id.delete) { deleteQuote(position); return true; } if (item.getItemId() == R.id.share) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, rvAdapter.quoteList.get(position).getQuote()); view.getContext().startActivity(Intent.createChooser(intent, " به اشتراک بگذارید ")); return true; } return true; }); popupMenu.show(); }); }
void onLongClick() { Task currentTask = taskList.get(position); CardView cardView = (CardView)itemView; float initialElevation = cardView.getCardElevation(); cardView.setCardElevation(cardView.getCardElevation() * 15); PopupMenu menu = new PopupMenu(context, itemView); menu.inflate(R.menu.pop_up_menu); menu.setOnMenuItemClickListener(item -> { switch (item.getItemId()){ case R.id.edit_task: actions.editTask(currentTask, position); return true; case R.id.delete_task: actions.deleteTask(currentTask, position); } return false; }); menu.setOnDismissListener(popupMenu -> cardView.setCardElevation(initialElevation)); menu.show(); }
/** * Folder Menu * * @param context * @param view */ public static void showFolderMenu(Context context, View view, File file, RefreshData refreshData) { PopupMenu popupMenu = new PopupMenu(context, view); MenuInflater menuInflater = popupMenu.getMenuInflater(); menuInflater.inflate(R.menu.folder_menu, popupMenu.getMenu()); if (file == null) { return; } popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.exclude_folder: excludeFolder(context, file, refreshData); break; } return false; } }); popupMenu.show(); }
public static void popupMenuEnableIcons(PopupMenu popupMenu) { 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 (Throwable e) { e.printStackTrace(); } }
@Override public void onClickOptions(View v, final Update update, Button buttonView) { PopupMenu popupMenu = new PopupMenu(this, buttonView); popupMenu.getMenuInflater().inflate(R.menu.update_card, popupMenu.getMenu()); popupMenu.setOnMenuItemClickListener(item -> { switch (item.getItemId()) { case R.id.menu_card_copytext: ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); clipboard.setPrimaryClip(ClipData.newPlainText("Update Text", update.getText())); showToast(getString(R.string.toast_card_copiedtext)); break; } return false; }); popupMenu.show(); }
private void showMenu(final int position, View v) { PopupMenu popup = new PopupMenu(getActivity(), v); MenuInflater inflater = popup.getMenuInflater(); inflater.inflate(R.menu.album_list_item, popup.getMenu()); final Album album = mAdapter.getItem(position); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.action_edit_tags: showEditorDialog(album); return true; case R.id.action_add_to_playlist: showPlaylistPicker(album); return true; } return false; } }); popup.show(); }
private void showLanguageSelectMenu( View v, final List<String> languageList, final OnLanguageSelected callback) { if(languageList.isEmpty()) return; PopupMenu m = new PopupMenu(context, v); int i = 0; for (String languageCode : languageList) { m.getMenu().add(NONE,i++,NONE, getLanguageMenuItemTitle(languageCode)); } m.setOnMenuItemClickListener(item -> { callback.onLanguageSelected(languageList.get(item.getItemId())); return true; }); m.show(); }
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mUsers.setLayoutManager(new LinearLayoutManager(getContext())); mUsers.setHasFixedSize(true); mUsers.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL)); mUsers.addOnItemTouchListener(new RecyclerItemClickListener(getContext(), (view1, position) -> { Timber.d("User position: " + position + " id: " + mAdapter.getItemId(position)); PopupMenu popupMenu = new PopupMenu(getContext(), view1); popupMenu.inflate(R.menu.fragment_users_popupmenu); popupMenu.setOnMenuItemClickListener(new OnExecUserPopupMenu(mAdapter.getItemId(position))); popupMenu.show(); })); RxView.clicks(mCreateInput) .subscribe(aVoid -> { User session = getArguments().getParcelable("session"); Bundle args = new Bundle(); args.putLong("userId", -1); args.putParcelable("session", session); router.navigateTo(Screens.USER_SCREEN, args); }); mCacheUsersPresenter.load(); }
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); Timber.d("onViewCreated"); mDevices.setLayoutManager(new LinearLayoutManager(getContext())); mDevices.setHasFixedSize(true); mDevices.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL)); mDevices.addOnItemTouchListener(new RecyclerItemClickListener(getContext(), (view1, position) -> { Timber.d("Device position: " + position + " id: " + mAdapter.getItemId(position)); PopupMenu popupMenu = new PopupMenu(getContext(), view1); popupMenu.inflate(R.menu.fragment_devices_popupmenu); popupMenu.setOnMenuItemClickListener(new OnExecDevicePopupMenu(mAdapter.getItemId(position))); popupMenu.show(); })); RxView.clicks(mCreateInput) .subscribe(aVoid -> { Bundle args = new Bundle(); args.putLong("deviceId", -1); router.navigateTo(Screens.DEVICE_SCREEN, args); }); mCacheDevicesPresenter.load(); }
@Override public void onClick(final View view) { if (view == mOverflowIcon) { PopupMenu popup = new PopupMenu(view.getContext(), view); popup.inflate(R.menu.menu_book_item); popup.setOnMenuItemClickListener(this); popup.show(); } else { final List<FileType> ftypes = ((BookLibApplication) view.getContext().getApplicationContext()).getLibManager().getFileTypesForBook(ebk); if (ftypes.size() > 1) { showFileTypePickerDialog(view.getContext()); } else { openBook(view.getContext(), ftypes.get(0).getFileType().toLowerCase()); } } }
private void showMenu(final int position, View v) { PopupMenu popup = new PopupMenu(getActivity(), v); MenuInflater inflater = popup.getMenuInflater(); final Album album = mAdapterAlbum.getItem(position); inflater.inflate(R.menu.search_album_item, popup.getMenu()); popup.setOnMenuItemClickListener(item -> { switch (item.getItemId()) { case R.id.action_play_album: playAlbum(album); return true; case R.id.action_add_to_playlist: showPlaylistPicker(album); return true; default: break; } return false; }); popup.show(); }
private void popupAddRadio(final View v) { final PopupMenu popup = new PopupMenu(MainActivity.this, v); popup.getMenuInflater().inflate(R.menu.add_radio, popup.getMenu()); popup.setOnMenuItemClickListener(item -> { switch (item.getItemId()) { case R.id.add_browse: loadSearch(); break; case R.id.add_manual: editRadio(null); break; default: break; } return true; }); popup.show(); }
public void setMenuOptionsHandler(final MenuClickHandler clickHandler) { cardMenuIcon.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { PopupMenu popup = new PopupMenu(getContext(), v); MenuInflater inflater = popup.getMenuInflater(); inflater.inflate(menuItemsResource, popup.getMenu()); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { clickHandler.onMenuOptionClick(item); return true; } }); popup.show(); } }); }
@Override public void showFilteringPopUpMenu() { PopupMenu popup = new PopupMenu(getContext(), getActivity().findViewById(R.id.menu_filter)); popup.getMenuInflater().inflate(R.menu.filter_tasks, popup.getMenu()); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.active: mPresenter.setFiltering(TasksFilterType.ACTIVE_TASKS); break; case R.id.completed: mPresenter.setFiltering(TasksFilterType.COMPLETED_TASKS); break; default: mPresenter.setFiltering(TasksFilterType.ALL_TASKS); break; } mPresenter.loadTasks(false); return true; } }); popup.show(); }
private void setupOverflowMenu(Post post, int position) { overflowMenu.setOnClickListener(view -> { PopupMenu popupMenu = new PostPopupMenuBuilder().prepMenu(itemView.getContext(), overflowMenu) .addReportAbuse(menuItem -> { cardTouchEventPublishSubject.onNext( new CardTouchEvent(post, position, CardTouchEvent.Type.REPORT_ABUSE)); return false; }) .addUnfollowStore(menuItem -> { cardTouchEventPublishSubject.onNext( new CardTouchEvent(post, position, CardTouchEvent.Type.UNFOLLOW_STORE)); return false; }) .getPopupMenu(); popupMenu.show(); }); }
private void setupOverflowMenu(Post post, int position) { overflowMenu.setOnClickListener(view -> { PopupMenu popupMenu = new PostPopupMenuBuilder().prepMenu(itemView.getContext(), overflowMenu) .addReportAbuse(menuItem -> { cardTouchEventPublishSubject.onNext( new CardTouchEvent(post, position, CardTouchEvent.Type.REPORT_ABUSE)); return false; }) .addIgnoreUpdate(menuItem -> { cardTouchEventPublishSubject.onNext( new CardTouchEvent(post, position, CardTouchEvent.Type.IGNORE_UPDATE)); return false; }) .getPopupMenu(); popupMenu.show(); }); }
private void showPopupMenu(final View view, final View contextView, final Contact contact) { PopupMenu popup = new PopupMenu(contextView.getContext(), view); popup.getMenuInflater().inflate(R.menu.menu_contact_list_popup, popup.getMenu()); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.actionDelete: deleteContact(contextView, contact); return true; default: return false; } } }); popup.show(); }
private void prepareMainMenu(View v) { popup = new PopupMenu(this, v); v.setOnTouchListener(popup.getDragToOpenListener()); popup.getMenuInflater() .inflate(R.menu.menu_main, popup.getMenu()); popup.setOnMenuItemClickListener(this); // force shows popup menu icons // try { // Field mFieldPopup = popup.getClass().getDeclaredField("mPopup"); // mFieldPopup.setAccessible(true); // MenuPopupHelper mPopup = (MenuPopupHelper) mFieldPopup.get(popup); // mPopup.setForceShowIcon(true); // } catch (Exception e) { // } }
public PopupCardView(Context context, final List<String> list) { super(context, R.layout.popup_cardview); this.list = list; if (list != null) { popup = new PopupMenu(getContext(), valueView); for (int i = 0; i < list.size(); i++) popup.getMenu().add(Menu.NONE, i, Menu.NONE, list.get(i)); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { if (valueView != null) { valueText = list.get(item.getItemId()) + " "; valueView.setText(valueText); } if (onPopupCardListener != null) onPopupCardListener.onItemSelected(PopupCardView.this, item.getItemId()); return false; } }); } if (onPopupCardListener != null) setListener(); }
public PopupCardView(Context context, final List<String> list) { super(context, R.layout.popup_cardview); this.list = list; if (list != null) { popup = new PopupMenu(getContext(), valueView); for (int i = 0; i < list.size(); i++) popup.getMenu().add(Menu.NONE, i, Menu.NONE, list.get(i)); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { if (valueView != null) { valueText = list.get(item.getItemId()) + " "; valueView.setText(list.get(item.getItemId()) + " "); } if (onPopupCardListener != null) onPopupCardListener.onItemSelected(PopupCardView.this, item.getItemId()); return false; } }); } if (onPopupCardListener != null) setListener(); }
private void showFilterPopup(View v) { PopupMenu popup = new PopupMenu(context, v); popup.getMenuInflater().inflate(R.menu.menu_popup, popup.getMenu()); popup.setOnMenuItemClickListener(item -> { switch (item.getItemId()) { case R.id.menu_delete: deleteAlert(); return true; case R.id.menu_rename: editAlert(); return true; case R.id.menu_share: Intent share = new Intent(Intent.ACTION_SEND); share.setType("text/plain"); share.putExtra(Intent.EXTRA_TEXT, bookmark.getUrl()); context.startActivity(Intent.createChooser(share, context.getResources().getString(R.string.share_bookmark))); return true; default: return false; } }); popup.show(); }
CardViewHolder(ImageCardView view, Context context) { super(view); mContext = context; Context wrapper = new ContextThemeWrapper(mContext, R.style.MyPopupMenu); mPopupMenu = new PopupMenu(wrapper, view); mPopupMenu.inflate(R.menu.popup_menu); mPopupMenu.setOnMenuItemClickListener(this); view.setOnLongClickListener(this); mOwner = (LifecycleOwner) mContext; mDefaultBackground = mContext.getResources().getDrawable(R.drawable.no_cache_no_internet, null); mDefaultPlaceHolder = new RequestOptions(). placeholder(mDefaultBackground); mCardView = (ImageCardView) CardViewHolder.this.view; Resources resources = mCardView.getContext().getResources(); mCardView.setMainImageDimensions(Math.round( resources.getDimensionPixelSize(R.dimen.card_width)), resources.getDimensionPixelSize(R.dimen.card_height)); mFragmentActivity = (FragmentActivity) context; mViewModel = ViewModelProviders.of(mFragmentActivity).get(VideosViewModel.class); }
public View.OnLongClickListener removeFromFavourites(final RxBus rxBus) { return v -> { PopupMenu popup = new PopupMenu(v.getContext(), v); popup.setOnMenuItemClickListener((MenuItem menuitem) -> { switch (menuitem.getItemId()) { case R.id.menu_popup_remove_favourite: rxBus.post(new FavoriteRemoveEvent(favourite.get().getFavId())); return true; default: return false; } }); popup.inflate(R.menu.popup_favorites); popup.show(); return true; }; }
private void showOptions(final View view) { PopupMenu popupMenu = new PopupMenu(getActivity(), view); popupMenu.inflate(R.menu.menu_add); popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(final MenuItem item) { switch (item.getItemId()) { case R.id.new_addfeed: addSomething(); break; } return false; } }); popupMenu.show(); }