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.battlelancer.seriesguide.ui.StatsFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int itemId = item.getItemId();
    if (itemId == R.id.menu_action_stats_share) {
        shareStats();//from   w ww  .ja v a  2  s. com
        return true;
    }
    if (itemId == R.id.menu_action_stats_filter_specials) {
        PreferenceManager.getDefaultSharedPreferences(getActivity()).edit()
                .putBoolean(DisplaySettings.KEY_HIDE_SPECIALS, !item.isChecked()).commit();
        getActivity().supportInvalidateOptionsMenu();
        loadStats();
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.money.manager.ex.currency.list.CurrencyListFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    CurrencyUIFeatures ui = new CurrencyUIFeatures(getActivity());

    switch (item.getItemId()) {
    case R.id.menu_import_all_currencies:
        ui.showDialogImportAllCurrencies();
        return true;

    case R.id.menu_update_exchange_rate:
        ui.showDialogUpdateExchangeRates();
        break;// w ww  .j a  v  a 2s  .c  om

    case R.id.menu_show_used:
        if (item.isChecked()) {
            item.setChecked(false);
            // list all accounts
            mShowOnlyUsedCurrencies = false;
            reloadData();
        } else {
            item.setChecked(true);
            // list only used accounts
            mShowOnlyUsedCurrencies = true;
            reloadData();
        }
        break;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.example.javier.MaterialDesignApp.PlayerActivity.java

public void showAudioPopup(View v) {
    PopupMenu popup = new PopupMenu(this, v);
    Menu menu = popup.getMenu();/*www.j a  v  a2  s . c  o m*/
    menu.add(Menu.NONE, Menu.NONE, Menu.NONE, R.string.enable_background_audio);
    final MenuItem backgroundAudioItem = menu.findItem(0);
    backgroundAudioItem.setCheckable(true);
    backgroundAudioItem.setChecked(enableBackgroundAudio);
    OnMenuItemClickListener clickListener = new OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            if (item == backgroundAudioItem) {
                enableBackgroundAudio = !item.isChecked();
                return true;
            }
            return false;
        }
    };
    configurePopupWithTracks(popup, clickListener, DemoPlayer.TYPE_AUDIO);
    popup.show();
}

From source file:org.dmfs.tasks.TaskListActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.menu_visible_list) {
        Intent settingsIntent = new Intent(getBaseContext(), SyncSettingsActivity.class);
        startActivity(settingsIntent);//from  w  ww.ja va  2 s .c o m
        return true;
    } else if (item.getItemId() == R.id.menu_alarms) {
        // set and save state
        boolean activatedAlarms = !item.isChecked();
        item.setChecked(activatedAlarms);
        AlarmBroadcastReceiver.setAlarmPreference(this, activatedAlarms);
        return true;
    } else {
        return super.onOptionsItemSelected(item);
    }
}

From source file:nu.firetech.android.pactrack.frontend.ParcelListFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    switch (item.getItemId()) {
    case R.id.action_delete:
        UICommon.deleteParcel(info.id, getActivity(), mDbAdapter, new Runnable() {
            @Override/*from ww w .  j a v a 2s  .  c o  m*/
            public void run() {
                refreshDone();
            }
        });
        return true;
    case R.id.action_edit:
        ParcelIdDialog.create(getFragmentManager(), info.id);
        return true;
    case R.id.action_auto_include:
        mDbAdapter.setAutoUpdate(info.id, !item.isChecked());
        mParent.onAutoUpdateChanged(info.id, !item.isChecked());
        return true;
    case R.id.action_refresh:
        mParent.showParcel(info.id, true);
        return true;
    }

    return super.onContextItemSelected(item);
}

From source file:nu.firetech.android.pactrack.frontend.ParcelDetailsFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.action_delete:
        UICommon.deleteParcel(mRowId, getActivity(), mDbAdapter, new Runnable() {
            @Override//from   www. jav  a 2 s . co  m
            public void run() {
                mParent.onCurrentParcelRemoved();
            }
        });
        return true;
    case R.id.action_edit:
        ParcelIdDialog.create(getFragmentManager(), mRowId);
        return true;
    case R.id.action_auto_include:
        mDbAdapter.setAutoUpdate(mRowId, !item.isChecked());
        mParent.onAutoUpdateChanged(mRowId, !item.isChecked());
        return true;
    case R.id.action_refresh:
        errorShown = Error.NONE;
        doRefresh();
        return true;
    }

    return super.onOptionsItemSelected(item);
}

