List of usage examples for android.view MenuItem isChecked
public boolean isChecked();
From source file:org.mariotaku.twidere.fragment.RetweetQuoteDialogFragment.java
@CheckResult private boolean retweetOrQuote(ParcelableAccount account, ParcelableStatus status, boolean showProtectedConfirmation) { AsyncTwitterWrapper twitter = mTwitterWrapper; final Dialog dialog = getDialog(); if (dialog == null || twitter == null) return false; final EditText editComment = (EditText) dialog.findViewById(R.id.edit_comment); if (useQuote(editComment.length() > 0, account)) { final Menu menu = mPopupMenu.getMenu(); final MenuItem itemQuoteOriginalStatus = menu.findItem(R.id.quote_original_status); final Uri statusLink; final boolean quoteOriginalStatus = itemQuoteOriginalStatus.isChecked(); String commentText;//from w w w .j av a2 s . c o m final ParcelableStatusUpdate update = new ParcelableStatusUpdate(); update.accounts = new ParcelableAccount[] { account }; final String editingComment = String.valueOf(editComment.getText()); switch (ParcelableAccountUtils.getAccountType(account)) { case ParcelableAccount.Type.FANFOU: { if (!status.is_quote || !quoteOriginalStatus) { if (status.user_is_protected && showProtectedConfirmation) { QuoteProtectedStatusWarnFragment.show(this, account, status); return false; } update.repost_status_id = status.id; commentText = getString(R.string.fanfou_repost_format, editingComment, status.user_screen_name, status.text_plain); } else { if (status.quoted_user_is_protected && showProtectedConfirmation) { return false; } commentText = getString(R.string.fanfou_repost_format, editingComment, status.quoted_user_screen_name, status.quoted_text_plain); update.repost_status_id = status.quoted_id; } if (commentText.length() > Validator.MAX_TWEET_LENGTH) { commentText = commentText.substring(0, Math.max(Validator.MAX_TWEET_LENGTH, editingComment.length())); } break; } default: { if (!status.is_quote || !quoteOriginalStatus) { statusLink = LinkCreator.getStatusWebLink(status); } else { statusLink = LinkCreator.getQuotedStatusWebLink(status); } update.attachment_url = statusLink.toString(); commentText = editingComment; break; } } update.text = commentText; update.is_possibly_sensitive = status.is_possibly_sensitive; BackgroundOperationService.updateStatusesAsync(getContext(), Draft.Action.QUOTE, update); } else { twitter.retweetStatusAsync(status.account_key, status.id); } return true; }
From source file:org.xbmc.kore.ui.sections.audio.AlbumListFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); switch (item.getItemId()) { case R.id.action_sort_by_album: item.setChecked(!item.isChecked()); preferences.edit().putInt(Settings.KEY_PREF_ALBUMS_SORT_ORDER, Settings.SORT_BY_ALBUM).apply(); refreshList();//from w ww . jav a2s .com break; case R.id.action_sort_by_artist: item.setChecked(!item.isChecked()); preferences.edit().putInt(Settings.KEY_PREF_ALBUMS_SORT_ORDER, Settings.SORT_BY_ARTIST).apply(); refreshList(); break; case R.id.action_sort_by_artist_year: item.setChecked(!item.isChecked()); preferences.edit().putInt(Settings.KEY_PREF_ALBUMS_SORT_ORDER, Settings.SORT_BY_ARTIST_YEAR).apply(); refreshList(); break; default: break; } return super.onOptionsItemSelected(item); }
From source file:me.drakeet.meizhi.ui.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); switch (id) { case R.id.action_trending: openGitHubTrending();// w w w .j ava 2 s . co m return true; case R.id.action_notifiable: boolean isChecked = !item.isChecked(); item.setChecked(isChecked); PreferencesLoader loader = new PreferencesLoader(this); loader.saveBoolean(R.string.action_notifiable, isChecked); Toasts.showShort(isChecked ? R.string.notifiable_on : R.string.notifiable_off); return true; } return super.onOptionsItemSelected(item); }
From source file:org.xbmc.kore.ui.TVShowListFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); switch (item.getItemId()) { case R.id.action_hide_watched: item.setChecked(!item.isChecked()); preferences.edit().putBoolean(Settings.KEY_PREF_TVSHOWS_FILTER_HIDE_WATCHED, item.isChecked()).apply(); refreshList();/*from w w w . j av a 2 s . c om*/ break; case R.id.action_ignore_prefixes: item.setChecked(!item.isChecked()); preferences.edit().putBoolean(Settings.KEY_PREF_TVSHOWS_IGNORE_PREFIXES, item.isChecked()).apply(); refreshList(); break; case R.id.action_sort_by_name: item.setChecked(true); preferences.edit().putInt(Settings.KEY_PREF_TVSHOWS_SORT_ORDER, Settings.SORT_BY_NAME).apply(); refreshList(); break; case R.id.action_sort_by_year: item.setChecked(true); preferences.edit().putInt(Settings.KEY_PREF_TVSHOWS_SORT_ORDER, Settings.SORT_BY_YEAR).apply(); refreshList(); break; case R.id.action_sort_by_rating: item.setChecked(true); preferences.edit().putInt(Settings.KEY_PREF_TVSHOWS_SORT_ORDER, Settings.SORT_BY_RATING).apply(); refreshList(); break; case R.id.action_sort_by_date_added: item.setChecked(true); preferences.edit().putInt(Settings.KEY_PREF_TVSHOWS_SORT_ORDER, Settings.SORT_BY_DATE_ADDED).apply(); refreshList(); break; default: break; } return super.onOptionsItemSelected(item); }
From source file:org.xbmc.kore.ui.MovieListFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); switch (item.getItemId()) { case R.id.action_hide_watched: item.setChecked(!item.isChecked()); preferences.edit().putBoolean(Settings.KEY_PREF_MOVIES_FILTER_HIDE_WATCHED, item.isChecked()).apply(); refreshList();//from w ww . j ava 2 s.c om break; case R.id.action_ignore_prefixes: item.setChecked(!item.isChecked()); preferences.edit().putBoolean(Settings.KEY_PREF_MOVIES_IGNORE_PREFIXES, item.isChecked()).apply(); refreshList(); break; case R.id.action_sort_by_name: item.setChecked(true); preferences.edit().putInt(Settings.KEY_PREF_MOVIES_SORT_ORDER, Settings.SORT_BY_NAME).apply(); refreshList(); break; case R.id.action_sort_by_year: item.setChecked(true); preferences.edit().putInt(Settings.KEY_PREF_MOVIES_SORT_ORDER, Settings.SORT_BY_YEAR).apply(); refreshList(); break; case R.id.action_sort_by_rating: item.setChecked(true); preferences.edit().putInt(Settings.KEY_PREF_MOVIES_SORT_ORDER, Settings.SORT_BY_RATING).apply(); refreshList(); break; case R.id.action_sort_by_date_added: item.setChecked(true); preferences.edit().putInt(Settings.KEY_PREF_MOVIES_SORT_ORDER, Settings.SORT_BY_DATE_ADDED).apply(); refreshList(); break; case R.id.action_sort_by_length: item.setChecked(true); preferences.edit().putInt(Settings.KEY_PREF_MOVIES_SORT_ORDER, Settings.SORT_BY_LENGTH).apply(); refreshList(); break; default: break; } return super.onOptionsItemSelected(item); }
From source file:com.alainesp.fan.sanderson.MainActivity.java
@Override public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); if (!item.isChecked()) { if (id != R.id.nav_about) { this.setTitle(item.getTitle()); item.setChecked(true);//w w w . j a v a 2 s .c o m } if (id == R.id.nav_main) { getFragmentManager().beginTransaction().replace(R.id.main_fragment, new SummaryFragment()).commit(); app_state = APP_STATE_SUMMARY; } else if (id == R.id.nav_blog) { getFragmentManager().beginTransaction().replace(R.id.main_fragment, new BlogPostsFragment()) .commit(); app_state = APP_STATE_BLOG; } else if (id == R.id.nav_events) { getFragmentManager().beginTransaction().replace(R.id.main_fragment, new EventsFragment()).commit(); app_state = APP_STATE_EVENTS; } else if (id == R.id.nav_books) { getFragmentManager().beginTransaction().replace(R.id.main_fragment, new BooksFragment()).commit(); app_state = APP_STATE_BOOKS; } else if (id == R.id.nav_twitter) { getFragmentManager().beginTransaction().replace(R.id.main_fragment, new TwitterFragment()).commit(); app_state = APP_STATE_TWITTER; } else if (id == R.id.nav_tor0) { Uri webpage = Uri.parse("http://www.tor.com/features/series/the-way-of-kings-reread-on-torcom/"); Intent webIntent = new Intent(Intent.ACTION_VIEW, webpage); if (isIntentSafe(webIntent)) startActivity(webIntent); getFragmentManager().beginTransaction().replace(R.id.main_fragment, new TorWoKRereadFragment()) .commit(); app_state = APP_STATE_WOK; this.setTitle("The Way of Kings Reread"); } else if (id == R.id.nav_tor1) { //Uri webpage = Uri.parse("http://www.tor.com/series/words-of-radiance-reread-on-torcom/"); getFragmentManager().beginTransaction().replace(R.id.main_fragment, new TorWoRRereadFragment()) .commit(); app_state = APP_STATE_WOR; this.setTitle("Words of Radiance Reread"); } else if (id == R.id.nav_17shard)// TODO: Handle posts and news in the app { Uri webpage = Uri.parse("http://www.17thshard.com/forum/"); Intent webIntent = new Intent(Intent.ACTION_VIEW, webpage); if (isIntentSafe(webIntent)) startActivity(webIntent); getFragmentManager().beginTransaction().replace(R.id.main_fragment, new Shard17thFragment()) .commit(); app_state = APP_STATE_17SHARD; } else if (id == R.id.nav_settings) { getFragmentManager().beginTransaction().replace(R.id.main_fragment, new SettingsFragment()) .commit(); app_state = APP_STATE_SETTINGS; } else if (id == R.id.nav_about) { try { new AlertDialog.Builder(this).setTitle("About") .setMessage(Html.fromHtml("<em>Fan of Sanderson</em> " + getPackageManager().getPackageInfo(getPackageName(), 0).versionName + " BETA" + "<br/><br/>Application made by fans to fans.<br/><br/>" + "Developer: Alain Espinosa <alainesp@gmail.com>")) .setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).create().show(); } catch (PackageManager.NameNotFoundException ignored) { } } } DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }
From source file:org.samcrow.ridgesurvey.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); getMenuInflater().inflate(R.menu.home_menu, menu); final MenuItem compassItem = menu.findItem(R.id.compass_item); if (mHeadingCalculator.isAvailable()) { compassItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override/* w w w . j a va2s. c o m*/ public boolean onMenuItemClick(MenuItem item) { item.setChecked(!item.isChecked()); if (item.isChecked()) { mCompass.setVisibility(View.VISIBLE); mHeadingCalculator.resume(); } else { mCompass.setVisibility(View.INVISIBLE); mHeadingCalculator.pause(); } return true; } }); } else { compassItem.setVisible(false); } final MenuItem editItem = menu.findItem(R.id.edit_item); editItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { final Site selectedSite = mSelectionManager.getSelectedSite(); final Route selectedSiteRoute = mSelectionManager.getSelectedSiteRoute(); if (selectedSite != null && selectedSiteRoute != null) { final Intent intent = new Intent(MainActivity.this, DataEntryActivity.class); intent.putExtra(DataEntryActivity.ARG_SITE, selectedSite); intent.putExtra(DataEntryActivity.ARG_ROUTE, selectedSiteRoute.getName()); startActivityForResult(intent, REQUEST_CODE_ENTRY); } else { new AlertDialog.Builder(MainActivity.this).setTitle(R.string.no_site_selected) .setMessage(R.string.select_a_site).setNeutralButton(android.R.string.ok, null).show(); } return true; } }); final MenuItem viewObservationsItem = menu.findItem(R.id.view_observations_item); viewObservationsItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { final Intent intent = new Intent(MainActivity.this, ObservationListActivity.class); startActivityForResult(intent, REQUEST_CODE_OBSERVATION_LIST); return true; } }); final MenuItem uploadItem = menu.findItem(R.id.upload_item); uploadItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { // Start the upload service startUpload(); return true; } }); final UploadMenuItemController controller = new UploadMenuItemController(this, uploadItem); mUploadStatusTracker.addListener(controller); return true; }
From source file:de.amuttsch.ioweu.app.ui.DebtListsActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Pass the event to ActionBarDrawerToggle, if it returns // true, then it has handled the app icon touch event if (mDrawerToggle.onOptionsItemSelected(item)) { return true; }//from ww w . j ava 2 s.com Callback currentFragment = getCurrentFragment(); switch (item.getItemId()) { case R.id.action_show_history: item.setChecked(!item.isChecked()); mShowHistory = item.isChecked(); currentFragment.showHistory(mShowHistory); break; case R.id.action_make_all_even: ((DebtListFragment) currentFragment).makeAllDebtsEven(); break; case R.id.action_delete_all: ((DebtListFragment) currentFragment).deleteAllDebts(); break; default: break; } return super.onOptionsItemSelected(item); }
From source file:com.joeyturczak.jtscanner.ui.MainActivity.java
public void selectDrawerItem(MenuItem menuItem) { // Create a new fragment and specify the planet to show based on // position/*from w w w.j a v a2 s . c om*/ if (!menuItem.isChecked()) { switch (menuItem.getItemId()) { case R.id.scanner_fragment: startScannerFragment(); break; case R.id.scan_list_fragment: startScanListFragment(); break; case R.id.settings_fragment: startSettingsFragment(); break; case R.id.file_list_fragment: startFileListFragment(); break; case R.id.about: startAboutFragment(); break; default: startScannerFragment(); } // Highlight the selected item, update the title, and close the drawer setTitle(menuItem.getTitle()); menuItem.setChecked(true); } mDrawerLayout.closeDrawers(); }
From source file:org.voidsink.anewjkuapp.fragment.MapFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_snap_to_location: item.setChecked(!item.isChecked()); this.mMyLocationOverlay.setSnapToLocationEnabled(item.isChecked()); return true; default:/*from w w w . j av a 2 s . co m*/ return super.onOptionsItemSelected(item); } }