Example usage for android.view MenuItem getMenuInfo

List of usage examples for android.view MenuItem getMenuInfo

Introduction

In this page you can find the example usage for android.view MenuItem getMenuInfo.

Prototype

public ContextMenuInfo getMenuInfo();

Source Link

Document

Gets the extra information linked to this menu item.

Usage

From source file:org.openintents.shopping.ui.ShoppingActivity.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    super.onContextItemSelected(item);
    AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) item.getMenuInfo();
    switch (item.getItemId()) {
    case MENU_MARK_ITEM:
        markItem(menuInfo.position);//from  www .j av  a2s . c  o m
        break;
    case MENU_EDIT_ITEM:
        editItem(menuInfo.position, EditItemDialog.FieldType.ITEMNAME);
        break;
    case MENU_REMOVE_ITEM_FROM_LIST:
        removeItemFromList(menuInfo.position);
        break;
    case MENU_DELETE_ITEM:
        deleteItemDialog(menuInfo.position);
        break;
    case MENU_MOVE_ITEM:
        Intent intent = new Intent();
        intent.setAction(Intent.ACTION_PICK);
        intent.setData(ShoppingContract.Lists.CONTENT_URI);
        startActivityForResult(intent, REQUEST_PICK_LIST);
        mMoveItemPosition = menuInfo.position;
        break;
    case MENU_COPY_ITEM:
        copyItem(menuInfo.position);
        break;
    case MENU_ITEM_STORES:
        editItemStores(menuInfo.position);
        break;
    }

    return true;
}

From source file:com.lgallardo.qbittorrentclient.RefreshListener.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();

    //        Log.d("Debug", "Item name: " + getResources().getResourceEntryName(item.getItemId()));
    ///*from w  ww  . j av a2  s.c o  m*/
    //        Log.d("Debug", "Item position: " + TorrentDetailsFragment.fileContentRowPosition);

    switch (item.getItemId()) {

    case R.id.action_file_dont_download:
        //                Log.d("Debug", "Don't download");
        setFilePrio(TorrentDetailsFragment.hashToUpdate, TorrentDetailsFragment.fileContentRowPosition, 0);
        return true;
    case R.id.action_file_normal_priority:
        //                Log.d("Debug", "Normal priority");
        setFilePrio(TorrentDetailsFragment.hashToUpdate, TorrentDetailsFragment.fileContentRowPosition, 1);
        return true;
    case R.id.action_file_high_priority:
        //                Log.d("Debug", "High priority");
        setFilePrio(TorrentDetailsFragment.hashToUpdate, TorrentDetailsFragment.fileContentRowPosition, 2);
        return true;
    case R.id.action_file_maximum_priority:
        //                Log.d("Debug", "Maximum priority");
        setFilePrio(TorrentDetailsFragment.hashToUpdate, TorrentDetailsFragment.fileContentRowPosition, 7);
        return true;

    default:
        //                Log.d("Debug", "default priority?");
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.bernard.beaconportal.activities.activity.MessageList.java

@Override
public boolean onContextItemSelected(android.view.MenuItem item) {
    AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) item.getMenuInfo();

    Account realAccount = null;/*  w ww . j  ava 2 s .com*/

    FolderInfoHolder folder = null;

    if (mListView.getItemAtPosition(menuInfo.position) != null) {

        if (menuInfo.position - 1 > mAdapter_Accounts.getCount() - 5) {

            if (0 < menuInfo.position - (mAdapter_Accounts.getCount() + 4)) {

                folder = (FolderInfoHolder) mAdapter
                        .getItem(menuInfo.position - (mAdapter_Accounts.getCount() + 6));

            } else {
                folder = (FolderInfoHolder) mAdapter.getItem(menuInfo.position);

            }

        } else {

            folder = (FolderInfoHolder) mAdapter.getItem(menuInfo.position);

            if (menuInfo != null && mListView.getItemAtPosition(menuInfo.position) != null) {

                mSelectedContextAccount = (BaseAccount) getListView().getItemAtPosition(menuInfo.position);
            }

            if (mSelectedContextAccount instanceof Account) {
                realAccount = (Account) mSelectedContextAccount;

            }

        }

    }

    switch (item.getItemId()) {
    case R.id.clear_local_folder:
        onClearFolder(mAccount, folder.name);
        break;
    case R.id.refresh_folder:
        checkMail(folder);
        break;
    case R.id.folder_settings:
        mDrawerLayout.closeDrawer(Gravity.START);
        FolderSettings.actionSettings(this, mAccount, folder.name);

        break;
    case R.id.delete_account:
        onDeleteAccount(realAccount);

        break;
    case R.id.account_settings:
        mDrawerLayout.closeDrawer(Gravity.START);
        onEditAccount(realAccount);

        break;
    case R.id.activate:
        onActivateAccount(realAccount);

        break;
    case R.id.clear_pending:
        onClearCommands(realAccount);

        break;
    case R.id.empty_trash:
        onEmptyTrash(realAccount);

        break;
    case R.id.clear:
        onClear(realAccount);

        break;
    case R.id.recreate:
        onRecreate(realAccount);

        break;
    case R.id.export:
        onExport(false, realAccount);

        break;
    case R.id.move_up:
        onMove(realAccount, true);

        break;
    case R.id.move_down:
        onMove(realAccount, false);

        break;
    }

    return super.onContextItemSelected(item);

}

