Example usage for android.view MenuItem isChecked

List of usage examples for android.view MenuItem isChecked

Introduction

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

Prototype

public boolean isChecked();

Source Link

Document

Return whether the item is currently displaying a check mark.

Usage

From source file:de.badaix.snapcast.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        ServerDialogFragment serverDialogFragment = new ServerDialogFragment();
        serverDialogFragment.setHost(Settings.getInstance(this).getHost(),
                Settings.getInstance(this).getStreamPort(), Settings.getInstance(this).getControlPort());
        serverDialogFragment.setAutoStart(Settings.getInstance(this).isAutostart());
        serverDialogFragment.setListener(new ServerDialogFragment.ServerDialogListener() {
            @Override//w ww. j  a  va 2  s .  c o  m
            public void onHostChanged(String host, int streamPort, int controlPort) {
                setHost(host, streamPort, controlPort);
                startRemoteControl();
            }

            @Override
            public void onAutoStartChanged(boolean autoStart) {
                Settings.getInstance(MainActivity.this).setAutostart(autoStart);
            }
        });
        serverDialogFragment.show(getSupportFragmentManager(), "serverDialogFragment");
        //            NsdHelper.getInstance(this).startListening("_snapcast._tcp.", SERVICE_NAME, this);
        return true;
    } else if (id == R.id.action_play_stop) {
        if (bound && snapclientService.isRunning()) {
            stopSnapclient();
        } else {
            item.setEnabled(false);
            startSnapclient();
        }
        return true;
    } else if (id == R.id.action_hide_offline) {
        item.setChecked(!item.isChecked());
        Settings.getInstance(this).put("hide_offline", item.isChecked());
        sectionsPagerAdapter.setHideOffline(item.isChecked());
        return true;
    } else if (id == R.id.action_refresh) {
        startRemoteControl();
        remoteControl.getServerStatus();
    } else if (id == R.id.action_about) {
        Intent intent = new Intent(this, AboutActivity.class);
        startActivity(intent);
    }

    return super.onOptionsItemSelected(item);
}

From source file:com.morlunk.mumbleclient.channel.ChannelMenu.java

@Override
public boolean onMenuItemClick(MenuItem item) {
    boolean adding = false;
    switch (item.getItemId()) {
    case R.id.context_channel_join:
        mService.joinChannel(mChannel.getId());
        break;//from w  w  w.  ja  va  2s  .c  o  m
    case R.id.context_channel_add:
        adding = true;
    case R.id.context_channel_edit:
        ChannelEditFragment addFragment = new ChannelEditFragment();
        Bundle args = new Bundle();
        if (adding)
            args.putInt("parent", mChannel.getId());
        else
            args.putInt("channel", mChannel.getId());
        args.putBoolean("adding", adding);
        addFragment.setArguments(args);
        addFragment.show(mFragmentManager, "ChannelAdd");
        break;
    case R.id.context_channel_remove:
        AlertDialog.Builder adb = new AlertDialog.Builder(mContext);
        adb.setTitle(R.string.confirm);
        adb.setMessage(R.string.confirm_delete_channel);
        adb.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                mService.removeChannel(mChannel.getId());
            }
        });
        adb.setNegativeButton(android.R.string.cancel, null);
        adb.show();
        break;
    case R.id.context_channel_view_description:
        Bundle commentArgs = new Bundle();
        commentArgs.putInt("channel", mChannel.getId());
        commentArgs.putString("comment", mChannel.getDescription());
        commentArgs.putBoolean("editing", false);
        DialogFragment commentFragment = (DialogFragment) Fragment.instantiate(mContext,
                ChannelDescriptionFragment.class.getName(), commentArgs);
        commentFragment.show(mFragmentManager, ChannelDescriptionFragment.class.getName());
        break;
    case R.id.context_channel_pin:
        long serverId = mService.getConnectedServer().getId();
        boolean pinned = mDatabase.isChannelPinned(serverId, mChannel.getId());
        if (!pinned)
            mDatabase.addPinnedChannel(serverId, mChannel.getId());
        else
            mDatabase.removePinnedChannel(serverId, mChannel.getId());
        break;
    case R.id.context_channel_link: {
        IChannel channel = mService.getSessionChannel();
        if (!item.isChecked()) {
            mService.linkChannels(channel, mChannel);
        } else {
            mService.unlinkChannels(channel, mChannel);
        }
        break;
    }
    case R.id.context_channel_unlink_all:
        mService.unlinkAllChannels(mChannel);
        break;
    case R.id.context_channel_shout: {
        AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
        builder.setTitle(R.string.shout_configure);
        LinearLayout layout = new LinearLayout(mContext);
        layout.setOrientation(LinearLayout.VERTICAL);

        final CheckBox subchannelBox = new CheckBox(mContext);
        subchannelBox.setText(R.string.shout_include_subchannels);
        layout.addView(subchannelBox);

        final CheckBox linkedBox = new CheckBox(mContext);
        linkedBox.setText(R.string.shout_include_linked);
        layout.addView(linkedBox);

        builder.setView(layout);
        builder.setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                if (mService == null
                        || mService.getConnectionState() != JumbleService.ConnectionState.CONNECTED)
                    return;

                // Unregister any existing voice target.
                if (mService.getVoiceTargetMode() == VoiceTargetMode.WHISPER) {
                    mService.unregisterWhisperTarget(mService.getVoiceTargetId());
                }

                WhisperTargetChannel channelTarget = new WhisperTargetChannel(mChannel, linkedBox.isChecked(),
                        subchannelBox.isChecked(), null);
                byte id = mService.registerWhisperTarget(channelTarget);
                if (id > 0) {
                    mService.setVoiceTargetId(id);
                } else {
                    Toast.makeText(mContext, R.string.shout_failed, Toast.LENGTH_LONG).show();
                }
            }
        });
        builder.setNegativeButton(android.R.string.cancel, null);
        builder.show();

        break;
    }
    default:
        return false;
    }
    return true;
}

