List of usage examples for android.view MenuItem setChecked
public MenuItem setChecked(boolean checked);
From source file:com.dmitrymalkovich.android.popularmoviesapp.MovieListActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.sort_by_top_rated: if (mSortBy.equals(FetchMoviesTask.FAVORITES)) { getSupportLoaderManager().destroyLoader(FAVORITE_MOVIES_LOADER); }//from w ww .j a v a 2 s .c o m mSortBy = FetchMoviesTask.TOP_RATED; fetchMovies(mSortBy); item.setChecked(true); break; case R.id.sort_by_most_popular: if (mSortBy.equals(FetchMoviesTask.FAVORITES)) { getSupportLoaderManager().destroyLoader(FAVORITE_MOVIES_LOADER); } mSortBy = FetchMoviesTask.MOST_POPULAR; fetchMovies(mSortBy); item.setChecked(true); break; case R.id.sort_by_favorites: mSortBy = FetchMoviesTask.FAVORITES; item.setChecked(true); fetchMovies(mSortBy); default: break; } return super.onOptionsItemSelected(item); }
From source file:org.apache.taverna.mobile.ui.DashboardActivity.java
/** * @param navigationView Design Support NavigationView OnClick Listener Event */// ww w. j a v a 2 s.com private void setupDrawerContent(final NavigationView navigationView) { navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(MenuItem menuItem) { switch (menuItem.getItemId()) { case R.id.nav_workflows: fragment = new WorkflowFragment(); ActivityUtils.addFragmentToActivity(getSupportFragmentManager(), fragment, R.id.frame_container); menuItem.setChecked(true); mDrawerLayout.closeDrawers(); toolbar.setTitle(R.string.title_nav_all_workflows); return true; case R.id.nav_my_workflows: fragment = new MyWorkflowFragment(); ActivityUtils.addFragmentToActivity(getSupportFragmentManager(), fragment, R.id.frame_container); menuItem.setChecked(true); mDrawerLayout.closeDrawers(); toolbar.setTitle(R.string.title_nav_my_workflows); return true; case R.id.nav_favourite_workflow: fragment = new FavouriteWorkflowsFragment(); ActivityUtils.addFragmentToActivity(getSupportFragmentManager(), fragment, R.id.frame_container); menuItem.setChecked(true); mDrawerLayout.closeDrawers(); toolbar.setTitle(R.string.title_nav_favourite_workflows); return true; case R.id.nav_announcement: fragment = new AnnouncementFragment(); ActivityUtils.addFragmentToActivity(getSupportFragmentManager(), fragment, R.id.frame_container); menuItem.setChecked(true); mDrawerLayout.closeDrawers(); toolbar.setTitle(R.string.title_nav_announcement); return true; case R.id.nav_usage: dialog.setCanceledOnTouchOutside(true); dialog.setTitle(getString(R.string.title_nav_usage)); dialog.setContentView(R.layout.usage_layout); dialog.show(); mDrawerLayout.closeDrawers(); return true; case R.id.nav_about: TableLayout about = (TableLayout) getLayoutInflater().inflate(R.layout.about, navigationView, false); dialog.setCanceledOnTouchOutside(true); dialog.setTitle(getString(R.string.title_about)); dialog.setContentView(about); dialog.show(); mDrawerLayout.closeDrawers(); return true; case R.id.os_licences: WebView webView = (WebView) getLayoutInflater().inflate(R.layout.fragment_licence, navigationView, false); webView.getSettings().setUseWideViewPort(true); webView.loadUrl("file:///android_asset/licences.html"); AlertDialog alertDialog = new AlertDialog.Builder(DashboardActivity.this, R.style.Theme_Taverna_Dialog).setTitle(getString(R.string.title_nav_os_licences)) .setView(webView).setPositiveButton(android.R.string.ok, null).create(); alertDialog.show(); mDrawerLayout.closeDrawers(); return true; case R.id.nav_settings: startActivity(new Intent(getApplicationContext(), SettingsActivity.class)); overridePendingTransition(android.R.anim.slide_in_left, android.R.anim.slide_out_right); mDrawerLayout.closeDrawers(); return true; case R.id.nav_logout: mDrawerLayout.closeDrawers(); dataManager.getPreferencesHelper().setLoggedInFlag(false); startActivity(new Intent(getApplicationContext(), LoginActivity.class)); finish(); return true; } return true; } }); }
From source file:com.bigpigs.main.MainActivity.java
public void initNavMenu() { if (navigationView != null) { if (userModel.getUserType().equals(UserModel.TYPE_OWNER)) { navigationView/*w w w . j a va2 s. co m*/ .setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { // This method will trigger on item Click of navigation menu @Override public boolean onNavigationItemSelected(MenuItem menuItem) { menuItem.setChecked(true); navigationView.setCheckedItem(menuItem.getItemId()); switch (menuItem.getItemId()) { case R.id.menu_home: { frameLayout.setVisibility(View.GONE); viewPager.setVisibility(View.VISIBLE); tabs.setVisibility(View.VISIBLE); mDrawerLayout.closeDrawers(); break; } case R.id.menu_notification: { Utils.openDialog(MainActivity.this, "Chc nng hin ti khng kh dng"); break; } case R.id.menu_search: { // Log.d(TAG,); mSearchFragment = SearchFragment.newInstance(listSystemData, ""); replaceFragment(mSearchFragment, mSearchFragment.getClass().getName()); mDrawerLayout.closeDrawers(); break; } case R.id.menu_manage: { replaceFragment(new OwnerFragment().newInstance("", ""), OwnerFragment.class.getName()); mDrawerLayout.closeDrawers(); break; } case R.id.menu_settings: { replaceFragment(new SettingsFragment().newInstance("", ""), NotifcationFragment.class.getName()); mDrawerLayout.closeDrawers(); break; } case R.id.menu_logout: { logoutDialog(); mDrawerLayout.closeDrawers(); break; } } return true; } }); } else { navigationView .setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { // This method will trigger on item Click of navigation menu @Override public boolean onNavigationItemSelected(MenuItem menuItem) { // ShowToast.showToastLong(MainActivity.this,mSystemPitchArrayList.size()+""); menuItem.setChecked(true); navigationView.setCheckedItem(menuItem.getItemId()); switch (menuItem.getItemId()) { case R.id.menu_home: { frameLayout.setVisibility(View.GONE); viewPager.setVisibility(View.VISIBLE); tabs.setVisibility(View.VISIBLE); mDrawerLayout.closeDrawers(); break; } case R.id.menu_notification: { Utils.openDialog(MainActivity.this, "Chc nng hin ti khng kh dng"); break; } case R.id.menu_search: { // Log.d(TAG,); mSearchFragment = SearchFragment.newInstance(listSystemData, ""); replaceFragment(mSearchFragment, mSearchFragment.getClass().getName()); mDrawerLayout.closeDrawers(); break; } case R.id.menu_manage: { replaceFragment(new UserOrderManagement(""), OwnerFragment.class.getName()); mDrawerLayout.closeDrawers(); break; } case R.id.menu_settings: { replaceFragment(new SettingsFragment().newInstance("", ""), NotifcationFragment.class.getName()); mDrawerLayout.closeDrawers(); break; } case R.id.menu_logout: { logoutDialog(); mDrawerLayout.closeDrawers(); break; } } return true; } }); } } }
From source file:net.simonvt.cathode.ui.fragment.UpcomingShowsFragment.java
@Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.menu_hidden: showHidden = !showHidden;//from w ww.j ava2 s . c o m settings.edit().putBoolean(Settings.SHOW_HIDDEN, showHidden).apply(); getLoaderManager().restartLoader(Loaders.LOADER_SHOWS_UPCOMING, null, UpcomingShowsFragment.this); item.setChecked(showHidden); return true; case R.id.sort_by: ArrayList<ListDialog.Item> items = new ArrayList<ListDialog.Item>(); items.add(new ListDialog.Item(R.id.sort_title, R.string.sort_title)); items.add(new ListDialog.Item(R.id.sort_next_episode, R.string.sort_next_episode)); ListDialog.newInstance(R.string.action_sort_by, items, UpcomingShowsFragment.this) .show(getFragmentManager(), DIALOG_SORT); return true; case R.id.menu_refresh: jobManager.addJob(new SyncJob()); return true; default: return super.onMenuItemClick(item); } }
From source file:com.syncedsynapse.kore2.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(); getLoaderManager().restartLoader(LOADER_TVSHOWS, null, this); break;// www .j av a2s. c om case R.id.action_ignore_prefixes: item.setChecked(!item.isChecked()); preferences.edit().putBoolean(Settings.KEY_PREF_TVSHOWS_IGNORE_PREFIXES, item.isChecked()).apply(); getLoaderManager().restartLoader(LOADER_TVSHOWS, null, this); 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(); getLoaderManager().restartLoader(LOADER_TVSHOWS, null, this); 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(); getLoaderManager().restartLoader(LOADER_TVSHOWS, null, this); break; default: break; } return super.onOptionsItemSelected(item); }
From source file:com.syncedsynapse.kore2.ui.TVShowEpisodeListFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_hide_watched: item.setChecked(!item.isChecked()); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); preferences.edit().putBoolean(Settings.KEY_PREF_TVSHOW_EPISODES_FILTER_HIDE_WATCHED, item.isChecked()) .apply();//from w w w. j a v a 2 s . c o m getLoaderManager().restartLoader(LOADER_SEASONS, null, this); break; default: break; } return super.onOptionsItemSelected(item); }
From source file:com.fjoglar.etsitnoticias.view.activities.NewsListActivity.java
private void setUpDrawerContent(NavigationView navigationView) { navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override/*from w ww.ja va2 s. c o m*/ public boolean onNavigationItemSelected(MenuItem menuItem) { switch (menuItem.getItemId()) { case R.id.list_navigation_menu_item: // Do nothing, we're already on that screen menuItem.setChecked(true); break; case R.id.bookmarks_navigation_menu_item: menuItem.setChecked(true); Navigator.getInstance().navigateToBookmarksList(getContext()); overridePendingTransition(R.anim.push_down_in, R.anim.push_down_out); break; case R.id.settings_navigation_menu_item: Navigator.getInstance().navigateToSettings(getContext()); overridePendingTransition(R.anim.push_up_in, R.anim.push_up_out); break; case R.id.about_navigation_menu_item: Navigator.getInstance().navigateToAbout(getContext()); overridePendingTransition(R.anim.push_up_in, R.anim.push_up_out); break; default: break; } // Close the navigation drawer when an item is selected. drawerLayout.closeDrawers(); return true; } }); }
From source file:com.syncedsynapse.kore2.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(); getLoaderManager().restartLoader(LOADER_MOVIES, null, this); break;//from w w w .ja v a 2 s. co m case R.id.action_ignore_prefixes: item.setChecked(!item.isChecked()); preferences.edit().putBoolean(Settings.KEY_PREF_MOVIES_IGNORE_PREFIXES, item.isChecked()).apply(); getLoaderManager().restartLoader(LOADER_MOVIES, null, this); 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(); getLoaderManager().restartLoader(LOADER_MOVIES, null, this); 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(); getLoaderManager().restartLoader(LOADER_MOVIES, null, this); break; default: break; } return super.onOptionsItemSelected(item); }
From source file:com.owncloud.android.ui.adapter.UserListAdapter.java
private boolean optionsItemSelected(Menu menu, MenuItem item, AppCompatCheckBox allowEditsCheckBox, OCShare share) {/* w w w . ja va 2 s. c om*/ switch (item.getItemId()) { case R.id.action_can_edit_create: case R.id.action_can_edit_change: case R.id.action_can_edit_delete: { item.setChecked(!item.isChecked()); if (item.isChecked() && !allowEditsCheckBox.isChecked()) { allowEditsCheckBox.setChecked(true); } share.setPermissions(updatePermissionsToShare(share, menu.findItem(R.id.action_can_reshare).isChecked(), allowEditsCheckBox.isChecked(), menu.findItem(R.id.action_can_edit_create).isChecked(), menu.findItem(R.id.action_can_edit_change).isChecked(), menu.findItem(R.id.action_can_edit_delete).isChecked())); return true; } case R.id.action_can_reshare: { item.setChecked(!item.isChecked()); share.setPermissions(updatePermissionsToShare(share, menu.findItem(R.id.action_can_reshare).isChecked(), allowEditsCheckBox.isChecked(), menu.findItem(R.id.action_can_edit_create).isChecked(), menu.findItem(R.id.action_can_edit_change).isChecked(), menu.findItem(R.id.action_can_edit_delete).isChecked())); return true; } case R.id.action_unshare: { listener.unshareWith(share); shares.remove(share); notifyDataSetChanged(); return true; } case R.id.action_hide_file_listing: { item.setChecked(!item.isChecked()); if (capabilities.getFilesFileDrop().isTrue()) { listener.setHideFileListingPermissionsToShare(share, item.isChecked()); } else { // not supported in ownCloud listener.showNotSupportedByOcMessage(); } return true; } case R.id.action_password: { listener.requestPasswordForShare(share); return true; } case R.id.action_expiration_date: { ExpirationDatePickerDialogFragment dialog = ExpirationDatePickerDialogFragment.newInstance(share, -1); dialog.show(fragmentManager, ExpirationDatePickerDialogFragment.DATE_PICKER_DIALOG); return true; } default: return true; } }
From source file:cx.ring.client.HomeActivity.java
@Override public boolean onNavigationItemSelected(MenuItem pos) { pos.setChecked(true); mNavigationDrawer.closeDrawers();//from w ww . j ava 2 s . c om switch (pos.getItemId()) { case R.id.menuitem_home: if (fContent instanceof CallListFragment) break; if (getFragmentManager().getBackStackEntryCount() == 1) break; popCustomBackStack(); break; case R.id.menuitem_accounts: if (fContent instanceof AccountsManagementFragment) break; fContent = new AccountsManagementFragment(); getFragmentManager().beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE) .replace(R.id.main_frame, fContent, "Accounts").addToBackStack("Accounts").commit(); break; case R.id.menuitem_about: if (fContent instanceof AboutFragment) break; fContent = new AboutFragment(); getFragmentManager().beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE) .replace(R.id.main_frame, fContent, "About").addToBackStack("About").commit(); break; case R.id.menuitem_prefs: if (fContent instanceof SettingsFragment) break; fContent = new SettingsFragment(); getFragmentManager().beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE) .replace(R.id.main_frame, fContent, "Prefs").addToBackStack("Prefs").commit(); break; default: return false; } return true; }