From source file:org.tvbrowser.tvbrowser.TvBrowser.java

private void editDontWantToSee() {
    if (!SettingConstants.UPDATING_FILTER) {
        Set<String> currentExclusions = PrefUtils.getStringSetValue(R.string.I_DONT_WANT_TO_SEE_ENTRIES, null);

        final ArrayList<ExclusionEdit> mCurrentExclusionList = new ArrayList<TvBrowser.ExclusionEdit>();

        if (currentExclusions != null && !currentExclusions.isEmpty()) {
            for (String exclusion : currentExclusions) {
                mCurrentExclusionList.add(new ExclusionEdit(exclusion));
            }/*from w  ww.j a v a 2 s  .c  o m*/
        }

        Collections.sort(mCurrentExclusionList);

        final ArrayAdapter<ExclusionEdit> exclusionAdapter = new ArrayAdapter<TvBrowser.ExclusionEdit>(
                TvBrowser.this, android.R.layout.simple_list_item_1, mCurrentExclusionList);

        View view = getLayoutInflater().inflate(R.layout.dont_want_to_see_exclusion_edit_list,
                getParentViewGroup(), false);

        ListView list = (ListView) view.findViewById(R.id.dont_want_to_see_exclusion_list);

        list.setAdapter(exclusionAdapter);

        final Runnable cancel = new Runnable() {
            @Override
            public void run() {
            }
        };

        AdapterView.OnItemClickListener onClickListener = new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                final ExclusionEdit edit = exclusionAdapter.getItem(position);

                View editView = getLayoutInflater().inflate(R.layout.dont_want_to_see_edit,
                        getParentViewGroup(), false);

                final TextView exclusion = (TextView) editView.findViewById(R.id.dont_want_to_see_value);
                final CheckBox caseSensitive = (CheckBox) editView
                        .findViewById(R.id.dont_want_to_see_case_sensitve);

                exclusion.setText(edit.mExclusion);
                caseSensitive.setSelected(edit.mIsCaseSensitive);

                Runnable editPositive = new Runnable() {
                    @Override
                    public void run() {
                        if (exclusion.getText().toString().trim().length() > 0) {
                            edit.mExclusion = exclusion.getText().toString();
                            edit.mIsCaseSensitive = caseSensitive.isSelected();

                            exclusionAdapter.notifyDataSetChanged();
                        }
                    }
                };

                showAlertDialog(getString(R.string.action_dont_want_to_see), null, editView, null, editPositive,
                        null, cancel, false, false);
            }
        };

        list.setOnItemClickListener(onClickListener);
        list.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {
            @Override
            public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
                getMenuInflater().inflate(R.menu.don_want_to_see_context, menu);

                MenuItem item = menu.findItem(R.id.dont_want_to_see_delete);

                item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
                    @Override
                    public boolean onMenuItemClick(MenuItem item) {
                        ExclusionEdit edit = exclusionAdapter
                                .getItem(((AdapterView.AdapterContextMenuInfo) item.getMenuInfo()).position);
                        exclusionAdapter.remove(edit);
                        exclusionAdapter.notifyDataSetChanged();

                        return true;
                    }
                });
            }
        });

        Thread positive = new Thread() {
            @Override
            public void run() {
                SettingConstants.UPDATING_FILTER = true;

                final NotificationCompat.Builder builder = new NotificationCompat.Builder(TvBrowser.this);
                builder.setSmallIcon(R.drawable.ic_stat_notify);
                builder.setOngoing(true);
                builder.setContentTitle(getResources().getText(R.string.action_dont_want_to_see));
                builder.setContentText(
                        getResources().getText(R.string.dont_want_to_see_refresh_notification_text));

                final int notifyID = 2;

                final NotificationManager notification = (NotificationManager) getSystemService(
                        Context.NOTIFICATION_SERVICE);
                notification.notify(notifyID, builder.build());

                updateProgressIcon(true);

                HashSet<String> newExclusions = new HashSet<String>();
                final ArrayList<DontWantToSeeExclusion> exclusionList = new ArrayList<DontWantToSeeExclusion>();

                for (ExclusionEdit edit : mCurrentExclusionList) {
                    String exclusion = edit.getExclusion();

                    newExclusions.add(exclusion);
                    exclusionList.add(new DontWantToSeeExclusion(exclusion));
                }

                new Thread() {
                    public void run() {
                        Cursor programs = getContentResolver().query(TvBrowserContentProvider.CONTENT_URI_DATA,
                                new String[] { TvBrowserContentProvider.KEY_ID,
                                        TvBrowserContentProvider.DATA_KEY_TITLE },
                                null, null, TvBrowserContentProvider.KEY_ID);
                        programs.moveToPosition(-1);

                        builder.setProgress(programs.getCount(), 0, true);
                        notification.notify(notifyID, builder.build());

                        ArrayList<ContentProviderOperation> updateValuesList = new ArrayList<ContentProviderOperation>();

                        int keyColumn = programs.getColumnIndex(TvBrowserContentProvider.KEY_ID);
                        int titleColumn = programs.getColumnIndex(TvBrowserContentProvider.DATA_KEY_TITLE);

                        DontWantToSeeExclusion[] exclusionArr = exclusionList
                                .toArray(new DontWantToSeeExclusion[exclusionList.size()]);

                        while (programs.moveToNext()) {
                            builder.setProgress(programs.getCount(), programs.getPosition(), false);
                            notification.notify(notifyID, builder.build());

                            String title = programs.getString(titleColumn);

                            boolean filter = UiUtils.filter(getApplicationContext(), title, exclusionArr);
                            long progID = programs.getLong(keyColumn);

                            ContentValues values = new ContentValues();
                            values.put(TvBrowserContentProvider.DATA_KEY_DONT_WANT_TO_SEE, filter ? 1 : 0);

                            ContentProviderOperation.Builder opBuilder = ContentProviderOperation.newUpdate(
                                    ContentUris.withAppendedId(TvBrowserContentProvider.CONTENT_URI_DATA_UPDATE,
                                            progID));
                            opBuilder.withValues(values);

                            updateValuesList.add(opBuilder.build());
                        }

                        notification.cancel(notifyID);

                        programs.close();

                        if (!updateValuesList.isEmpty()) {
                            try {
                                getContentResolver().applyBatch(TvBrowserContentProvider.AUTHORITY,
                                        updateValuesList);
                                UiUtils.sendDontWantToSeeChangedBroadcast(getApplicationContext(), true);
                                handler.post(new Runnable() {
                                    @Override
                                    public void run() {
                                        Toast.makeText(getApplicationContext(),
                                                R.string.dont_want_to_see_sync_success, Toast.LENGTH_LONG)
                                                .show();
                                    }
                                });
                            } catch (RemoteException e) {
                                e.printStackTrace();
                            } catch (OperationApplicationException e) {
                                e.printStackTrace();
                            }
                        }

                        updateProgressIcon(false);
                        SettingConstants.UPDATING_FILTER = false;
                    }
                }.start();

                Editor edit = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit();
                edit.putStringSet(getString(R.string.I_DONT_WANT_TO_SEE_ENTRIES), newExclusions);
                edit.commit();
            }
        };

        showAlertDialog(getString(R.string.action_dont_want_to_see_edit), null, view, null, positive, null,
                cancel, false, true);
    }
}

