List of usage examples for android.view MenuItem isChecked
public boolean isChecked();
From source file:com.owncloud.android.ui.adapter.UserListAdapter.java
private boolean optionsItemSelected(Menu menu, MenuItem item, AppCompatCheckBox allowEditsCheckBox, OCShare share) {//from w ww .j a v a 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:pl.bcichecki.rms.client.android.fragments.EventsListFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); getActivity().getMenuInflater().inflate(R.menu.fragment_events_list, menu); MenuItem showArchivedMenuItem = menu.findItem(R.id.fragment_events_list_menu_show_archived); showArchivedMenuItem.setChecked(showArchivedEvents); showArchivedMenuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override/*w w w . jav a 2 s . c o m*/ public boolean onMenuItemClick(MenuItem item) { item.setChecked(!item.isChecked()); showArchivedEvents = item.isChecked(); downloadData(); downloadArchivedData(); return false; } }); }
From source file:com.androguide.honamicontrol.soundcontrol.SoundControlFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.link_seekbars: SharedPreferences soundPrefs = fa.getSharedPreferences("SOUND_CONTROL", 0); if (item.isChecked()) { item.setChecked(false);/* w w w.ja va2 s . c o m*/ soundPrefs.edit().putBoolean("LINKED", false).commit(); } else { item.setChecked(true); soundPrefs.edit().putBoolean("LINKED", true).commit(); } break; } return super.onOptionsItemSelected(item); }
From source file:org.mariotaku.twidere.fragment.support.RetweetQuoteDialogFragment.java
private void retweetOrQuote(AsyncTwitterWrapper twitter, ParcelableStatus status) { if (mEditComment.length() > 0) { final Menu menu = mPopupMenu.getMenu(); final MenuItem quoteOriginalStatus = menu.findItem(R.id.quote_original_status); final MenuItem linkToQuotedStatus = menu.findItem(R.id.link_to_quoted_status); final Uri statusLink; final long inReplyToStatusId; if (!status.is_quote) { inReplyToStatusId = status.id; statusLink = LinkCreator.getTwitterStatusLink(status.user_screen_name, status.id); } else if (quoteOriginalStatus.isChecked()) { inReplyToStatusId = status.quote_id; statusLink = LinkCreator.getTwitterStatusLink(status.user_screen_name, status.quote_id); } else {//from www . j a v a 2s .co m inReplyToStatusId = status.id; statusLink = LinkCreator.getTwitterStatusLink(status.quoted_by_user_screen_name, status.id); } final String commentText = mEditComment.getText() + " " + statusLink; twitter.updateStatusAsync(new long[] { status.account_id }, commentText, null, null, linkToQuotedStatus.isChecked() ? inReplyToStatusId : -1, status.is_possibly_sensitive); } else if (isMyRetweet(status)) { twitter.cancelRetweetAsync(status.account_id, status.id, status.my_retweet_id); } else { twitter.retweetStatusAsync(status.account_id, status.id); } }
From source file:com.example.amand.mobileprogrammingfitnessapp.LoggedActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_logged); // toolbar reference, and is used to instantiate the toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setTitleTextColor(0xFFFFFFFF); setSupportActionBar(toolbar);//from ww w . j ava2 s . c om // this sets the toolbar colour and replaces the action bar, although this activity has style // of no actionbar // dialog is instantiated, and is set up with appropriate message, that is displayed when the user // presses the about icon dialog = new AlertDialog.Builder(this); dialog.setTitle("About"); dialog.setMessage("This appliation was developed for Mobile & Ubiquitous Computing. This application" + "is a fitness app and composed of contents, such as nutrition, health, exercises and gym facilities." + "The gym facilities provides numerous features, such as displaying gyms near you" + System.lineSeparator() + "The application makes use of a circular Imageview that under apache 2.0 Licencing" + "http://www.apache.org/licenses/LICENSE-2.0.txt"); // Reference to the database object, which is used to recieve users information database = new Database(getApplicationContext(), null, null, 1); // reference to the navogationn view that consists of navigation header and items navigationView = (NavigationView) findViewById(R.id.navigation_view); // the first fragment is loaded switchFragment(1); toolbar.setTitle("Nutrition"); // the references to textviews and circle imageview to change the details of the navigation drawer header = navigationView.getHeaderView(0); circle = (CircleImageView) header.findViewById(R.id.profile_image); namee = (TextView) header.findViewById(R.id.fullnameheader); username = (TextView) header.findViewById(R.id.usernameheader); naviagtionbackground = (RelativeLayout) header.findViewById(R.id.navbackground); // reference to the drawerlayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer); // reference to framelayout frame = (FrameLayout) findViewById(R.id.Screen); // the decode stream decode = new byte[100]; // this gets the information that is passed in from the register screen. The data is the username, and //is needed when using the database methods // if the data recieved is null, then the visabilty of the setting icon is false Intent intt = getIntent(); temp = intt.getStringExtra("key"); if (temp == null) { setting = false; } //Two methods are called, when the oncreate method has ran, the first method is responsible //in displaying the users detail in the navigation drawer, takes the username as parameters // Likewise the loadpreference method, loads the preference of each user setNavigationDetails(temp); loadpreferences(temp); // // database.loadPreferenes(temp); // objectDdecode = database.loadPreferenes(temp); // Toast.makeText(getApplicationContext(),"done" +database.loadPreferenes(temp).toString(),Toast.LENGTH_LONG).show(); // Toast.makeText(getApplicationContext(),objectDdecode.toString(),Toast.LENGTH_LONG).show(); // the naviagtion view is set with item click listener. This listens to the click of items that are // present in the application navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { // this method is responosble for dealing with the menu items that have been clicked. public boolean onNavigationItemSelected(MenuItem menuItem) { // checks if the item has been selected, if its not selected set to false // else make it true to indicate its been checked if (menuItem.isChecked()) menuItem.setChecked(false); else menuItem.setChecked(true); //closes the naviagtion drawer once checked drawerLayout.closeDrawers(); //switch condidtion to assess what action is performed once the item has been checked switch (menuItem.getItemId()) { // the nutrition fragment is selected, if the gym icon is showing, it will disappear // the toolbar text is also set to nutrition case R.id.nutritionF: switchFragment(1); show = false; // reloads the option menu invalidateOptionsMenu(); toolbar.setTitle("Nutrition"); return true; // the health fragment is selected, if the gym icon is showing, it will disappear // the toolbar text is also set to Health case R.id.HealthF: switchFragment(3); toolbar.setTitle("Health"); show = false; // reloads the option menu invalidateOptionsMenu(); return true; // the exercie fragment is selected, if the gym icon is showing, it will disappear // the toolbar text is also set to Exercise case R.id.ExerciseF: Toast.makeText(getApplicationContext(), "Exercise", Toast.LENGTH_SHORT).show(); switchFragment(2); toolbar.setTitle("Exercises"); show = false; // reloads the option menu invalidateOptionsMenu(); return true; // the gym fragment is selected, if the gym icon is not showing, it will appear // the toolbar text is also set to gym case R.id.GymF: Toast.makeText(getApplicationContext(), "Gym Selected", Toast.LENGTH_SHORT).show(); switchFragment(4); toolbar.setTitle("Gym Facilities"); show = true; // reloads the option menu, to show the gym action icon invalidateOptionsMenu(); return true; // the logout item would just be intent back to the login screen. // to ensure user cannot travel back, the finish method is called to delete activity off the // stack case R.id.logoffF: Intent intt = new Intent(getApplicationContext(), LoginScreen.class); startActivity(intt); finish(); return true; // by default, even though this shouldnt happen, a toast message is presented to the user default: Toast.makeText(getApplicationContext(), "Somethings Wrong, please contact amandeep for more detail", Toast.LENGTH_SHORT).show(); return true; } } }); //Syncs the actionbartoggle to sync in with the toolbar new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.opendrawer, R.string.closedrawer) .syncState(); }
From source file:com.dogar.geodesic.map.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (mDrawerToggle.onOptionsItemSelected(item)) { return true; }/*from w w w . j a va 2 s . co m*/ // Handle action buttons switch (item.getItemId()) { case R.id.delete_mode: reverseCheck(item); GMFragment.setDeleteMode(item.isChecked()); return true; case R.id.menu_refresh: SyncUtils.TriggerRefresh(); return true; case R.id.map_terrain: reverseCheck(item); GMFragment.getMap().setMapType(GoogleMap.MAP_TYPE_TERRAIN); return true; case R.id.map_normal: reverseCheck(item); GMFragment.getMap().setMapType(GoogleMap.MAP_TYPE_NORMAL); return true; case R.id.map_hybrid: reverseCheck(item); GMFragment.getMap().setMapType(GoogleMap.MAP_TYPE_HYBRID); return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.pawnua.android.app.gpstrips.activities.TripDetailActivity.java
@Override 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);//from www .ja v a2 s . c o m else menuItem.setChecked(true); //Closing drawer on item click drawerLayout.closeDrawers(); //Check to see which item was being clicked and perform appropriate action switch (menuItem.getItemId()) { case R.id.action_openMap: openMap(); return true; case R.id.action_show_camera: { takePhoto(); return true; } case R.id.action_show_gallery: { openThumbGallery(); return true; } case R.id.action_export: { saveTripTask(trip); return true; } case R.id.action_about: { new AboutFragment().show(mFragmentManager, "about_layout"); return true; } default: Toast.makeText(getApplicationContext(), R.string.SmthWrong, Toast.LENGTH_SHORT).show(); return true; } }
From source file:com.orange.ocara.ui.activity.ListAuditActivity.java
void onSortMenuItem(MenuItem menuItem, SortCriteria.Type sortCriteriaType) { SortCriteria sortCriteria = null;/*from ww w . j a v a2 s .co m*/ // If already checked toggle current sortCriteria if (menuItem.isChecked()) { sortCriteria = auditListAdapter.getSortCriteria(); sortCriteria.toggleOrder(); } else { sortCriteria = sortCriteriaType.build(); } auditListAdapter.refreshWithSortCriteria(sortCriteria); supportInvalidateOptionsMenu(); }
From source file:org.voidsink.anewjkuapp.fragment.StatFragmentDetail.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_refresh_stats: Intent mUpdateService = new Intent(getActivity(), UpdateService.class); mUpdateService.putExtra(Consts.ARG_UPDATE_KUSSS_COURSES, true); mUpdateService.putExtra(Consts.ARG_UPDATE_KUSSS_ASSESSMENTS, true); getActivity().startService(mUpdateService); return true; case R.id.action_toggle_grades: item.setChecked(item.isCheckable() && !item.isChecked()); PreferenceWrapper.setPrefPositiveGradesOnly(getContext(), item.isChecked()); return true; default:/*from w w w . ja v a 2 s . c om*/ return super.onOptionsItemSelected(item); } }
From source file:eu.pellerito.movies.fragment.BaseFragment.java
@Override public boolean onOptionsItemSelected(@NonNull MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. switch (item.getItemId()) { case R.id.menu_sort_popular: mOrder = String.valueOf(Costants.POPULAR); // update date updateUI();/*from ww w .j a va2 s. c o m*/ /* * click checked controls * */ if (item.isChecked()) item.setChecked(false); else item.setChecked(true); return true; case R.id.menu_sort_top_rated: mOrder = String.valueOf(Costants.TOP_RATED); // update date updateUI(); /* * click checked controls * */ if (item.isChecked()) item.setChecked(false); else item.setChecked(true); return true; default: return super.onOptionsItemSelected(item); } }