Example usage for android.view MenuItem setCheckable

List of usage examples for android.view MenuItem setCheckable

Introduction

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

Prototype

public MenuItem setCheckable(boolean checkable);

Source Link

Document

Control whether this item can display a check mark.

Usage

From source file:nz.ac.auckland.lablet.ExperimentRunViewManager.java

/**
 * Show a menu to enable or disable sensors.
 *///w w w .  ja  va2s  .c om
private void showSensorMenu() {
    View menuView = findViewById(R.id.action_sensors);
    PopupMenu popup = new PopupMenu(menuView.getContext(), menuView);

    final List<ISensorPlugin> plugins = ExperimentPluginFactory.getFactory().getSensorPlugins();
    for (int i = 0; i < plugins.size(); i++) {
        ISensorPlugin plugin = plugins.get(i);

        MenuItem item = popup.getMenu().add(1, i, i, plugin.getSensorName());
        item.setCheckable(true);

        if (getExperiment(plugin) != null)
            item.setChecked(true);
    }

    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem menuItem) {
            ISensorPlugin plugin = plugins.get(menuItem.getItemId());
            IExperimentSensor experimentSensor = getExperiment(plugin);
            if (experimentSensor != null)
                removeExperimentRun(experimentSensor);
            else
                addExperiment(plugin);
            return true;
        }
    });

    popup.show();
}

From source file:nz.ac.auckland.lablet.ExperimentRunViewManager.java

private void showViewMenu() {
    View menuView = findViewById(R.id.action_view);
    PopupMenu popup = new PopupMenu(menuView.getContext(), menuView);

    final List<IExperimentSensor> experimentRuns = getActiveSensors();
    for (int i = 0; i < experimentRuns.size(); i++) {
        IExperimentSensor experiment = experimentRuns.get(i);

        MenuItem item = popup.getMenu().add(1, i, i, experiment.getClass().getSimpleName());
        item.setCheckable(true);
    }/*from  w ww.  j  a v a  2s .c  o m*/
    popup.getMenu().setGroupCheckable(1, true, true);
    IExperimentSensor currentExperimentSensor = experiment.getCurrentExperimentSensor();
    if (currentExperimentSensor != null)
        popup.getMenu().getItem(experimentRuns.indexOf(currentExperimentSensor)).setChecked(true);
    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem menuItem) {
            int itemPosition = menuItem.getItemId();
            IExperimentSensor experimentRun = experimentRuns.get(itemPosition);
            setCurrentSensor(experimentRun);
            pager.requestLayout();
            pager.setCurrentItem(itemPosition, true);
            return true;
        }
    });

    popup.show();
}

From source file:com.he5ed.lib.cloudprovider.picker.CloudPickerActivity.java