From source file:org.secu3.android.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_dashboard:
        if (!AndEngine.isDeviceSupported(this)) {
            new AlertDialog.Builder(this).setTitle(R.string.dialog_device_not_supported_title)
                    .setMessage(R.string.dialog_device_not_supported_title)
                    .setIcon(android.R.drawable.ic_dialog_alert).setPositiveButton(android.R.string.ok, null)
                    .create().show();//www  . j av a2  s  .  com
        } else
            startActivity(new Intent(this, DashBoardActivity.class));
        return true;
    case R.id.menu_preferences:
        startActivity(new Intent(this, SettingsActivity.class));
        return true;
    case R.id.menu_params:
        startActivity(new Intent(this, ParamActivity.class));
        return true;
    case R.id.menu_errors:
        startActivity(new Intent(this, ErrorsActivity.class));
        return true;
    case R.id.menu_exit:
        Secu3Service.secu3Notification.notificationManager.cancelAll();
        startService(new Intent(Secu3Service.ACTION_SECU3_SERVICE_STOP, Uri.EMPTY, this, Secu3Service.class));
        return true;
    case R.id.menu_diagnostics:
        new AlertDialog.Builder(this).setTitle(android.R.string.dialog_alert_title)
                .setIcon(android.R.drawable.ic_dialog_alert).setMessage(R.string.menu_diagnostics_warning_title)
                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        if ((fwOptions == Integer.MIN_VALUE)
                                || ((fwOptions & (1 << Secu3Packet.COPT_DIAGNOSTICS)) == 0)) {
                            Toast.makeText(getApplicationContext(), R.string.diagnostics_not_supported_title,
                                    Toast.LENGTH_LONG).show();
                        }
                        startActivity(new Intent(getApplicationContext(), DiagnosticsActivity.class));
                    }
                }).setNegativeButton(android.R.string.cancel, null).create().show();
        return true;
    case R.id.menu_raw_sensors:
        item.setChecked(rawSensors = !item.isChecked());
        setRawMode(rawSensors);
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:de.azapps.mirakel.main_activity.MainActivity.java

