android.support.v7.widget.PopupMenu Java Examples

The following examples show how to use android.support.v7.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: ContextUtils.java    From memetastic with GNU General Public License v3.0 6 votes vote down vote up
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();
    }
}
 
Example #2
Source File: VideoCardPresenter.java    From leanback-showcase with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #3
Source File: PopupCardView.java    From KA27 with Apache License 2.0 6 votes vote down vote up
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();
}
 
Example #4
Source File: PostViewActivity.java    From quill with MIT License 6 votes vote down vote up
@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();
    }
}
 
Example #5
Source File: TasksFragment.java    From mobius-android-sample with Apache License 2.0 6 votes vote down vote up
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:
            onFilterSelected(TasksFilterType.ACTIVE_TASKS);
            break;
          case R.id.completed:
            onFilterSelected(TasksFilterType.COMPLETED_TASKS);
            break;
          default:
            onFilterSelected(TasksFilterType.ALL_TASKS);
            break;
        }
        return true;
      });

  popup.show();
}
 
Example #6
Source File: ClientItem.java    From snapdroid with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onClick(View v) {
    if (v == ibMute) {
        Volume volume = client.getConfig().getVolume();
        volume.setMuted(!volume.isMuted());
        update();
        listener.onVolumeChanged(this, volume.getPercent(), volume.isMuted());
    } else if (v == ibOverflow) {
        PopupMenu popup = new PopupMenu(v.getContext(), v);
        popup.getMenu().add(Menu.NONE, R.id.menu_details, 0, R.string.menu_details);
        if (!client.isConnected())
            popup.getMenu().add(Menu.NONE, R.id.menu_delete, 1, R.string.menu_delete);
        popup.setOnMenuItemClickListener(this);
        popup.show();
    }
}
 
Example #7
Source File: BaseBrowserFragment.java    From VCL-Android with Apache License 2.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void onPopupMenu(View anchor, final int position) {
    if (!AndroidUtil.isHoneycombOrLater()) {
        // Call the "classic" context menu
        anchor.performLongClick();
        return;
    }
    PopupMenu popupMenu = new PopupMenu(getActivity(), anchor);
    setContextMenu(popupMenu.getMenuInflater(), popupMenu.getMenu(), position);

    popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            return handleContextItemSelected(item, position);
        }
    });
    popupMenu.show();
}
 
Example #8
Source File: AudioAlbumFragment.java    From VCL-Android with Apache License 2.0 6 votes vote down vote up
@Override
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void onPopupMenu(View anchor, final int position) {
    if (!AndroidUtil.isHoneycombOrLater()) {
        // Call the "classic" context menu
        anchor.performLongClick();
        return;
    }

    PopupMenu popupMenu = new PopupMenu(getActivity(), anchor);
    popupMenu.getMenuInflater().inflate(R.menu.audio_list_browser, popupMenu.getMenu());
    setContextMenuItems(popupMenu.getMenu(), anchor, position);

    popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            return handleContextItemSelected(item, position);
        }
    });
    popupMenu.show();
}
 
Example #9
Source File: ConnectionAdapter.java    From EMQ-Android-Toolkit with Apache License 2.0 6 votes vote down vote up
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();
}
 
Example #10
Source File: PopupCardView.java    From kernel_adiutor with Apache License 2.0 6 votes vote down vote up
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();
}
 
Example #11
Source File: AppFileListAdapter.java    From AppPlus with MIT License 6 votes vote down vote up
/**
 * 显示弹出式菜单
 * @param entity
 * @param ancho
 */
private void showPopMenu(final AppEntity entity,View ancho) {
    PopupMenu popupMenu = new PopupMenu(mContext,ancho);
    popupMenu.getMenuInflater().inflate(R.menu.item_pop_file_menu,popupMenu.getMenu());
    popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            if(mClickPopupMenuItem!=null){
                mClickPopupMenuItem.onClickMenuItem(item.getItemId(),entity);
            }
            return false;
        }
    });

    makePopForceShowIcon(popupMenu);
    popupMenu.show();
}
 
Example #12
Source File: BookCardEventsCallback.java    From IslamicLibraryAndroid with GNU General Public License v3.0 6 votes vote down vote up
public void onMoreButtonClicked(@NonNull final BookInfo bookInfo, @NonNull 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();
}
 