/**
 * @hide//from   w ww.  j  a va  2s .co  m
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.cp_activity_picker);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    // lock right drawer from been swiped open
    drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, GravityCompat.END);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar,
            R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    navigationView.setItemIconTintList(null); // remove the auto grey tint to keep icon color
    Menu menu = navigationView.getMenu();
    CloudProvider cloudProvider = CloudProvider.getInstance(this);
    // check whether individual account is assigned
    String accountId = getIntent().getStringExtra(EXTRA_PICK_ACCOUNT_ID);
    if (!TextUtils.isEmpty(accountId)) {
        mAccounts = new CloudAccount[1];
        mAccounts[0] = cloudProvider.getAccountById(accountId);
    } else {
        mAccounts = cloudProvider.getCloudAccounts();
    }
    // populate navigation menu
    for (int i = 0; i < mAccounts.length; i++) {
        CloudAccount account = mAccounts[i];
        MenuItem item = menu.add(0, i, 0, account.getUser().email);
        // use cloud API class reflection
        try {
            Class clazz = Class.forName(account.api);
            Field iconResource = clazz.getField("ICON_RESOURCE");
            item.setIcon(iconResource.getInt(null));
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
            item.setIcon(R.drawable.ic_cloud_black_24dp);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }

        item.setCheckable(true);
    }

    mFragmentManager = getSupportFragmentManager();
    mItemFragment = (ItemFragment) mFragmentManager.findFragmentById(R.id.right_drawer_view);
    if (mItemFragment == null) {
        mItemFragment = new ItemFragment();
        mFragmentManager.beginTransaction().add(R.id.right_drawer_view, mItemFragment).commit();
    }

    mProgressBar = (ProgressBar) findViewById(R.id.progress_bar);
    mErrorView = (LinearLayout) findViewById(R.id.error_view);
    if (savedInstanceState != null) {
        switch (savedInstanceState.getInt("empty_view_visibility")) {
        case View.VISIBLE:
            mErrorView.setVisibility(View.VISIBLE);
            ImageView icon = (ImageView) mErrorView.findViewById(R.id.empty_icon_image_view);
            TextView title = (TextView) mErrorView.findViewById(R.id.empty_title_text_view);
            TextView detail = (TextView) mErrorView.findViewById(R.id.empty_detail_text_view);
            Bitmap bitmap = savedInstanceState.getParcelable("icon_drawable");
            icon.setImageBitmap(bitmap);
            title.setText(savedInstanceState.getCharSequence("title_text"));
            detail.setText(savedInstanceState.getCharSequence("detail_text"));
            break;
        case View.INVISIBLE:
            mErrorView.setVisibility(View.INVISIBLE);
            break;
        case View.GONE:
            mErrorView.setVisibility(View.GONE);
            break;
        }
    } else {
        // open drawer on first load
        drawer.openDrawer(GravityCompat.START);
    }
}

From source file:com.thanhle.englishvocabulary.activity.MyActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_my);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

    mNavigationView1 = (NavigationView) findViewById(R.id.nav_view);
    mNavigationView1.getMenu().getItem(0).setCheckable(false);
    mNavigationView1.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
        @Override/* w  w w . j a  v a 2s  .  c o  m*/
        public boolean onNavigationItemSelected(MenuItem menuItem) {
            //                menuItem.setChecked(true);
            menuItem.setCheckable(false);
            switch (menuItem.getItemId()) {
            //change user profile
            case R.id.navigation_item_1:
                Intent updateProfile = new Intent(MyActivity.this, UpdateProfileActivity.class);
                startActivity(updateProfile);
                closeDrawer();
                return true;
            //change library
            case R.id.navigation_item_2:
                //                        ArrayList<LibraryTable> libraries = new ArrayList<LibraryTable>();
                //                        for (int j = 0; j < Consts.LIST_LIBRARY.size(); j++) {
                //                            LibraryTable libraryTable = new LibraryTable(Consts.LIST_LIBRARY.get(j).getName(), Consts.LIST_LIBRARY.get(j).getName());
                //                            libraries.add(libraryTable);
                //                        }
                //
                //                        LibraryListDialog.newInstance(libraries, MyActivity.this).show(
                //                                getSupportFragmentManager(), null);

                ArrayList<LibraryTable> libraries = database.getListMyLibrary();
                libraries.add(0, new LibraryTable(Consts.MY_LIBRARY, getString(R.string.my_library)));
                LibraryListDialog.newInstance(libraries, MyActivity.this).show(getSupportFragmentManager(),
                        null);

                return true;

            // library online
            case R.id.navigation_item_3:
                //                        SearchLibraryDialog.newInstance(MyActivity.this, "Search Library", "").show(getSupportFragmentManager(), null);

                if (isConnectInternet()) {
                    Intent libraryOnline = new Intent(MyActivity.this, ListLibraryActivity.class);
                    startActivity(libraryOnline);
                    mDrawerLayout.closeDrawer(GravityCompat.START);
                } else {
                    Toast.makeText(MyActivity.this, getString(R.string.network_error), Toast.LENGTH_SHORT)
                            .show();
                }
                return true;

            //logout
            case R.id.navigation_item_4:
                mSharePrefs.clear();
                database.clearAllWords();
                database.clearAllCards();
                database.clearAllLibrary();
                finish();
                Intent i = new Intent(MyActivity.this, SplashActivity.class);
                startActivity(i);
                return true;
            default:
                return true;
            }

        }
    });

    setUpToolbar();

    CircularImageView imgUserAvatar = (CircularImageView) findViewById(R.id.imgUserAvatar);
    String url = "";
    if (mSharePrefs.getUserInfo().provider.equalsIgnoreCase("google")) {
        url = convertLinkImage(mSharePrefs.get(Consts.LINK_PICTURE, "http://imgur.com/Q54I5IC.png"));
    } else {
        url = mSharePrefs.get(Consts.LINK_PICTURE, "http://i.imgur.com/Q54I5IC.png");
    }
    Picasso.with(this).load(url).placeholder(R.drawable.img_icon_user_avatar).transform(new RoundTransform())
            .into(imgUserAvatar);
    //        new LoadProfileImage(imgUserAvatar).execute();

    TextView tvUserName = (TextView) findViewById(R.id.tv_username_layout_user_drawer_header);
    UserResource user = mSharePrefs.getUserInfo();
    if (user != null) {
        if (user.fullname != null && !user.fullname.equalsIgnoreCase("")) {
            tvUserName.setText(user.fullname);
        } else {
            tvUserName.setText(user.username);
        }
    }

    //get list library from server
    if (Consts.LIST_LIBRARY.size() == 0 && isConnectInternet()) {
        Bundle bundle = new Bundle();
        bundle.putString(Consts.PARAMConsts.TOKEN, mSharePrefs.getToken());
        mRequestManager.request(Actions.GETLISTLIBRARY, bundle, mGetListLibrarySuccessListener,
                mGetListLibraryErrorListener);
    }

    initialiseBilling();

    mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(Wearable.API).addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this).build();

    // get screen width and set width of Navigation Drawer layout width is 4/5 screen width
    int screenWidth = AppUtils.getScreenSize(this)[0];
    DrawerLayout.LayoutParams lp = (DrawerLayout.LayoutParams) findViewById(R.id.dictionary_drawer)
            .getLayoutParams();
    //        DrawerLayout.LayoutParams lp2 = (DrawerLayout.LayoutParams) findViewById(R.id.user_drawer).getLayoutParams();
    lp.width = screenWidth / 5 * 4;
    //        lp2.width = screenWidth / 5 * 3;

    mDictionaryDrawerFragment = (DictionaryDrawerFragment) getSupportFragmentManager()
            .findFragmentById(R.id.dictionary_drawer);
    //        mUserDrawerFragment = (UserDrawerFragment)
    //                getSupportFragmentManager().findFragmentById(R.id.user_drawer);
    mTitle = getTitle();

    // Set up the drawer.
    mDictionaryDrawerFragment.setUp(R.id.dictionary_drawer, (DrawerLayout) findViewById(R.id.drawer_layout));
    //        mUserDrawerFragment.setUp(
    //                R.id.user_drawer,
    //                (DrawerLayout) findViewById(R.id.drawer_layout));

    if (savedInstanceState != null) {
        mDialogRate = (RateMeDialog) getSupportFragmentManager().findFragmentByTag(DIALOG_TAG_RATE);
        mDialogAddCard = (AddCardDialog) getSupportFragmentManager().findFragmentByTag(DIALOG_ADD_CARD);
        mDialogCardPicker = (ConfirmDialog) getSupportFragmentManager()
                .findFragmentByTag(DIALOG_TAG_CARD_PICKER);
        mDialogLearnAll = (ConfirmDialog) getSupportFragmentManager().findFragmentByTag(DIALOG_TAG_LEARN_ALL);
        mFragment = (MainFragment) getSupportFragmentManager().findFragmentById(R.id.container);
    } else {
        mFragment = new MainFragment();
        FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
        fragmentTransaction.add(R.id.container, mFragment);
        fragmentTransaction.commit();
    }
}