@Override
public boolean onOptionsItemSelected(final MenuItem item) {
    if (this.mDrawerToggle.onOptionsItemSelected(item)) {
        return true;
    }/*  www  .j  a  va  2 s .  c o m*/
    switch (item.getItemId()) {
    case R.id.menu_delete:
        handleDestroyTask(this.currentTask);
        updateShare();
        return true;
    case R.id.menu_move:
        handleMoveTask(this.currentTask);
        return true;
    case R.id.list_delete:
        handleDestroyList(this.currentList);
        return true;
    case R.id.task_sorting:
        this.currentList = ListDialogHelpers.handleSortBy(this, this.currentList, new Helpers.ExecInterface() {
            @Override
            public void exec() {
                setCurrentList(MainActivity.this.currentList);
            }
        }, null);
        return true;
    case R.id.menu_new_list:
        getListFragment().editList(null);
        return true;
    case R.id.menu_sort_lists:
        final boolean t = !item.isChecked();
        getListFragment().enableDrop(t);
        item.setChecked(t);
        return true;
    case R.id.menu_settings:
        final Intent intent = new Intent(MainActivity.this, SettingsActivity.class);
        startActivityForResult(intent, MainActivity.RESULT_SETTINGS);
        break;
    case R.id.menu_contact:
        Helpers.contact(this);
        break;
    case R.id.menu_new_ui:
        MirakelCommonPreferences.setUseNewUI(true);
        Helpers.restartApp(this);
        break;
    case R.id.menu_sync_now:
        final Bundle bundle = new Bundle();
        bundle.putBoolean(ContentResolver.SYNC_EXTRAS_DO_NOT_RETRY, true);
        bundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true);
        bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
        new Thread(new Runnable() {
            @SuppressLint("InlinedApi")
            @Override
            public void run() {
                final List<AccountMirakel> accounts = AccountMirakel.getEnabled(true);
                for (final AccountMirakel a : accounts) {
                    // davdroid accounts should be there only from
                    // API>=14...
                    ContentResolver.requestSync(a.getAndroidAccount(), DefinitionsHelper.AUTHORITY_TYP, bundle);
                }
            }
        }).start();
        break;
    case R.id.share_task:
        SharingHelper.share(this, getCurrentTask());
        break;
    case R.id.share_list:
        SharingHelper.share(this, getCurrentList());
        break;
    case R.id.search:
        onSearchRequested();
        break;
    case R.id.menu_undo:
        UndoHistory.undoLast(this);
        updateCurrentListAndTask();
        if (this.currentPosition == getTaskFragmentPosition()) {
            setCurrentTask(this.currentTask);
        } else if ((getListFragment() != null) && (getTasksFragment() != null)
                && (getListFragment().getAdapter() != null) && (getTasksFragment().getAdapter() != null)) {
            getListFragment().getAdapter().changeData(ListMirakel.all());
            getListFragment().getAdapter().notifyDataSetChanged();
            getTasksFragment().getAdapter().notifyDataSetChanged();
            if (!MirakelCommonPreferences.isTablet()
                    && (this.currentPosition == MainActivity.getTasksFragmentPosition())) {
                setCurrentList(getCurrentList());
            }
        }
        break;
    case R.id.mark_as_subtask:
        TaskDialogHelpers.handleSubtask(this, this.currentTask, null, true);
        break;
    case R.id.menu_task_clone:
        try {
            final Task newTask = this.currentTask.create();
            setCurrentTask(newTask, true);
            getListFragment().update();
            updatesForTask(newTask);
        } catch (final NoSuchListException e) {
            Log.wtf(MainActivity.TAG, "List vanished on task cloning");
        }
        break;
    default:
        return super.onOptionsItemSelected(item);
    }
    return true;
}

From source file:org.catnut.fragment.TweetFragment.java

@Override
public boolean onMenuItemClick(MenuItem item) {
    // first check emotions
    if (item.getItemId() == R.id.action_emotions) {
        GridView emotions = (GridView) LayoutInflater.from(getActivity()).inflate(R.layout.emotions, null);
        emotions.setAdapter(new EmotionsAdapter(getActivity()));
        emotions.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override//w w  w. j a  v a 2s  .  c  o  m
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                int cursor = mSendText.getSelectionStart();
                mSendText.getText().insert(cursor,
                        CatnutUtils.text2Emotion(getActivity(), TweetImageSpan.EMOTION_KEYS[position],
                                getResources().getInteger(R.integer.icon_bound_px)));
                mSendText.requestFocus();
            }
        });
        AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).setView(emotions).create();
        alertDialog.show();
        alertDialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT,
                getResources().getDimensionPixelSize(R.dimen.emotion_window_height));
        return true;
    }
    switch (item.getItemId()) {
    case R.id.action_reply_none:
        mRetweetOption = 0;
        break;
    case R.id.action_reply_current:
        mRetweetOption = 1;
        break;
    case R.id.action_reply_original:
        mRetweetOption = 2;
        break;
    case R.id.action_reply_both:
        mRetweetOption = 3;
        break;
    default:
        break;
    }
    if (!item.isChecked()) {
        item.setChecked(true);
    }
    return true;
}