Example #13
Source File: MoverRecycleFragment.java    From Mover with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onItemLongClick(RecyclerView parent, View view, int position, long id) {

    int viewType = mWatchMeAdapter.getItemViewType(position);

    switch (viewType){
        case WatchMeAdapterNew.TYPE_HEADER_FIRST:
            getJobManager().addJob(new FetchAvailableVideoQualities("p3xpwfHm"));
            return true;

        case WatchMeAdapterNew.TYPE_VIDEO:
        case WatchMeAdapterNew.TYPE_VIDEO_LAST:

            mSelectedVideoPosition = position;

            PopupMenu popupMenu = new PopupMenu(view.getContext(), view, Gravity.TOP);
            popupMenu.setOnMenuItemClickListener(mOnMenuItemClickListener);
            popupMenu.inflate(R.menu.video_item_menu);
            popupMenu.show();
            return true;
    }

    return false;
}
 
Example #14
Source File: DashboardItemAddFragment.java    From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    long dashboardId = getArguments().getLong(Dashboard$Table.ID);
    mDashboard = new Select()
            .from(Dashboard.class)
            .where(Condition.column(Dashboard$Table
                    .ID).is(dashboardId))
            .querySingle();

    ButterKnife.bind(this, view);

    InputMethodManager imm = (InputMethodManager)
            getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(mFilter.getWindowToken(), 0);

    mAdapter = new DashboardItemSearchDialogAdapter(
            LayoutInflater.from(getActivity()));
    mListView.setAdapter(mAdapter);
    mDialogLabel.setText(getString(R.string.add_dashboard_item));

    mResourcesMenu = new PopupMenu(getActivity(),mFilter, Gravity.END);
    mResourcesMenu.inflate(R.menu.menu_filter_resources);
    mResourcesMenu.setOnMenuItemClickListener(this);
}
 
Example #15
Source File: PopupListFragment.java    From android-ActionBarCompat-ListPopupMenu with Apache License 2.0 5 votes vote down vote up
private void showPopupMenu(View view) {
    final PopupAdapter adapter = (PopupAdapter) getListAdapter();

    // Retrieve the clicked item from view's tag
    final String item = (String) view.getTag();

    // Create a PopupMenu, giving it the clicked view for an anchor
    PopupMenu popup = new PopupMenu(getActivity(), view);

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

    // Set a listener so we are notified if a menu item is clicked
    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem menuItem) {
            switch (menuItem.getItemId()) {
                case R.id.menu_remove:
                    // Remove the item from the adapter
                    adapter.remove(item);
                    return true;
            }
            return false;
        }
    });

    // Finally show the PopupMenu
    popup.show();
}
 
Example #16
Source File: TimerViewHolder.java    From ClockPlus with GNU General Public License v3.0 5 votes vote down vote up
public TimerViewHolder(ViewGroup parent, OnListItemInteractionListener<Timer> listener,
                       AsyncTimersTableUpdateHandler asyncTimersTableUpdateHandler) {
    super(parent, R.layout.item_timer, listener);
    Log.d(TAG, "New TimerViewHolder");
    mAsyncTimersTableUpdateHandler = asyncTimersTableUpdateHandler;
    mStartIcon = ContextCompat.getDrawable(getContext(), R.drawable.ic_start_24dp);
    mPauseIcon = ContextCompat.getDrawable(getContext(), R.drawable.ic_pause_24dp);

    // TODO: This is bad! Use a Controller/Presenter instead...
    // or simply pass in an instance of FragmentManager to the ctor.
    AppCompatActivity act = (AppCompatActivity) getContext();
    mAddLabelDialogController = new AddLabelDialogController(
            act.getSupportFragmentManager(),
            new AddLabelDialog.OnLabelSetListener() {
                @Override
                public void onLabelSet(String label) {
                    mController.updateLabel(label);
                }
            });

    // The item layout is inflated in the super ctor, so we can safely reference our views.
    mPopupMenu = new PopupMenu(getContext(), mMenuButton);
    mPopupMenu.inflate(R.menu.menu_timer_viewholder);
    mPopupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
                case R.id.action_delete:
                    mController.deleteTimer();
                    return true;
            }
            return false;
        }
    });
}
 