From source file:com.ruesga.rview.MainActivity.java

private void updateAccountCustomFilters() {
    // Remove all custom filters and re-add them
    final DrawerNavigationMenu menu = (DrawerNavigationMenu) mBinding.drawerNavigationView.getMenu();
    int myFiltersGroupIndex = menu.findGroupIndex(R.id.category_my_filters);
    MenuItem group = menu.getItem(myFiltersGroupIndex);
    SubMenu myFiltersSubMenu = group.getSubMenu();
    int count = myFiltersSubMenu.size() - 1;
    for (int i = count; i >= 0; i--) {
        ((DrawerNavigationSubMenu) myFiltersSubMenu).removeItemAt(i);
    }// ww  w. j a v  a  2s  .c o m

    mCustomFilters = Preferences.getAccountCustomFilters(this, mAccount);
    if (mCustomFilters != null) {
        int i = 0;
        for (CustomFilter filter : mCustomFilters) {
            int id = MY_FILTERS_GROUP_BASE_ID + i;
            String title = filter.mName + DrawerNavigationView.SEPARATOR + filter.mQuery.toString()
                    + DrawerNavigationView.SEPARATOR + "ic_close";
            MenuItem item = myFiltersSubMenu.add(group.getGroupId(), id, Menu.NONE, title);
            item.setIcon(R.drawable.ic_filter);
            item.setCheckable(true);
            i++;
        }
    }

    menu.setGroupVisible(R.id.category_my_filters,
            !mModel.isAccountExpanded && mCustomFilters != null && !mCustomFilters.isEmpty());
    mBinding.drawerNavigationView.setCheckedItem(mModel.currentNavigationItemId);
}

