List of usage examples for android.view MenuItem isChecked
public boolean isChecked();
From source file:edu.nd.darts.cimon.NDroidAdmin.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.startup: SharedPreferences appPrefs = getSharedPreferences(SHARED_PREFS, Context.MODE_PRIVATE); SharedPreferences.Editor editor = appPrefs.edit(); if (item.isChecked()) { item.setChecked(false);/* w ww.j a v a 2 s . com*/ editor.putBoolean(PREF_STARTUP, false); } else { item.setChecked(true); editor.putBoolean(PREF_STARTUP, true); } editor.commit(); return true; case R.id.exit: stopService(new Intent(this, NDroidService.class)); if (DebugLog.DEBUG) Log.d(TAG, "CIMON service stopped - exiting"); finish(); return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.example.george.sharedelementimplementation.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.menu_slow) { sAnimatorScale = item.isChecked() ? 1 : 5; item.setChecked(!item.isChecked()); }// ww w . j ava2s.c o m return super.onOptionsItemSelected(item); }
From source file:net.hyx.app.volumenotification.activity.ListViewActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: NavUtils.navigateUpFromSameTask(this); break;/* w ww . j a va 2 s . co m*/ case R.id.menu_pref: startActivity(new Intent(this, SettingsActivity.class)); break; case R.id.menu_dark_app_theme: boolean darkTheme = !item.isChecked(); settings.getPreferences().edit().putBoolean("pref_dark_app_theme", darkTheme).commit(); item.setChecked(darkTheme); setTheme(settings.getAppTheme()); recreate(); break; case R.id.menu_about: Snackbar.make(findViewById(android.R.id.content), R.string.hint_about_message, Snackbar.LENGTH_LONG) .setAction(R.string.hint_about_action, new View.OnClickListener() { @Override public void onClick(View v) { Uri url = Uri.parse(getResources().getString(R.string.menu_about_url)); startActivity(new Intent(Intent.ACTION_VIEW, url)); } }).show(); break; } return super.onOptionsItemSelected(item); }
From source file:info.wncwaterfalls.app.InformationMapFragment.java
private void createOfflineTileProvider() { File tilesDBFile = mTilesDB.getDBFile(); MapBoxOfflineTileProvider mMapBoxTileProvider = new MapBoxOfflineTileProvider(tilesDBFile); // Create new TileOverlayOptions instance. TileOverlayOptions overlayOptions = new TileOverlayOptions(); // Set the tile provider on the TileOverlayOptions. overlayOptions.tileProvider(mMapBoxTileProvider); GoogleMap map = mMapView.getMap();//from w w w . j a v a 2 s .co m mMBTilesTileOverlay = map.addTileOverlay(overlayOptions); mOfflineMapCreated = true; enableOfflineMapToggle(); // Notify the user of zoom restrictions. Hard to actually enforce them, // however, since only both zoom controls can be disabled at once. map.setOnCameraChangeListener(new GoogleMap.OnCameraChangeListener() { @Override public void onCameraChange(CameraPosition position) { MenuItem item = mOptionsMenu.findItem(R.id.menu_item_map_show_overlay); if (item != null && item.isChecked()) { CharSequence whichWay = ""; if (position.zoom < 14.0 && !mNotifiedTooFarIn) { whichWay = "in"; mNotifiedTooFarIn = true; } else if (position.zoom > 16.0 && !mNotifiedTooFarOut) { whichWay = "out"; mNotifiedTooFarOut = true; } if (whichWay != "") { CharSequence error = "Zoom " + whichWay + " to see offline map."; int duration = Toast.LENGTH_SHORT; Toast toast = Toast.makeText(InformationMapFragment.this.getActivity(), error, duration); toast.show(); } } }; }); }
From source file:com.duy.pascal.ui.file.FileExplorerAction.java
@Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { int id = item.getItemId(); if (id == R.id.select_all) { if (!item.isChecked()) { mView.setSelectAll(true);/*from ww w .j ava2 s. c o m*/ item.setChecked(true); item.setTitle(R.string.cancel_select_all); } else { mView.setSelectAll(false); } } else if (id == R.id.copy && !mCheckedList.isEmpty()) { mFileClipboard.setData(true, mCheckedList); destroyActionMode(); } else if (id == R.id.cut && !mCheckedList.isEmpty()) { mFileClipboard.setData(false, mCheckedList); destroyActionMode(); } else if (id == R.id.paste) { destroyActionMode(); mFileClipboard.paste(mContext, mExplorerContext.getCurrentDirectory(), new OnClipboardPasteFinishListener() { @Override public void onFinish(int count, String error) { mFileClipboard.showPasteResult(mContext, count, error); } }); } else if (id == R.id.rename) { doRenameAction(); } else if (id == R.id.share) { shareFile(); } else if (id == R.id.delete) { doDeleteAction(); } else { return false; } return true; }
From source file:com.oddsoft.tpetrash2.view.activity.MainActivity.java
private void initDrawer() { navigation.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override/* w w w . j av a2 s . co m*/ 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, Prefs.class)); break; case R.id.navAbout: new LibsBuilder() //provide a style (optional) (LIGHT, DARK, LIGHT_DARK_TOOLBAR) .withActivityStyle(Libs.ActivityStyle.LIGHT_DARK_TOOLBAR).withAboutIconShown(true) .withAboutVersionShown(true).withAboutAppName(getString(R.string.app_name)) .withActivityTitle(getString(R.string.about)) .withAboutDescription(getString(R.string.license)) //start the activity .start(MainActivity.this); break; case R.id.navSuggest: startActivity( new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.oddsoft.tpetrash2"))); break; case R.id.navFacebook: startActivity( new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/TaipeiTrash"))); break; } return false; } }); actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.app_name, R.string.app_name) { @Override public void onDrawerClosed(View drawerView) { // Code here will be triggered once the drawer closes as we dont want anything to happen so we leave this blank super.onDrawerClosed(drawerView); } @Override public void onDrawerOpened(View drawerView) { // Code here will be triggered once the drawer open as we dont want anything to happen so we leave this blank 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:io.tehtotalpwnage.musicphp_android.NavigationActivity.java
private int getCheckedItem(NavigationView navView) { Menu menu = navView.getMenu(); for (int i = 0; i < menu.size(); i++) { MenuItem item = menu.getItem(i); if (item.isChecked()) { return i; }// w ww . j a v a 2s . c om } return 0; }
From source file:us.shandian.blacklight.ui.statuses.NewPostActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.isCheckable() && item.isEnabled()) { item.setChecked(!item.isChecked()); }/*from w w w. j a v a 2 s .c o m*/ int id = item.getItemId(); if (id == android.R.id.home) { finish(); return true; } else if (id == R.id.post_send) { try { if (!TextUtils.isEmpty(mText.getText().toString())) { new Uploader().execute(); } else { Toast.makeText(this, R.string.empty_weibo, Toast.LENGTH_SHORT).show(); } } catch (Exception e) { } return true; } else if (id == R.id.post_pic) { if (mBitmap == null) { showPicturePicker(); } else { setPicture(null); } return true; } else if (id == R.id.post_emoticon) { if (mDrawer.isDrawerOpen(Gravity.END)) { mDrawer.closeDrawer(Gravity.END); } else { mDrawer.openDrawer(Gravity.END); } return true; } else if (id == R.id.post_at) { AtUserSuggestDialog diag = new AtUserSuggestDialog(this); diag.setListener(new AtUserSuggestDialog.AtUserListener() { @Override public void onChooseUser(String name) { mText.getText().insert(mText.getSelectionStart(), " @" + name + " "); } }); diag.show(); return true; } else { return super.onOptionsItemSelected(item); } }
From source file:io.github.sin3hz.fastjumper.sample.AppListFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_use_divider: { mUseDivider = !item.isChecked(); item.setChecked(mUseDivider);/*from w w w .j a v a2 s .c o m*/ setupDivider(); return true; } case R.id.action_load_more: { mLoadMore = !item.isChecked(); return true; } default: return super.onOptionsItemSelected(item); } }
From source file:com.bringcommunications.etherpay.SendActivity.java
public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.show_gas: { boolean show_gas = item.isChecked() ? false : true; item.setChecked(show_gas);/*from ww w. jav a2s . co m*/ SharedPreferences.Editor preferences_editor = preferences.edit(); preferences_editor.putBoolean("show_gas", show_gas); preferences_editor.apply(); recreate(); return true; } case R.id.show_data: { boolean show_data = item.isChecked() ? false : true; item.setChecked(show_data); SharedPreferences.Editor preferences_editor = preferences.edit(); preferences_editor.putBoolean("show_data", show_data); preferences_editor.apply(); recreate(); return true; } case R.id.help: do_help(R.string.send_help_title, R.string.send_help); return true; default: return super.onOptionsItemSelected(item); } }