Example #17
Source File: ThirdSwipeBackFragment.java    From SwipeBackFragment with Apache License 2.0 5 votes vote down vote up
private void initToolbar(View view) {
    mToolbar = (Toolbar) view.findViewById(R.id.toolbar);
    _initToolbar(mToolbar);

    Button btnSet = (Button) view.findViewById(R.id.btn_set);
    btnSet.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final PopupMenu popupMenu = new PopupMenu(getActivity(), v, GravityCompat.END);
            popupMenu.inflate(R.menu.swipe_orientation);
            popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    switch (item.getItemId()) {
                        case R.id.action_left:
                            getSwipeBackLayout().setEdgeOrientation(SwipeBackLayout.EDGE_LEFT);
                            Toast.makeText(getActivity(), "left", Toast.LENGTH_SHORT).show();
                            break;
                        case R.id.action_right:
                            getSwipeBackLayout().setEdgeOrientation(SwipeBackLayout.EDGE_RIGHT);
                            Toast.makeText(getActivity(), "right", Toast.LENGTH_SHORT).show();
                            break;
                        case R.id.action_all:
                            getSwipeBackLayout().setEdgeOrientation(SwipeBackLayout.EDGE_ALL);
                            Toast.makeText(getActivity(), "all", Toast.LENGTH_SHORT).show();
                            break;
                    }
                    popupMenu.dismiss();
                    return true;
                }
            });
            popupMenu.show();
        }
    });
}
 
Example #18
Source File: AppInfoListAdapter.java    From AppPlus with MIT License 5 votes vote down vote up
private void makePopForceShowIcon(PopupMenu popupMenu) {
    try {
        Field mFieldPopup=popupMenu.getClass().getDeclaredField("mPopup");
        mFieldPopup.setAccessible(true);
        MenuPopupHelper mPopup = (MenuPopupHelper) mFieldPopup.get(popupMenu);
        mPopup.setForceShowIcon(true);
    } catch (Exception e) {

    }
}
 
Example #19
Source File: SearchAdapter.java    From APlayer with GNU General Public License v3.0 5 votes vote down vote up
@SuppressLint("RestrictedApi")
@Override
protected void convert(final SearchResHolder holder, Song song, int position) {
  holder.mName.setText(song.getTitle());
  holder.mOther.setText(String.format("%s-%s", song.getArtist(), song.getAlbum()));
  //封面
  Disposable disposable = new LibraryUriRequest(holder.mImage,
      getSearchRequestWithAlbumType(song),
      new RequestConfig.Builder(SMALL_IMAGE_SIZE, SMALL_IMAGE_SIZE).build()).load();
  holder.mImage.setTag(disposable);

  //设置按钮着色
  int tintColor = ThemeStore.getLibraryBtnColor();
  Theme.tintDrawable(holder.mButton, R.drawable.icon_player_more, tintColor);

  holder.mButton.setOnClickListener(v -> {
    final PopupMenu popupMenu = new PopupMenu(holder.itemView.getContext(), holder.mButton, Gravity.END);
    popupMenu.getMenuInflater().inflate(R.menu.menu_song_item, popupMenu.getMenu());
    popupMenu.setOnMenuItemClickListener(
        new SongPopupListener((AppCompatActivity) holder.itemView.getContext(), song, false, ""));
    popupMenu.show();
  });

  if (mOnItemClickListener != null && holder.mRooView != null) {
    holder.mRooView.setOnClickListener(
        v -> mOnItemClickListener.onItemClick(v, holder.getAdapterPosition()));
  }
}
 
Example #20
Source File: PopupWindowFactory.java    From QuickNote with Apache License 2.0 5 votes vote down vote up
public static PopupMenu createAndShowPopupMenu(Context context, View anchor, int menuRes, PopupMenu.OnMenuItemClickListener listener) {
    PopupMenu popup = new PopupMenu(context, anchor);
    popup.getMenuInflater().inflate(menuRes, popup.getMenu());
    popup.setOnMenuItemClickListener(listener);
    popup.show();
    return popup;
}
 