From source file:org.tigase.mobile.TigaseMobileMessengerActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    if (getCurrentPage() == 0 || getCurrentPage() == 1 || helper.isXLarge()) {
        MenuInflater inflater = getMenuInflater();
        Log.v(TAG, "current page " + getCurrentPage());
        Log.v(TAG, "xlarge = " + helper.isXLarge());
        final boolean serviceActive = JaxmppService.isServiceActive();

        menu.clear();/*w w  w  .j  a va  2s  . c o m*/
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
            inflater.inflate(R.menu.main_menu_old, menu);
        } else {
            inflater.inflate(R.menu.main_menu, menu);
        }

        MenuItem con = menu.findItem(R.id.connectButton);
        con.setVisible(!serviceActive);

        MenuItem dcon = menu.findItem(R.id.disconnectButton);
        dcon.setVisible(serviceActive);

        MenuItem showOffline = menu.findItem(R.id.showHideOffline);
        showOffline.setCheckable(true);
        showOffline.setChecked(mPreferences.getBoolean(Preferences.SHOW_OFFLINE, Boolean.TRUE));

        MenuItem add = menu.findItem(R.id.contactAdd);
        helper.setShowAsAction(add, MenuItem.SHOW_AS_ACTION_IF_ROOM);
        add.setVisible(serviceActive);

        MenuItem bookmarks = menu.findItem(R.id.bookmarksShow);
        if (bookmarks != null) {
            bookmarks.setVisible(serviceActive);
        }
    }

    return super.onPrepareOptionsMenu(menu);
}

From source file:org.geometerplus.android.fbreader.FBReader.java

@Override
public void refresh() {
    runOnUiThread(new Runnable() {
        public void run() {
            for (Map.Entry<MenuItem, String> entry : myMenuItemMap.entrySet()) {
                final String actionId = entry.getValue();
                final MenuItem menuItem = entry.getKey();
                menuItem.setVisible(// w  ww  . j a  v a 2s .  c o m
                        myFBReaderApp.isActionVisible(actionId) && myFBReaderApp.isActionEnabled(actionId));
                switch (myFBReaderApp.isActionChecked(actionId)) {
                case B3_TRUE:
                    menuItem.setCheckable(true);
                    menuItem.setChecked(true);
                    break;
                case B3_FALSE:
                    menuItem.setCheckable(true);
                    menuItem.setChecked(false);
                    break;
                case B3_UNDEFINED:
                    menuItem.setCheckable(false);
                    break;
                }
            }
        }
    });
}