From source file:com.android.contacts.quickcontact.QuickContactActivity.java

private void toggleStar(MenuItem starredMenuItem) {
    // Make sure there is a contact
    if (mContactData != null) {
        // Read the current starred value from the UI instead of using the last
        // loaded state. This allows rapid tapping without writing the same
        // value several times
        final boolean isStarred = starredMenuItem.isChecked();

        // To improve responsiveness, swap out the picture (and tag) in the UI already
        ContactDisplayUtils.configureStarredMenuItem(starredMenuItem, mContactData.isDirectoryEntry(),
                mContactData.isUserProfile(), !isStarred);

        // Now perform the real save
        final Intent intent = ContactSaveService.createSetStarredIntent(QuickContactActivity.this,
                mContactData.getLookupUri(), !isStarred);
        startService(intent);/*www.jav  a2  s .c  om*/

        final CharSequence accessibilityText = !isStarred
                ? getResources().getText(R.string.description_action_menu_add_star)
                : getResources().getText(R.string.description_action_menu_remove_star);
        // Accessibility actions need to have an associated view. We can't access the MenuItem's
        // underlying view, so put this accessibility action on the root view.
        mScroller.announceForAccessibility(accessibilityText);
    }
}

From source file:com.nononsenseapps.feeder.ui.FeedFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
    final long id = menuItem.getItemId();
    if (id == R.id.action_sync) {
        // Sync all feeds when menu button pressed
        RssContentProvider.RequestSync();
        return true;
    } else if (id == R.id.action_edit_feed && this.id > 0) {
        Intent i = new Intent(getActivity(), EditFeedActivity.class);
        // TODO do not animate the back movement here
        i.putExtra(EditFeedActivity.SHOULD_FINISH_BACK, true);
        i.putExtra(EditFeedActivity._ID, this.id);
        i.putExtra(EditFeedActivity.TITLE, customTitle);
        i.putExtra(EditFeedActivity.TAG, tag);
        i.setData(Uri.parse(url));//from   w w  w .j  a  v a2 s.co  m
        startActivity(i);
        return true;
    } else if (id == R.id.action_add_templated && this.id > 0) {
        Intent i = new Intent(getActivity(), EditFeedActivity.class);
        // TODO do not animate the back movement here
        i.putExtra(EditFeedActivity.SHOULD_FINISH_BACK, true);
        i.putExtra(EditFeedActivity.TEMPLATE, true);
        //i.putExtra(EditFeedActivity.TITLE, title);
        i.putExtra(EditFeedActivity.TAG, tag);
        i.setData(Uri.parse(url));
        startActivity(i);
        return true;
    } else if (id == R.id.action_delete_feed && this.id > 0) {
        getActivity().getContentResolver().delete(FeedSQL.URI_FEEDS, Util.WHEREIDIS,
                Util.LongsToStringArray(this.id));
        RssContentProvider.notifyAllUris(getActivity());

        // Tell activity to open another fragment
        ((FeedActivity) getActivity()).loadFirstFeedInDB(true);
        return true;
    }
    //        else if (id == R.id.action_mark_as_read) {
    //            markAsRead();
    //            return true;
    //        }
    else if (id == R.id.action_only_unread) {
        final boolean onlyUnread = !menuItem.isChecked();
        PrefUtils.setPrefShowOnlyUnread(getActivity(), onlyUnread);
        menuItem.setChecked(onlyUnread);
        if (onlyUnread) {
            menuItem.setIcon(R.drawable.ic_action_visibility_off);
        } else {
            menuItem.setIcon(R.drawable.ic_action_visibility);
        }

        menuItem.setTitle(onlyUnread ? R.string.show_unread_items : R.string.show_all_items);
        //getActivity().invalidateOptionsMenu();
        // Restart loader
        getLoaderManager().restartLoader(FEEDITEMS_LOADER, new Bundle(), this);
        return true;
    } else {
        return super.onOptionsItemSelected(menuItem);
    }
}