From source file:com.nttec.everychan.ui.presentation.BoardFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    //?  ? -//from   w  ww .  ja va2s .  c  o  m
    switch (item.getItemId()) {
    case R.id.context_menu_thumb_load_thumb:
        bitmapCache.asyncGet(
                ChanModels.hashAttachmentModel((AttachmentModel) lastContextMenuAttachment.getTag()),
                ((AttachmentModel) lastContextMenuAttachment.getTag()).thumbnail,
                resources.getDimensionPixelSize(R.dimen.post_thumbnail_size), chan, null, imagesDownloadTask,
                (ImageView) lastContextMenuAttachment.findViewById(R.id.post_thumbnail_image),
                imagesDownloadExecutor, Async.UI_HANDLER, true, R.drawable.thumbnail_error);
        return true;
    case R.id.context_menu_thumb_download:
        downloadFile((AttachmentModel) lastContextMenuAttachment.getTag());
        return true;
    case R.id.context_menu_thumb_copy_url:
        String url = chan.fixRelativeUrl(((AttachmentModel) lastContextMenuAttachment.getTag()).path);
        Clipboard.copyText(activity, url);
        Toast.makeText(activity, resources.getString(R.string.notification_url_copied, url), Toast.LENGTH_LONG)
                .show();
        return true;
    case R.id.context_menu_thumb_attachment_info:
        String info = Attachments.getAttachmentInfoString(chan,
                ((AttachmentModel) lastContextMenuAttachment.getTag()), resources);
        Toast.makeText(activity, info, Toast.LENGTH_LONG).show();
        return true;
    case R.id.context_menu_thumb_reverse_search:
        ReverseImageSearch.openDialog(activity,
                chan.fixRelativeUrl(((AttachmentModel) lastContextMenuAttachment.getTag()).path));
        return true;
    }

    //?  ?  ?
    int position = lastContextMenuPosition;
    if (item.getMenuInfo() != null && item.getMenuInfo() instanceof AdapterView.AdapterContextMenuInfo) {
        position = ((AdapterView.AdapterContextMenuInfo) item.getMenuInfo()).position;
    }
    if (nullAdapterIsSet || position == -1 || adapter.getCount() <= position)
        return false;
    switch (item.getItemId()) {
    case R.id.context_menu_open_in_new_tab:
        UrlPageModel modelNewTab = new UrlPageModel();
        modelNewTab.chanName = chan.getChanName();
        modelNewTab.type = UrlPageModel.TYPE_THREADPAGE;
        modelNewTab.boardName = tabModel.pageModel.boardName;
        modelNewTab.threadNumber = adapter.getItem(position).sourceModel.parentThread;
        String tabTitle = null;
        String subject = adapter.getItem(position).sourceModel.subject;
        if (subject != null && subject.length() != 0) {
            tabTitle = subject;
        } else {
            Spanned spannedComment = adapter.getItem(position).spannedComment;
            if (spannedComment != null) {
                tabTitle = spannedComment.toString().replace('\n', ' ');
                if (tabTitle.length() > MAX_TITLE_LENGHT)
                    tabTitle = tabTitle.substring(0, MAX_TITLE_LENGHT);
            }
        }
        if (tabTitle != null)
            tabTitle = resources.getString(R.string.tabs_title_threadpage_loaded, modelNewTab.boardName,
                    tabTitle);
        UrlHandler.open(modelNewTab, activity, false, tabTitle);
        return true;
    case R.id.context_menu_thread_preview:
        showThreadPreviewDialog(position);
        return true;
    case R.id.context_menu_reply_no_reading:
        UrlPageModel model = new UrlPageModel();
        model.chanName = chan.getChanName();
        model.type = UrlPageModel.TYPE_THREADPAGE;
        model.boardName = tabModel.pageModel.boardName;
        model.threadNumber = adapter.getItem(position).sourceModel.parentThread;
        openPostForm(ChanModels.hashUrlPageModel(model), presentationModel.source.boardModel,
                getSendPostModel(model));
        return true;
    case R.id.context_menu_hide:
        adapter.getItem(position).hidden = true;
        database.addHidden(tabModel.pageModel.chanName, tabModel.pageModel.boardName,
                pageType == TYPE_POSTSLIST ? tabModel.pageModel.threadNumber
                        : adapter.getItem(position).sourceModel.number,
                pageType == TYPE_POSTSLIST ? adapter.getItem(position).sourceModel.number : null);
        adapter.notifyDataSetChanged();
        return true;
    case R.id.context_menu_reply:
        openReply(position, false, null);
        return true;
    case R.id.context_menu_reply_with_quote:
        openReply(position, true, null);
        return true;
    case R.id.context_menu_select_text:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB && lastContextMenuPosition == -1) {
            int firstPosition = listView.getFirstVisiblePosition() - listView.getHeaderViewsCount();
            int wantedChild = position - firstPosition;
            if (wantedChild >= 0 && wantedChild < listView.getChildCount()) {
                View v = listView.getChildAt(wantedChild);
                if (v != null && v.getTag() != null && v.getTag() instanceof PostsListAdapter.PostViewTag) {
                    ((PostsListAdapter.PostViewTag) v.getTag()).commentView.startSelection();
                    return true;
                }
            }
        }
        Clipboard.copyText(activity, adapter.getItem(position).spannedComment.toString());
        Toast.makeText(activity, resources.getString(R.string.notification_comment_copied), Toast.LENGTH_LONG)
                .show();
        return true;
    case R.id.context_menu_share:
        UrlPageModel sharePostUrlPageModel = new UrlPageModel();
        sharePostUrlPageModel.chanName = chan.getChanName();
        sharePostUrlPageModel.type = UrlPageModel.TYPE_THREADPAGE;
        sharePostUrlPageModel.boardName = tabModel.pageModel.boardName;
        sharePostUrlPageModel.threadNumber = tabModel.pageModel.threadNumber;
        sharePostUrlPageModel.postNumber = adapter.getItem(position).sourceModel.number;

        Intent sharePostIntent = new Intent(Intent.ACTION_SEND);
        sharePostIntent.setType("text/plain");
        sharePostIntent.putExtra(Intent.EXTRA_SUBJECT, chan.buildUrl(sharePostUrlPageModel));
        sharePostIntent.putExtra(Intent.EXTRA_TEXT, adapter.getItem(position).spannedComment.toString());
        startActivity(Intent.createChooser(sharePostIntent, resources.getString(R.string.share_via)));
        return true;
    case R.id.context_menu_delete:
        DeletePostModel delModel = new DeletePostModel();
        delModel.chanName = chan.getChanName();
        delModel.boardName = tabModel.pageModel.boardName;
        delModel.threadNumber = tabModel.pageModel.threadNumber;
        delModel.postNumber = adapter.getItem(position).sourceModel.number;
        runDelete(delModel, adapter.getItem(position).sourceModel.attachments != null
                && adapter.getItem(position).sourceModel.attachments.length > 0);
        return true;
    case R.id.context_menu_report:
        DeletePostModel reportModel = new DeletePostModel();
        reportModel.chanName = chan.getChanName();
        reportModel.boardName = tabModel.pageModel.boardName;
        reportModel.threadNumber = tabModel.pageModel.threadNumber;
        reportModel.postNumber = adapter.getItem(position).sourceModel.number;
        runReport(reportModel);
        return true;
    case R.id.context_menu_subscribe:
        String chanName = chan.getChanName();
        String board = tabModel.pageModel.boardName;
        String thread = tabModel.pageModel.threadNumber;
        String post = adapter.getItem(position).sourceModel.number;
        if (subscriptions.hasSubscription(chanName, board, thread, post)) {
            subscriptions.removeSubscription(chanName, board, thread, post);
            for (int i = position; i < adapter.getCount(); ++i)
                adapter.getItem(i).onUnsubscribe(post);
        } else {
            subscriptions.addSubscription(chanName, board, thread, post);
            for (int i = position; i < adapter.getCount(); ++i)
                adapter.getItem(i).onSubscribe(post);
        }
        adapter.notifyDataSetChanged();
        return true;
    }
    return false;
}