From source file:info.wncwaterfalls.app.InformationMapFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_item_map_type_street:
        return setMapTypeIfUnchecked(item, GoogleMap.MAP_TYPE_NORMAL);

    case R.id.menu_item_map_type_terrain:
        return setMapTypeIfUnchecked(item, GoogleMap.MAP_TYPE_TERRAIN);

    case R.id.menu_item_map_type_none:
        return setMapTypeIfUnchecked(item, GoogleMap.MAP_TYPE_NONE);

    case R.id.menu_item_map_show_overlay:
        if (mMBTilesTileOverlay != null) {
            mMBTilesTileOverlay.setVisible(!mMBTilesTileOverlay.isVisible());
            item.setChecked(!item.isChecked());
        }//from  w w  w .  j  av  a2s .co  m
        return true;

    case R.id.menu_item_map_tracking:
        GoogleMap map = mMapView.getMap();
        map.setMyLocationEnabled(!map.isMyLocationEnabled());
        item.setChecked(!item.isChecked());
        return true;

    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:org.tigase.messenger.phone.pro.roster.RosterItemFragment.java

@Override
public boolean onOptionsItemSelected(final MenuItem item) {

    SharedPreferences.Editor editor;//from ww  w  .  j  a  v  a  2  s. c om
    switch (item.getItemId()) {
    case R.id.menu_roster_sort_presence:
        item.setChecked(true);

        editor = sharedPref.edit();
        editor.putString("roster_sort", "presence");
        editor.commit();
        refreshRoster();
        return true;
    case R.id.menu_roster_sort_name:
        item.setChecked(true);
        editor = sharedPref.edit();
        editor.putString("roster_sort", "name");
        editor.commit();
        refreshRoster();
        return true;
    case R.id.menu_roster_show_offline:
        final boolean v = !item.isChecked();
        item.setChecked(v);
        editor = sharedPref.edit();
        editor.putBoolean("show_offline", v);
        editor.commit();
        refreshRoster();
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.landenlabs.all_devtool.DevToolActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_about:
        showAbout();/* w ww.j av  a 2  s.  c  om*/
        return true;
    case R.id.menu_web:
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://LanDenLabs.com"));
        startActivity(intent);
        return true;
    case R.id.menu_share:
        GlobalInfo.s_globalInfo.tabAdapter.sharePage();
        //  invalidateOptionsMenu();
        return true;
    case R.id.menu_shortcuts_on:
        ShortcutUtil.makeShortcuts();
        return true;
    case R.id.menu_shortcuts_off:
        ShortcutUtil.removeShortcuts();
        return true;

    case R.id.menu_lock_orientation:
        item.setChecked(!item.isChecked());
        GlobalInfo.s_globalInfo.isLockedOrientation = item.isChecked();
        GlobalInfo.s_globalInfo.lockedOrientation = getResources().getConfiguration().orientation;
        ;
        return true;
    }

    return super.onOptionsItemSelected(item);
    // return false;
}

From source file:com.commonsware.android.diceware.PassphraseFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.open:
        open();/*from   ww w  .  jav  a  2 s.  c o m*/
        return (true);

    case R.id.get:
        get();
        return (true);

    case R.id.refresh:
        loadWords(false, true);
        return (true);

    case R.id.reset:
        prefs.edit().clear().apply();
        loadWords(true, true);
        return (true);

    case R.id.word_count_4:
    case R.id.word_count_5:
    case R.id.word_count_6:
    case R.id.word_count_7:
    case R.id.word_count_8:
    case R.id.word_count_9:
    case R.id.word_count_10:
        item.setChecked(!item.isChecked());

        int temp = Integer.parseInt(item.getTitle().toString());

        if (temp != wordCount) {
            wordCount = temp;
            loadWords(false, true);
        }

        return (true);
    }

    return (super.onOptionsItemSelected(item));
}