From source file:org.yaaic.fragment.ConversationFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.disconnect:
        server.setStatus(Status.DISCONNECTED);
        server.setMayReconnect(false);/*w  w w.ja v a2  s .com*/
        binder.getService().getConnection(serverId).quitServer();
        server.clearConversations();
        break;

    case R.id.close:
        Conversation conversationToClose = pagerAdapter.getItem(pager.getCurrentItem());
        // Make sure we part a channel when closing the channel conversation
        if (conversationToClose.getType() == Conversation.TYPE_CHANNEL) {
            binder.getService().getConnection(serverId).partChannel(conversationToClose.getName());
        } else if (conversationToClose.getType() == Conversation.TYPE_QUERY) {
            server.removeConversation(conversationToClose.getName());
            onRemoveConversation(conversationToClose.getName());
        } else {
            Toast.makeText(getActivity(), getResources().getString(R.string.close_server_window),
                    Toast.LENGTH_SHORT).show();
        }
        break;

    case R.id.join:
        startActivityForResult(new Intent(getActivity(), JoinActivity.class), REQUEST_CODE_JOIN);
        break;

    case R.id.users:
        Conversation conversationForUserList = pagerAdapter.getItem(pager.getCurrentItem());
        if (conversationForUserList.getType() == Conversation.TYPE_CHANNEL) {
            Intent intent = new Intent(getActivity(), UsersActivity.class);
            intent.putExtra(Extra.USERS, binder.getService().getConnection(server.getId())
                    .getUsersAsStringArray(conversationForUserList.getName()));
            startActivityForResult(intent, REQUEST_CODE_USERS);
        } else {
            Toast.makeText(getActivity(), getResources().getString(R.string.only_usable_from_channel),
                    Toast.LENGTH_SHORT).show();
        }
        break;

    case R.id.notify:
        Conversation conversationForNotify = pagerAdapter.getItem(pager.getCurrentItem());
        conversationForNotify.setAlwaysNotify(!item.isChecked());
        break;
    }

    return true;
}

From source file:org.mariotaku.twidere.activity.support.ComposeActivity.java

@Override
public boolean onMenuItemClick(final MenuItem item) {
    switch (item.getItemId()) {
    case MENU_TAKE_PHOTO:
    case R.id.take_photo_sub_item: {
        takePhoto();/*  www . j av a2  s.  c  o m*/
        break;
    }
    case MENU_ADD_IMAGE:
    case R.id.add_image_sub_item: {
        pickImage();
        break;
    }
    case MENU_ADD_LOCATION: {
        toggleLocation();
        break;
    }
    case MENU_DRAFTS: {
        Utils.openDrafts(this);
        break;
    }
    case MENU_DELETE: {
        AsyncTaskUtils.executeTask(new DeleteImageTask(this));
        break;
    }
    case MENU_TOGGLE_SENSITIVE: {
        if (!hasMedia())
            return false;
        mIsPossiblySensitive = !mIsPossiblySensitive;
        setMenu();
        updateTextCount();
        break;
    }
    case MENU_VIEW: {
        if (mInReplyToStatus == null)
            return false;
        final DialogFragment fragment = new ViewStatusDialogFragment();
        final Bundle args = new Bundle();
        args.putParcelable(EXTRA_STATUS, mInReplyToStatus);
        fragment.setArguments(args);
        fragment.show(getSupportFragmentManager(), "view_status");
        break;
    }
    case R.id.link_to_quoted_status: {
        final boolean newValue = !item.isChecked();
        item.setChecked(newValue);
        mPreferences.edit().putBoolean(KEY_LINK_TO_QUOTED_TWEET, newValue).apply();
        break;
    }
    default: {
        final Intent intent = item.getIntent();
        if (intent != null) {
            try {
                final String action = intent.getAction();
                if (INTENT_ACTION_EXTENSION_COMPOSE.equals(action)) {
                    final long[] accountIds = mAccountsAdapter.getSelectedAccountIds();
                    intent.putExtra(EXTRA_TEXT, ParseUtils.parseString(mEditText.getText()));
                    intent.putExtra(EXTRA_ACCOUNT_IDS, accountIds);
                    if (accountIds.length > 0) {
                        final long account_id = accountIds[0];
                        intent.putExtra(EXTRA_NAME, Utils.getAccountName(this, account_id));
                        intent.putExtra(EXTRA_SCREEN_NAME, Utils.getAccountScreenName(this, account_id));
                    }
                    if (mInReplyToStatusId > 0) {
                        intent.putExtra(EXTRA_IN_REPLY_TO_ID, mInReplyToStatusId);
                    }
                    if (mInReplyToStatus != null) {
                        intent.putExtra(EXTRA_IN_REPLY_TO_NAME, mInReplyToStatus.user_name);
                        intent.putExtra(EXTRA_IN_REPLY_TO_SCREEN_NAME, mInReplyToStatus.user_screen_name);
                    }
                    startActivityForResult(intent, REQUEST_EXTENSION_COMPOSE);
                } else if (INTENT_ACTION_EXTENSION_EDIT_IMAGE.equals(action)) {
                    // final ComponentName cmp = intent.getComponent();
                    // if (cmp == null || !hasMedia()) return false;
                    // final String name = new
                    // File(mMediaUri.getPath()).getName();
                    // final Uri data =
                    // Uri.withAppendedPath(CacheFiles.CONTENT_URI,
                    // Uri.encode(name));
                    // intent.setData(data);
                    // grantUriPermission(cmp.getPackageName(), data,
                    // Intent.FLAG_GRANT_READ_URI_PERMISSION);
                    // startActivityForResult(intent,
                    // REQUEST_EDIT_IMAGE);
                } else {
                    startActivity(intent);
                }
            } catch (final ActivityNotFoundException e) {
                Log.w(LOGTAG, e);
                return false;
            }
        }
        break;
    }
    }
    return true;
}