Example #21
Source File: CommentViewHolder.java    From aptoide-client with GNU General Public License v2.0 5 votes vote down vote up
public void showPopup(final Activity activity, View view, final int commentId, String author, boolean showReply) {
    PopupMenu popup = new PopupMenu(view.getContext(), view);
    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            if (!AptoideUtils.AccountUtils.isLoggedInOrAsk(activity)) return false;
            if (!(activity instanceof AddCommentVoteCallback)) {
                throw new IllegalStateException("activity is not an instanceof AddCommentVoteCallback");
            }

            final AddCommentVoteCallback voteCallback = (AddCommentVoteCallback) activity;
            int i = item.getItemId();
            if (i == R.id.menu_vote_up) {
                voteCallback.voteComment(commentId, AddApkCommentVoteRequest.CommentVote.up);
                return true;
            } else if (i == R.id.menu_vote_down) {
                voteCallback.voteComment(commentId, AddApkCommentVoteRequest.CommentVote.down);
                return true;
            }
            return false;
        }
    });
    popup.inflate(R.menu.menu_comments);
    popup.show();
    if (!showReply) {
        popup.getMenu().findItem(R.id.menu_reply).setVisible(false);
    }
}
 
Example #22
Source File: NotesFragment.java    From memoir with Apache License 2.0 5 votes vote down vote up
@Override
public void onLongClicked(View view, final int position) {
    final Context context = getContext();
    PopupMenu popupMenu = new PopupMenu(context, view);
    popupMenu.inflate(R.menu.menu_delete);
    popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {

                case R.id.note_delete:
                    new AlertDialog.Builder(context)
                            .setTitle("Delete Note")
                            .setMessage("Are you sure you want to delete the note?")
                            .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialogInterface, int i) {
                                    NotesDatabase.getInstance(context).deleteNoteAt(position);
                                    adapter.notifyItemRemoved(position);
                                    refreshLayout();
                                }
                            })
                            .setNegativeButton(android.R.string.no, null)
                            .show();
                    return true;

                default:
                    return false;
            }
        }
    });
    popupMenu.show();
}
 
Example #23
Source File: CardHeaderView.java    From example with Apache License 2.0 5 votes vote down vote up
/**
 * Adds Popup menu
 */
protected void addPopup() {

    if (mCardHeader.getPopupMenu() > -1 && mImageButtonOverflow != null) {

        //Add a PopupMenu and its listener
        mImageButtonOverflow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                PopupMenu popup = new PopupMenu(getContext(), mImageButtonOverflow);
                MenuInflater inflater = popup.getMenuInflater();
                inflater.inflate(mCardHeader.getPopupMenu(), popup.getMenu());
                popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                    @Override
                    public boolean onMenuItemClick(MenuItem item) {
                        if (mCardHeader.getPopupMenu() > 0 && mCardHeader.getPopupMenuListener() != null) {
                            // This individual card has it unique menu
                            mCardHeader.getPopupMenuListener().onMenuItemClick(mCardHeader.getParentCard(), item);
                        }
                        return false;
                    }
                });
                popup.show();
            }
        });

    } else {
        if (mImageButtonOverflow != null)
            mImageButtonOverflow.setVisibility(GONE);
    }
}
 
Example #24
Source File: ReportAdapter.java    From privacy-friendly-pedometer with GNU General Public License v3.0 5 votes vote down vote up
public void showPopup(View v, Context c) {
    PopupMenu popup = new PopupMenu(c, v);
    MenuInflater inflater = popup.getMenuInflater();
    inflater.inflate(R.menu.menu_card_activity_summary, popup.getMenu());
    popup.setOnMenuItemClickListener(this);
    if (mItemClickListener != null) {
        mItemClickListener.setActivityChartDataTypeChecked(popup.getMenu());
    }
    popup.show();
}
 
Example #25
Source File: ReportAdapter.java    From privacy-friendly-pedometer with GNU General Public License v3.0 5 votes vote down vote up
public void showPopup(View v, Context c) {
    PopupMenu popup = new PopupMenu(c, v);
    if (mItemClickListener != null) {
        mItemClickListener.inflateWalkingModeMenu(popup.getMenu());
    }
    popup.setOnMenuItemClickListener(this);
    popup.show();
}
 