From source file:com.example.innf.newchangtu.Map.view.activity.MainActivity.java

private void initNavigationView() {

    navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {

        MenuItem preMenuItem; /*???*/

        @Override// w w w .  ja va  2  s  . co m
        public boolean onNavigationItemSelected(MenuItem menuItem) {
            /*????checkedtrue?Drawer?Item???*/
            if (preMenuItem != null) {
                preMenuItem.setCheckable(false);
            }
            menuItem.setCheckable(true);
            mDrawerLayout.closeDrawers();
            preMenuItem = menuItem;

            Intent intent;
            /*?item*/
            switch (menuItem.getItemId()) {
            case R.id.drawer_menu_track_record:
                intent = TrackRecordListActivity.newIntent(MainActivity.this);
                startActivity(intent);
                break;
            case R.id.drawer_menu_map_sharing:
                intent = ShareMapActivity.newIntent(MainActivity.this);
                startActivity(intent);
                break;
            case R.id.drawer_menu_personal_setting:
                intent = SettingActivity.newIntent(MainActivity.this);
                startActivity(intent);
                break;
            case R.id.drawer_menu_nearby:
                intent = NearbyActivity.newIntent(MainActivity.this);
                startActivity(intent);
                break;
            case R.id.drawer_menu_track:
                intent = new Intent(MainActivity.this, TrackActivity.class);
                startActivity(intent);
                break;
            }
            return true;
        }

    });
}

From source file:net.konyan.yangonbusonthemap.HomeActivity.java

@SuppressWarnings("StatementWithEmptyBody")
@Override/*w  w w  .  j a v a 2s  .c  o m*/
public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    switch (id) {
    case R.id.nav_share:
        Util.share(this, Intent.ACTION_SEND);
        break;
    case R.id.nav_rate:
        Util.share(this, Intent.ACTION_VIEW);
        break;
    case R.id.nav_open_source:
        new EasyLicensesDialogCompat(this).setTitle("Licenses").setPositiveButton(android.R.string.ok, null)
                .show();
        break;
    case R.id.nav_yrta:
        new AlertDialog.Builder(this).setTitle(getString(R.string.ybs))
                .setMessage(getString(R.string.ybs_licence_full))
                .setPositiveButton(getString(android.R.string.ok), null).create().show();
        break;
    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    item.setCheckable(false);
    return true;
}

From source file:com.vuze.android.remote.fragment.TorrentListFragment.java

