List of usage examples for android.view MenuItem getOrder
public int getOrder();
From source file:io.github.hidroh.materialistic.ReadabilityFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.menu_font_size) { return true; }//w w w . j a v a2 s . co m if (item.getGroupId() == R.id.menu_font_size_group) { item.setChecked(true); String choice = mTextSizeOptionValues[item.getOrder()]; mTextSize = toHtmlPx(Preferences.Theme.resolveTextSize(choice)); Preferences.Theme.savePreferredReadabilityTextSize(getActivity(), choice); render(); } else if (item.getGroupId() == R.id.menu_font_group) { item.setChecked(true); mTypefaceName = mFontOptionValues[item.getOrder()]; Preferences.Theme.savePreferredReadabilityTypeface(getActivity(), mTypefaceName); render(); } return true; }
From source file:it.angelic.soulissclient.fragments.TagDetailFragment.java
public boolean onContextItemSelected(MenuItem item) { Log.d(TAG, "onContextItemSelected id:" + item.getItemId()); int position = item.getOrder(); /*ContextMenuRecyclerView.RecyclerContextMenuInfo info = (ContextMenuRecyclerView.RecyclerContextMenuInfo) item.getMenuInfo();*/ switch (item.getItemId()) { case R.id.eliminaTag: SoulissTypical soulissTypical = collectedTagTypicals.get(position); Log.i(Constants.TAG, "DELETE TYP POS:" + position); datasource.deleteTagTypical(collectedTag.getTagId().intValue(), soulissTypical.getNodeId(), soulissTypical.getSlot()); collectedTagTypicals.remove(position); parallaxExtAdapter.setData(collectedTagTypicals); parallaxExtAdapter.notifyDataSetChanged(); Toast.makeText(getActivity(), "Device deleted", Toast.LENGTH_SHORT).show(); mRecyclerView.invalidate();/* w w w .j av a2 s . c o m*/ break; //TODO increase/dec priority default: Log.i(Constants.TAG, "not doing shit"); break; } return super.onContextItemSelected(item); }
From source file:it.gulch.linuxday.android.activities.MainActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { // Hide & disable primary (contextual) action items when the main menu is opened if (drawerLayout.isDrawerOpen(mainMenu)) { final int size = menu.size(); for (int i = 0; i < size; ++i) { MenuItem item = menu.getItem(i); if ((item.getOrder() & 0xFFFF0000) == 0) { item.setVisible(false).setEnabled(false); }/*from w ww .java 2s.c o m*/ } } MenuItem refreshMenuItem = menu.findItem(R.id.refresh); boolean isRefreshing = refreshItem != null; Log.d(TAG, "isRefreshing: " + Boolean.toString(isRefreshing)); refreshMenuItem.setEnabled(!isRefreshing); return super.onPrepareOptionsMenu(menu); }
From source file:com.vrem.wifianalyzer.navigation.NavigationMenuViewTest.java
@Test public void testNavigationMenuView() throws Exception { // execute/*from www. j a v a 2 s . c o m*/ final Menu menu = navigationView.getMenu(); // validate assertEquals(NavigationMenu.values().length, menu.size()); IterableUtils.forEach(EnumUtils.values(NavigationGroup.class), new Closure<NavigationGroup>() { @Override public void execute(final NavigationGroup navigationGroup) { IterableUtils.forEach(navigationGroup.getNavigationMenus(), new Closure<NavigationMenu>() { @Override public void execute(NavigationMenu navigationMenu) { MenuItem actual = menu.getItem(navigationMenu.ordinal()); assertEquals(navigationGroup.ordinal(), actual.getGroupId()); assertEquals(mainActivity.getResources().getString(navigationMenu.getTitle()), actual.getTitle()); assertEquals(navigationMenu.ordinal(), actual.getItemId()); assertEquals(navigationMenu.ordinal(), actual.getOrder()); } }); } }); }
From source file:com.meetingninja.csse.meetings.MeetingsFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { int position = item.getItemId(); boolean handled = false; AdapterContextMenuInfo aInfo = (AdapterContextMenuInfo) item.getMenuInfo(); if (item.getGroupId() == MainActivity.DrawerLabel.MEETINGS.getPosition()) { switch (item.getOrder()) { case 1: // Edit Toast.makeText(getActivity(), item.getTitle(), Toast.LENGTH_SHORT).show(); handled = true;//from w w w . jav a 2 s. co m break; case 2: // Delete Meeting meeting = meetingAdpt.getItem(position); // mySQLiteAdapter.deleteMeeting(meeting); Need to implement MeetingVolleyAdapter.deleteMeeting(meeting.getID()); meetings.remove(position); meetingAdpt.notifyDataSetChanged(); handled = true; break; default: Log.wtf(TAG, "Invalid context menu option selected"); break; } } else { Log.wtf(TAG, "What happened here?"); } return handled; }
From source file:com.audiokernel.euphonyrmt.fragments.BrowseFragment.java
private void addToPlaylist(final MenuItem item) { final EditText input = new EditText(getActivity()); final int id = item.getOrder(); if (item.getItemId() == 0) { new AlertDialog.Builder(getActivity()).setTitle(R.string.playlistName) .setMessage(R.string.newPlaylistPrompt).setView(input) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override/* w w w. j a v a 2s .c o m*/ public void onClick(final DialogInterface dialog, final int which) { final String name = input.getText().toString().trim(); if (!name.isEmpty()) { mApp.oMPDAsyncHelper.execAsync(new Runnable() { @Override public void run() { add(mItems.get(id), name); } }); } } }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { // Do nothing. } }).show(); } else { add(mItems.get(id), item.getTitle().toString()); } }
From source file:com.meetingninja.csse.notes.NotesFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { int position = item.getItemId(); boolean handled = false; AdapterContextMenuInfo aInfo = (AdapterContextMenuInfo) item.getMenuInfo(); if (item.getGroupId() == MainActivity.DrawerLabel.NOTES.getPosition()) { switch (item.getOrder()) { case 1: // Add Content Toast.makeText(getActivity(), String.format("%s", item.getTitle()), Toast.LENGTH_SHORT).show(); handled = true;/*from ww w . j a v a 2 s .com*/ break; case 2: // Delete delete(noteAdpt.getItem(position)); handled = true; break; case 3: Intent versionControl = new Intent(getActivity(), VersionControlActivity.class); startActivity(versionControl); handled = true; break; case 4: Note n = noteAdpt.getItem(position); if (mergeNote == null) { Log.d("MERGE", "merge_a: " + n.getID()); mergeNote = n; Toast.makeText(getActivity(), String.format("Select second note to merge."), Toast.LENGTH_LONG) .show(); } else if (mergeNote.getID().equalsIgnoreCase(n.getID())) { Log.d("MERGE", "merge_b: " + n.getID() + " : " + mergeNote.getID()); mergeNote = null; Toast.makeText(getActivity(), String.format("Error: Same note selected twice. Please reselect notes to merge."), Toast.LENGTH_LONG).show(); } else { Log.d("MERGE", "merge_c: " + n.getID() + " : " + mergeNote.getID()); Toast.makeText(getActivity(), String.format("Merging " + n.getTitle() + " into " + mergeNote.getTitle()), Toast.LENGTH_LONG).show(); mergeNote.setContent(mergeNote.getContent() + "\n" + n.getContent()); delete(n); updateNote(mergeNote); mergeNote = null; populateList(); } break; default: Log.wtf(TAG, "Invalid context menu option selected"); break; } } else { Log.wtf(TAG, "What happened here?"); } return handled; }
From source file:org.mariotaku.twidere.fragment.support.AccountsDashboardFragment.java
@Override public void onActivityCreated(final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE); mResolver = getContentResolver();/*w w w . ja va2 s. c o m*/ final View view = getView(); if (view == null) throw new AssertionError(); final Context context = view.getContext(); final TwidereApplication application = TwidereApplication.getInstance(context); mImageLoader = application.getMediaLoaderWrapper(); mListView.setItemsCanFocus(true); mAdapter = new MergeAdapter(); final LayoutInflater inflater = getLayoutInflater(savedInstanceState); mAccountsAdapter = new AccountSelectorAdapter(context, inflater, this); mAccountOptionsAdapter = new AccountOptionsAdapter(context); mAppMenuAdapter = new AppMenuAdapter(context); mAccountSelectorView = inflater.inflate(R.layout.header_drawer_account_selector, mListView, false); mAccountsSelector = (RecyclerView) mAccountSelectorView.findViewById(R.id.other_accounts_list); final LinearLayoutManager layoutManager = new FixedLinearLayoutManager(context); layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); layoutManager.setStackFromEnd(true); mAccountsSelector.setLayoutManager(layoutManager); mAccountsSelector.setAdapter(mAccountsAdapter); mAccountsSelector.setItemAnimator(null); mAccountProfileContainer = mAccountSelectorView.findViewById(R.id.profile_container); mNoAccountContainer = mAccountSelectorView.findViewById(R.id.no_account_container); mAccountProfileImageView = (ShapedImageView) mAccountSelectorView.findViewById(R.id.profile_image); mAccountProfileBannerView = (ImageView) mAccountSelectorView.findViewById(R.id.account_profile_banner); mFloatingProfileImageSnapshotView = (ImageView) mAccountSelectorView .findViewById(R.id.floating_profile_image_snapshot); mAccountProfileNameView = (TextView) mAccountSelectorView.findViewById(R.id.name); mAccountProfileScreenNameView = (TextView) mAccountSelectorView.findViewById(R.id.screen_name); mAccountsToggleMenu = (ActionMenuView) mAccountSelectorView.findViewById(R.id.toggle_menu); final SupportMenuInflater menuInflater = new SupportMenuInflater(context); menuInflater.inflate(R.menu.action_dashboard_timeline_toggle, mAccountsToggleMenu.getMenu()); mAccountsToggleMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { if (item.getGroupId() != AccountToggleProvider.MENU_GROUP) return false; final ParcelableAccount[] accounts = mAccountActionProvider.getAccounts(); final ParcelableAccount account = accounts[item.getOrder()]; final ContentValues values = new ContentValues(); final boolean newActivated = !account.is_activated; mAccountActionProvider.setAccountActivated(account.account_id, newActivated); values.put(Accounts.IS_ACTIVATED, newActivated); final String where = Expression.equals(Accounts.ACCOUNT_ID, account.account_id).getSQL(); mResolver.update(Accounts.CONTENT_URI, values, where, null); return true; } }); mAccountProfileContainer.setOnClickListener(this); mAdapter.addView(mAccountSelectorView, true); mAdapter.addAdapter(mAccountOptionsAdapter); mAdapter.addView(inflater.inflate(R.layout.layout_divider_drawer, mListView, false), false); mAdapter.addAdapter(mAppMenuAdapter); mListView.setAdapter(mAdapter); mListView.setOnItemClickListener(this); mPreferences.registerOnSharedPreferenceChangeListener(this); getLoaderManager().initLoader(0, null, this); }
From source file:com.almarsoft.GroundhogReader.MessageListActivity.java
@Override public boolean onContextItemSelected(MenuItem item) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); int order = item.getOrder(); HeaderItemClass header = mHeaderItemsList.get(info.position); // "Mark thread as read" if (order == MENU_ITEM_MARKTHREADREAD) markThreadAsReadOrUnread(header, true); // "Mark thread as unread" if (order == MENU_ITEM_MARKTHREADUNREAD) markThreadAsReadOrUnread(header, false); if (order == MENU_ITEM_STARTHREAD) { ArrayList<HeaderItemClass> itemsProxy = mHeaderItemsList; int itemsSize = itemsProxy.size(); String starred_thread_subject = header.getArticle().simplifiedSubject(); for (int i = 0; i < itemsSize; i++) { if (itemsProxy.get(i).getArticle().simplifiedSubject() == starred_thread_subject) { itemStarClicked(i);//from ww w . j a v a 2 s . c o m } } } if (order == MENU_ITEM_BANTHREAD) { banThread(header); Toast.makeText(this, getString(R.string.thread_ignore), Toast.LENGTH_LONG).show(); } if (order == MENU_ITEM_BANUSER) { banUser(header); Toast.makeText(this, getString(R.string.author_banned_reload_tohide), Toast.LENGTH_LONG).show(); } return true; }
From source file:com.todoroo.astrid.core.CustomFilterActivity.java
@Override public boolean onContextItemSelected(MenuItem item) { if (item.getGroupId() == MENU_GROUP_FILTER) { // give an initial value for the row before adding it CustomFilterCriterion criterion = getNth(item.getItemId(), criteria); final CriterionInstance instance = new CriterionInstance(); instance.criterion = criterion;//from w w w .jav a2 s . co m adapter.showOptionsFor(instance, new Runnable() { public void run() { adapter.add(instance); updateList(); } }); return true; } // item type context item else if (item.getGroupId() == MENU_GROUP_CONTEXT_TYPE) { CriterionInstance instance = adapter.getItem(item.getOrder()); instance.type = item.getItemId(); updateList(); } // delete context item else if (item.getGroupId() == MENU_GROUP_CONTEXT_DELETE) { CriterionInstance instance = adapter.getItem(item.getOrder()); adapter.remove(instance); updateList(); } return super.onContextItemSelected(item); }