From source file:org.brandroid.openmanager.activities.OpenExplorer.java

public boolean onClick(int id, MenuItem item, View from) {
    super.onClick(id);
    if (from == null || !from.isShown())
        from = findViewById(id);/*www  .j a v a2  s .  c  o  m*/
    if (id != R.id.title_icon && id != android.R.id.home)
        ;
    toggleBookmarks(false);
    OpenFragment f = getSelectedFragment();
    if (f != null && f.onClick(id, from))
        return true;
    if (item != null && f != null && f.onOptionsItemSelected(item))
        return true;
    if (DEBUG)
        Logger.LogDebug("OpenExplorer.onClick(0x" + Integer.toHexString(id) + "," + item + "," + from + ")");
    switch (id) {
    case R.id.menu_debug:
        debugTest();
        break;
    case R.id.title_icon:
    case android.R.id.home:
        toggleBookmarks();
        return true;

    case R.id.menu_multi:
        if (getClipboard().isMultiselect()) {
            getClipboard().stopMultiselect();
            //getClipboard().clear();
            if (!BEFORE_HONEYCOMB && mActionMode != null)
                ((ActionMode) mActionMode).finish();
            return true;
        }

        if (BEFORE_HONEYCOMB || !USE_ACTIONMODE) {
            getClipboard().startMultiselect();
        } else {
            mActionMode = startActionMode(new ActionMode.Callback() {

                public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
                    return false;
                }

                public void onDestroyActionMode(ActionMode mode) {
                    getClipboard().clear();
                    mActionMode = null;
                }

                public boolean onCreateActionMode(ActionMode mode, Menu menu) {
                    mode.setTitle(getString(R.string.s_menu_multi) + ": " + getClipboard().size() + " "
                            + getString(R.string.s_files));
                    mode.getMenuInflater().inflate(R.menu.multiselect, menu);
                    //MenuUtils.setMenuVisible(menu, false, R.id.menu_context_paste, R.id.menu_context_unzip);
                    getDirContentFragment(true).changeMultiSelectState(true);
                    return true;
                }

                public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
                    if (getClipboard().size() < 1) {
                        mode.finish();
                        return true;
                    }
                    OpenPath file = getClipboard().get(0); //getMultiSelectHandler().getSelectedFiles();

                    getClipboard().clear();

                    return getDirContentFragment(false).executeMenu(item.getItemId(), mode, file);
                }
            });
        }
        return true;

    case R.id.menu_view_carousel:
        changeViewMode(OpenExplorer.VIEW_CAROUSEL, true);
        return true;

    case R.id.menu_view_grid:
        changeViewMode(OpenExplorer.VIEW_GRID, true);
        return true;

    case R.id.menu_view_list:
        changeViewMode(OpenExplorer.VIEW_LIST, true);
        return true;

    case R.id.menu_view_fullscreen:
        getPreferences().setSetting("global", "pref_fullscreen",
                !getPreferences().getSetting("global", "pref_fullscreen", false));
        goHome();
        return true;

    case R.id.menu_view_split:
        setSetting("pref_basebar", !USE_SPLIT_ACTION_BAR);
        goHome();
        return true;

    //case R.id.menu_global_ops_text:
    //case R.id.menu_global_ops_icon:
    case R.id.title_ops:
        refreshOperations();
        showLogFrag(mOpsFragment, true);
        checkTitleSeparator();
        return true;

    case R.id.title_log:
        if (mLogFragment == null)
            mLogFragment = new LogViewerFragment();
        showLogFrag(mLogFragment, true);
        sendToLogView(null, 0);
        return true;

    /*case R.id.menu_root:
    if(RootManager.Default.isRoot())
    {
       getPreferences().setSetting("global", "pref_root", false);
       showToast(getString(R.string.s_menu_root_disabled));
       RootManager.Default.exitRoot();
       item.setChecked(false);
    } else
    {
       if(RootManager.Default.isRoot() || RootManager.Default.requestRoot())
       {
          getPreferences().setSetting("global", "pref_root", true);
          showToast(getString(R.string.s_menu_root) + "!");
          item.setTitle(getString(R.string.s_menu_root) + "!");
       } else {
          item.setChecked(false);
          showToast("Unable to achieve root.");
       }
    }
    return true;
            
    case R.id.menu_flush:
    ThumbnailCreator.flushCache(getApplicationContext(), true);
    OpenPath.flushDbCache();
    goHome();
    return true;*/

    case R.id.menu_refresh:
        ContentFragment content = getDirContentFragment(true);
        if (content != null) {
            if (DEBUG && IS_DEBUG_BUILD)
                Logger.LogDebug("Refreshing " + content.getPath().getPath());
            FileManager.removeOpenCache(content.getPath().getPath());
            content.getPath().deleteFolderFromDb();
            content.runUpdateTask(true);
            changePath(content.getPath(), false, true);
        }
        mBookmarks.refresh();
        return true;

    case R.id.menu_settings:
        showPreferences(null);
        return true;

    case R.id.menu_search:
        onSearchRequested();
        return true;

    /*case R.id.menu_favorites:
    toggleBookmarks();
    return true;*/

    case R.id.menu_multi_all_delete:
        DialogHandler.showConfirmationDialog(this,
                getResources().getString(R.string.s_confirm_delete,
                        getClipboard().getCount() + " " + getResources().getString(R.string.s_files)),
                getResources().getString(R.string.s_menu_delete_all), new DialogInterface.OnClickListener() { // yes
                    public void onClick(DialogInterface dialog, int which) {
                        getEventHandler().deleteFile(getClipboard(), OpenExplorer.this, false);
                    }
                });
        break;

    case R.id.menu_multi_all_clear:
        getClipboard().clear();
        return true;

    case R.id.menu_multi_all_copy:
        getClipboard().DeleteSource = false;
        getDirContentFragment(false).executeMenu(R.id.content_paste, null,
                getDirContentFragment(false).getPath());
        break;

    case R.id.menu_multi_all_move:
        getClipboard().DeleteSource = true;
        getDirContentFragment(false).executeMenu(R.id.content_paste, null,
                getDirContentFragment(false).getPath());
        break;

    case R.id.title_paste:
    case R.id.title_paste_icon:
    case R.id.title_paste_text:
    case R.id.content_paste:
        //if(BEFORE_HONEYCOMB)
        getClipboard().setCurrentPath(getCurrentPath());
        onClipboardDropdown(from);
        return true;

    //getDirContentFragment(false).executeMenu(R.id.menu_paste, null, mLastPath, mClipboard);
    //return true;

    case R.id.menu_about:
        DialogHandler.showAboutDialog(this);
        return true;

    case R.id.menu_exit:
        DialogHandler.showConfirmationDialog(this, getString(R.string.s_alert_exit),
                getString(R.string.s_menu_exit), getPreferences(), "exit",
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        finish();
                    }
                });
        return true;
    case R.id.menu_more:
        showMenu(mOptsMenu, ViewUtils.getFirstView(this, R.id.menu_more, R.id.base_bar, R.id.title_buttons,
                android.R.id.home), true);
        return true;

    default:
        if (f instanceof ContentFragment) {
            ContentFragment cf = (ContentFragment) f;
            if (item.getMenuInfo() != null && cf.onContextItemSelected(item))
                return true;
            else if (cf.onClick(id, from))
                return true;
            else if (cf.onOptionsItemSelected(item))
                return true;
            return cf.executeMenu(id, null, getDirContentFragment(false).getPath());
        } else if (f instanceof TextEditorFragment)
            ((TextEditorFragment) f).onClick(id, from);
        else if (f.onOptionsItemSelected(item))
            return true;
    }

    //showToast("oops");
    return false;
    //return super.onOptionsItemSelected(item);
}