From source file:com.aimfire.gallery.GalleryActivity.java

/**
 * Override Activity lifecycle method.//w  w w .  j a  v a 2s .c o  m
 */
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    Intent intent;

    /* 
     * if user interacted with action bar, delay any scheduled hide()
     * operations to prevent the jarring behavior of controls going away
     * while interacting with the UI.
     */
    if (AUTO_HIDE) {
        delayedHide(AUTO_HIDE_DELAY_SHORT_MILLIS);
    }

    switch (item.getItemId()) {
    case android.R.id.home:
        intent = new Intent(GalleryActivity.this, MainActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.putExtra(MainConsts.EXTRA_MSG, mIsMyMedia);
        startActivity(intent);
        break;
    case R.id.action_share:
        createDriveLink();
        break;
    case R.id.action_thumb_view:
        switchThumbView();
        break;
    case R.id.action_delete:
        deleteFile();
        break;
    case R.id.action_anaglyph:
        if (!item.isChecked()) {
            mDisplayMode = DisplayMode.Anaglyph;
            if (item.getTitle().equals(getString(R.string.action_anaglyph_cyanred))) {
                mDisplaySwap = true;
            } else {
                mDisplaySwap = false;
            }

            item.setChecked(true);
            updateDisplayPrefs();
            invalidateOptionsMenu();
            switchDisplayMode();
        }
        break;
    case R.id.action_sbs:
        if (!item.isChecked()) {
            mDisplayMode = DisplayMode.SbsFull;
            if (item.getTitle().equals(getString(R.string.action_sbs_cross))) {
                mDisplaySwap = true;
            } else {
                mDisplaySwap = false;
            }

            item.setChecked(true);
            updateDisplayPrefs();
            invalidateOptionsMenu();
            switchDisplayMode();
        }
        break;
    case R.id.action_3dtv:
        if (!item.isChecked()) {
            mDisplayMode = DisplayMode.SbsHalf;
            item.setChecked(true);
            updateDisplayPrefs();
            invalidateOptionsMenu();
            switchDisplayMode();
        }
        break;
    case R.id.action_swap:
        if (item.isChecked()) {
            mDisplaySwap = false;
            item.setChecked(false);
        } else {
            mDisplaySwap = true;
            item.setChecked(true);
        }
        updateDisplayPrefs();
        invalidateOptionsMenu();
        switchDisplayMode();
        break;
    case R.id.action_grayscale:
        if (item.isChecked()) {
            mDisplayColor = true;
            item.setChecked(false);
        } else {
            mDisplayColor = false;
            item.setChecked(true);
        }
        updateDisplayPrefs();
        invalidateOptionsMenu();
        switchDisplayMode();
        break;
    default:
        return super.onOptionsItemSelected(item);
    }
    return true;
}