private void setupActionModeCallback() {
    mActionModeCallbackV7 = new Callback() {

        // Called when the action mode is created; startActionMode() was called
        @Override//from w  w w. j a  v  a2s .co  m
        public boolean onCreateActionMode(ActionMode mode, Menu menu) {

            if (AndroidUtils.DEBUG_MENU) {
                Log.d(TAG, "onCreateActionMode");
            }

            if (mode == null && torrentListAdapter.getCheckedItemCount() == 0
                    && torrentListAdapter.getSelectedPosition() < 0) {
                return false;
            }

            Menu origMenu = menu;
            if (tb != null) {
                menu = tb.getMenu();
            }
            if (mode != null) {
                mActionMode = (mode instanceof ActionModeWrapperV7) ? mode
                        : new ActionModeWrapperV7(mode, tb, getActivity());

                mActionMode.setTitle(R.string.context_torrent_title);
            }
            ActionBarToolbarSplitter.buildActionBar(getActivity(), this, R.menu.menu_context_torrent_details,
                    menu, tb);

            TorrentDetailsFragment frag = (TorrentDetailsFragment) getActivity().getSupportFragmentManager()
                    .findFragmentById(R.id.frag_torrent_details);
            if (frag != null) {
                frag.onCreateActionMode(mode, menu);
            }

            if (sideListArea == null) {
                SubMenu subMenu = origMenu.addSubMenu(R.string.menu_global_actions);
                subMenu.setIcon(R.drawable.ic_menu_white_24dp);
                MenuItemCompat.setShowAsAction(subMenu.getItem(), MenuItemCompat.SHOW_AS_ACTION_NEVER);

                try {
                    // Place "Global" actions on top bar in collapsed menu
                    MenuInflater mi = mode == null ? getActivity().getMenuInflater() : mode.getMenuInflater();
                    mi.inflate(R.menu.menu_torrent_list, subMenu);
                    onPrepareOptionsMenu(subMenu);
                } catch (UnsupportedOperationException e) {
                    Log.e(TAG, e.getMessage());
                    menu.removeItem(subMenu.getItem().getItemId());
                }
            }

            if (AndroidUtils.usesNavigationControl()) {
                MenuItem add = origMenu.add(R.string.select_multiple_items);
                add.setCheckable(true);
                add.setChecked(torrentListAdapter.isMultiCheckMode());
                add.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
                    @Override
                    public boolean onMenuItemClick(MenuItem item) {
                        boolean turnOn = !torrentListAdapter.isMultiCheckModeAllowed();

                        torrentListAdapter.setMultiCheckModeAllowed(turnOn);
                        if (turnOn) {
                            torrentListAdapter.setMultiCheckMode(turnOn);
                            torrentListAdapter.setItemChecked(torrentListAdapter.getSelectedPosition(), true);
                        }
                        return true;
                    }
                });
            }

            return true;
        }

        // Called each time the action mode is shown. Always called after
        // onCreateActionMode, but
        // may be called multiple times if the mode is invalidated.
        @Override
        public boolean onPrepareActionMode(ActionMode mode, Menu menu) {

            if (AndroidUtils.DEBUG_MENU) {
                Log.d(TAG, "MULTI:onPrepareActionMode " + mode);
            }
            if (tb != null) {
                menu = tb.getMenu();
            }

            // Must be called first, because our drawer sets all menu items
            // visible.. :(
            getActivity().onPrepareOptionsMenu(menu);

            prepareContextMenu(menu);

            TorrentDetailsFragment frag = (TorrentDetailsFragment) getActivity().getSupportFragmentManager()
                    .findFragmentById(R.id.frag_torrent_details);
            if (frag != null) {
                frag.onPrepareActionMode(mode, menu);
            }

            AndroidUtils.fixupMenuAlpha(menu);

            return true;
        }

        // Called when the user selects a contextual menu item
        @Override
        public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
            if (AndroidUtils.DEBUG_MENU) {
                Log.d(TAG, "onActionItemClicked " + item.getTitle());
            }

            if (TorrentListFragment.this.handleFragmentMenuItems(item.getItemId())) {
                return true;
            }
            if (getActivity().onOptionsItemSelected(item)) {
                return true;
            }
            TorrentDetailsFragment frag = (TorrentDetailsFragment) getActivity().getSupportFragmentManager()
                    .findFragmentById(R.id.frag_torrent_details);
            if (frag != null) {
                if (frag.onActionItemClicked(mode, item)) {
                    return true;
                }
            }
            return false;
        }

        // Called when the user exits the action mode
        @Override
        public void onDestroyActionMode(ActionMode mode) {
            if (AndroidUtils.DEBUG_MENU) {
                Log.d(TAG, "onDestroyActionMode. BeingReplaced?" + actionModeBeingReplaced);
            }

            mActionMode = null;

            if (!actionModeBeingReplaced) {
                listview.post(new Runnable() {
                    @Override
                    public void run() {
                        torrentListAdapter.setMultiCheckMode(false);
                        torrentListAdapter.clearChecked();
                        updateCheckedIDs();
                    }
                });

                listview.post(new Runnable() {
                    @Override
                    public void run() {
                        if (mCallback != null) {
                            mCallback.actionModeBeingReplacedDone();
                        }
                    }
                });

                listview.setLongClickable(true);
                listview.requestLayout();
                AndroidUtils.invalidateOptionsMenuHC(getActivity(), mActionMode);
            }
        }
    };
}