Example #26
Source File: FragmentCreateChannelViewModel.java    From iGap-Android with GNU Affero General Public License v3.0 5 votes vote down vote up
public void onClickTxtInputLink(View view) {


        if (isRadioButtonPrivate.get()) {
            final PopupMenu popup = new PopupMenu(G.fragmentActivity, view);
            //Inflating the Popup using xml file
            popup.getMenuInflater().inflate(R.menu.menu_item_copy, popup.getMenu());

            //registering popup with OnMenuItemClickListener
            popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                public boolean onMenuItemClick(MenuItem item) {
                    switch (item.getItemId()) {
                        case R.id.menu_link_copy:
                            String copy;
                            copy = edtSetLink.get();
                            ClipboardManager clipboard = (ClipboardManager) G.context.getSystemService(CLIPBOARD_SERVICE);
                            ClipData clip = ClipData.newPlainText("LINK_GROUP", copy);
                            clipboard.setPrimaryClip(clip);

                            break;
                    }
                    return true;
                }
            });

            popup.show(); //
        }
    }
 
Example #27
Source File: SweetSheet.java    From MousePaint with MIT License 5 votes vote down vote up
public void setMenuList(@MenuRes int menuRes) {

        Menu menu = new PopupMenu(mParentVG.getContext(), null).getMenu();
        new MenuInflater(mParentVG.getContext()).inflate(menuRes, menu);
        List<MenuEntity> menuEntities = getMenuEntityFormMenuRes(menu);

        if(mDelegate != null) {

            mDelegate.setMenuList(menuEntities);
        }else{
            mMenuEntities=menuEntities;
        }

    }
 
Example #28
Source File: PermissionsPopupMenu.java    From Plumble with GNU General Public License v3.0 5 votes vote down vote up
public PermissionsPopupMenu(Context context, View anchor, int menuRes,
                            IOnMenuPrepareListener enforcer,
                            PopupMenu.OnMenuItemClickListener itemClickListener,
                            IChannel channel, IJumbleService service) {
    mContext = context;
    mChannel = channel;
    mService = service;
    mPrepareListener = enforcer;
    mMenu = new PopupMenu(mContext, anchor);
    mMenu.inflate(menuRes);
    mMenu.setOnDismissListener(this);
    mMenu.setOnMenuItemClickListener(itemClickListener);
}
 
Example #29
Source File: WalkingModesAdapter.java    From privacy-friendly-pedometer with GNU General Public License v3.0 5 votes vote down vote up
public void showPopup(View v, Context c) {
    PopupMenu popup = new PopupMenu(c, v);
    MenuInflater inflater = popup.getMenuInflater();
    inflater.inflate(R.menu.menu_card_walking_mode, popup.getMenu());
    popup.getMenu().findItem(R.id.menu_set_active).setChecked(isActive);
    popup.setOnMenuItemClickListener(this);
    popup.show();
}
 
Example #30
Source File: MainActivity.java    From Bluefruit_LE_Connect_Android with MIT License 5 votes vote down vote up
public void onClickFilterNameSettings(View view) {
    PopupMenu popup = new PopupMenu(this, view);
    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            boolean processed = true;
            switch (item.getItemId()) {
                case R.id.scanfilter_name_contains:
                    mPeripheralList.setFilterNameExact(false);
                    break;
                case R.id.scanfilter_name_exact:
                    mPeripheralList.setFilterNameExact(true);
                    break;
                case R.id.scanfilter_name_sensitive:
                    mPeripheralList.setFilterNameCaseInsensitive(false);
                    break;
                case R.id.scanfilter_name_insensitive:
                    mPeripheralList.setFilterNameCaseInsensitive(true);
                    break;
                default:
                    processed = false;
                    break;
            }
            updateFilters();
            return processed;
        }
    });
    MenuInflater inflater = popup.getMenuInflater();
    Menu menu = popup.getMenu();
    inflater.inflate(R.menu.menu_scan_filters_name, menu);
    final boolean isFilterNameExact = mPeripheralList.isFilterNameExact();
    menu.findItem(isFilterNameExact ? R.id.scanfilter_name_exact : R.id.scanfilter_name_contains).setChecked(true);
    final boolean isFilterNameCaseInsensitive = mPeripheralList.isFilterNameCaseInsensitive();
    menu.findItem(isFilterNameCaseInsensitive ? R.id.scanfilter_name_insensitive : R.id.scanfilter_name_sensitive).setChecked(true);
    popup.show();
}