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:com.commonsware.android.mapsv2.location.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.follow) {
        item.setChecked(!item.isChecked());
        autoFollow = item.isChecked();//from  w  w  w  .  j a v a  2  s. c  o m
        follow();

        return true;
    }

    return super.onOptionsItemSelected(item);
}

From source file:com.jefftharris.passwdsafe.sync.SyncLogsFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_show_all: {
        itsIsShowAll = !item.isChecked();
        item.setChecked(itsIsShowAll);//from  w w  w  . j a va2s .co m
        LoaderManager lm = getLoaderManager();
        lm.restartLoader(LOADER_LOGS, null, itsLogsCbs);
        return true;
    }
    default: {
        return super.onOptionsItemSelected(item);
    }
    }
}

From source file:org.que.activities.fragments.FavoriteMenuFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem favItem) {
    if (favItem.getItemId() == R.id.action_favorite) {
        SQLQuery query = getFavoriteUpdateSQLQuery();

        Integer fav;/*ww w. j a va 2s  . c om*/
        if (favItem.isChecked()) { //UNfavorited
            setFavIcon(false);
            fav = 0;
            CalendarHelper.deleteItemFromCalendar(getEntity(), getActivity());
            Toast.makeText(getActivity(), getString(R.string.removed), Toast.LENGTH_SHORT).show();
        } else {
            setFavIcon(true);
            fav = 1;
            CalendarHelper.attemptToAddToCalendar(getActivity(), getEntity());
            Toast.makeText(getActivity(), getString(R.string.added), Toast.LENGTH_SHORT).show();
        }

        query.addValues(getFavoriteColumnName(), fav.toString());
        ConferenceDAO.updateEntity(getActivity(), query);
    }

    return super.onOptionsItemSelected(favItem);
}

From source file:org.csploit.android.plugins.Traceroute.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.resolve_names:
        resolveNames = !item.isChecked();
        item.setChecked(resolveNames);/*from  w w  w.ja v a 2s. c om*/
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:at.bitfire.nophonespam.BlacklistActivity.java

public void onShowNotifications(MenuItem item) {
    settings.showNotifications(!item.isChecked());
}

From source file:at.bitfire.nophonespam.BlacklistActivity.java

public void onBlockHiddenNumbers(MenuItem item) {
    settings.blockHiddenNumbers(!item.isChecked());
}

From source file:com.ccjeng.weather.view.activity.MainActivity.java

private void navDrawer() {
    navigation.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
        @Override/*from  ww w. j a  v  a 2s  .c om*/
        public boolean onNavigationItemSelected(MenuItem menuItem) {

            //Checking if the item is in checked state or not, if not make it in checked state
            if (menuItem.isChecked())
                menuItem.setChecked(false);
            else
                menuItem.setChecked(true);

            //Closing drawer on item click
            drawerLayout.closeDrawers();

            switch (menuItem.getItemId()) {
            case R.id.navSetting:
                startActivity(new Intent(MainActivity.this, SettingsActivity.class));
                break;
            case R.id.navAbout:
                new LibsBuilder().withActivityStyle(Libs.ActivityStyle.LIGHT_DARK_TOOLBAR)
                        .withAboutIconShown(true).withAboutVersionShown(true)
                        .withAboutAppName(getString(R.string.app_name))
                        .withActivityTitle(getString(R.string.action_about))
                        .withAboutDescription(getString(R.string.about_license)).start(MainActivity.this);
                break;

            }
            return false;
        }
    });

    actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.app_name,
            R.string.app_name) {

        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
        }
    };

    //Setting the actionbarToggle to drawer layout
    drawerLayout.setDrawerListener(actionBarDrawerToggle);

    //calling sync state is necessay or else your hamburger icon wont show up
    actionBarDrawerToggle.syncState();
}

From source file:task.application.com.colette.navigation.AppNavigationViewAsDrawerImpl.java

/**
 * Sets up the given navdrawer item's appearance to the selected state. Note: this could also be
 * accomplished (perhaps more cleanly) with state-based layouts.
 *//*  w ww.j a v  a  2  s  . c o  m*/
private void setSelectedNavDrawerItem(NavigationModel.NavigationItemEnum item) {
    if (mNavigationView != null && mNavigationView.getMenu().findItem(item.getId()) != null
            && item != NavigationModel.NavigationItemEnum.INVALID) {
        for (NavigationModel.NavigationItemEnum menuItems : NavigationModel.NavigationItemEnum.values()) {
            MenuItem curItem = mNavigationView.getMenu().findItem(menuItems.getId());
            if (curItem != null && curItem.isChecked()) {
                mNavigationView.getMenu().findItem(menuItems.getId()).setChecked(false);
            }
        }
        mNavigationView.getMenu().findItem(item.getId()).setChecked(true);
    }
}

From source file:dg.shenm233.mmaps.ui.MainActivity.java

private void initNavigationView() {
    NavigationView nv = (NavigationView) mDrawerLayout.findViewById(R.id.navigation_view);
    nv.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
        @Override//from   w ww.j a  v  a2 s . com
        public boolean onNavigationItemSelected(MenuItem item) {
            MapsModule mapsModule = ((MapsFragment) getMapsFragment()).getMapsModule();
            int itemId = item.getItemId();
            boolean isChecked = item.isChecked();
            if (itemId == R.id.navigation_satellite) {
                if (!isChecked) {
                    mapsModule.setMapType(MapsModule.MAP_TYPE_SATELLITE);
                } else {
                    mapsModule.setMapType(MapsModule.MAP_TYPE_NORMAL);
                }
                item.setChecked(!isChecked);
                mDrawerLayout.closeDrawers();
            } else if (itemId == R.id.navigation_traffic) {
                mapsModule.setTrafficEnabled(!isChecked);
                item.setChecked(!isChecked);
                mDrawerLayout.closeDrawers();
            } else if (itemId == R.id.navigation_offline) {
                Intent intent = new Intent(MainActivity.this, OfflineMapActivity.class);
                startActivity(intent);
            } else if (itemId == R.id.navigation_settings) {
                Intent intent = new Intent(MainActivity.this, SettingsActivity.class);
                startActivity(intent);
            } else if (itemId == R.id.navigation_favorite) {
                mDrawerLayout.closeDrawers();
                switchToFavorite();
            }
            return true;
        }
    });
}

From source file:org.csploit.android.plugins.Inspector.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.focused_scan:
        if (item.isChecked()) {
            item.setChecked(false);// www  . j  a  v a2  s  . c o m
            mFocusedScan = false;
        } else {
            item.setChecked(true);
            mFocusedScan = true;
        }
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}