private void retweetOrQuote(AsyncTwitterWrapper twitter, ParcelableStatus status) { final Dialog dialog = getDialog(); if (dialog == null) return; final EditText editComment = ((EditText) dialog.findViewById(R.id.edit_comment)); if (editComment.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 || !quoteOriginalStatus.isChecked()) { inReplyToStatusId = status.id; statusLink = LinkCreator.getTwitterStatusLink(status.user_screen_name, status.id); } else { inReplyToStatusId = status.quoted_id; statusLink = LinkCreator.getTwitterStatusLink(status.quoted_user_screen_name, status.quoted_id); } final String commentText = editComment.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); } }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); if (imm.isActive()) imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_NOT_ALWAYS); finish(); break; case R.id.menu_enable_ori_comment: if (enableCommentOri.isChecked()) { enableCommentOri.setChecked(false); } else { enableCommentOri.setChecked(true); } break; case R.id.menu_enable_repost: if (enableRepost.isChecked()) { enableRepost.setChecked(false); } else { enableRepost.setChecked(true); } break; case R.id.menu_at: Intent intent = new Intent(WriteCommentActivity.this, AtUserActivity.class); intent.putExtra("token", token); startActivityForResult(intent, AT_USER); break; } return true; }
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will RelativeLayout main_view = (RelativeLayout) findViewById(R.id.main_view); switch (item.getItemId()) { case R.id.menu_red: if (item.isChecked()) item.setChecked(false); else item.setChecked(true); main_view.setBackgroundColor(Color.RED); return true; case R.id.menu_green: if (item.isChecked()) item.setChecked(false); else item.setChecked(true); main_view.setBackgroundColor(Color.GREEN); return true; case R.id.menu_yellow: if (item.isChecked()) item.setChecked(false); else item.setChecked(true); main_view.setBackgroundColor(Color.YELLOW); return true; default: return super.onOptionsItemSelected(item); } }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.sort_title: musicSrv.sortTitle(); break; case R.id.sort_author: musicSrv.sortAuthor(); break; case R.id.sort_album: musicSrv.sortAlbum(); break; case R.id.sort_length: musicSrv.sortLength(); break; case R.id.browse: Intent i = new Intent(getApplicationContext(), BrowseMedia.class); startActivity(i); break; case R.id.circle: item.setChecked(!item.isChecked()); SharedPreferences settings = getSharedPreferences("settings", 0); SharedPreferences.Editor editor = settings.edit(); editor.putBoolean("circle", item.isChecked()); editor.apply(); break; } return super.onOptionsItemSelected(item); }
@Override public void onClick(final DialogInterface dialog, final int which) { final ParcelableStatus status = getStatus(); if (status == null) return; switch (which) { case DialogInterface.BUTTON_POSITIVE: { final AsyncTwitterWrapper twitter = mTwitterWrapper; if (twitter == null) return; retweetOrQuote(twitter, status); break; } case DialogInterface.BUTTON_NEUTRAL: { final Intent intent = new Intent(INTENT_ACTION_QUOTE); final Menu menu = mPopupMenu.getMenu(); final MenuItem quoteOriginalStatus = menu.findItem(R.id.quote_original_status); intent.putExtra(EXTRA_STATUS, status); intent.putExtra(EXTRA_QUOTE_ORIGINAL_STATUS, quoteOriginalStatus.isChecked()); startActivity(intent); break; } default: break; } }
/** * 1. this message has repost's message 2. this message is an original message * * <p>if this message has repost's message,try to include its content, if total word number above * 140,discard current msg content */ private ItemBean repost() throws WeiboException { String content = ((EditText) findViewById(R.id.status_new_content)).getText().toString(); if (msg.getRetweeted_status() != null) { String msgContent = "//@" + msg.getUser().getScreen_name() + ": " + msg.getText(); String total = content + msgContent; if (total.length() < 140) { content = total; } } RepostNewMsgDao dao = new RepostNewMsgDao(token, msg.getId()); boolean comment = true; boolean oriComment = enableCommentOri.isChecked(); if (comment && oriComment) { dao.setIs_comment(RepostNewMsgDao.ENABLE_COMMENT_ALL); } else if (comment) { dao.setIs_comment(RepostNewMsgDao.ENABLE_COMMENT); } else if (oriComment) { dao.setIs_comment(RepostNewMsgDao.ENABLE_ORI_COMMENT); } dao.setStatus(content); return dao.sendNewMsg(); }
@Override public boolean onOptionsItemSelected(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. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_splash) { item.setChecked(!item.isChecked()); preferenceHelper.putBoolean(PreferenceHelper.SPLASH_IS_INVISIBLE, item.isChecked()); return true; } return super.onOptionsItemSelected(item); }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.check_enable_compression: { toggleEnableCompression(item, !item.isChecked()); break; } // case R.id.check_hidden_recipients: { // mHiddenRecipients = item.isChecked(); // notifyUpdate(); // break; // } case R.id.encrypt_copy: { mShareAfterEncrypt = false; cryptoOperation(); break; } case R.id.encrypt_share: { mShareAfterEncrypt = true; cryptoOperation(); break; } default: { return super.onOptionsItemSelected(item); } } return true; }
// This method will trigger on item Click of navigation menu @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); 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.option_1: Toast.makeText(getApplicationContext(), "Option 1 Selected", Toast.LENGTH_SHORT).show(); launchHomeFragment(); return true; case R.id.option_2: Toast.makeText(getApplicationContext(), "Option 2 Selected", Toast.LENGTH_SHORT).show(); return true; case R.id.option_3: Toast.makeText(getApplicationContext(), "Option 3 Selected", Toast.LENGTH_SHORT).show(); return true; default: Toast.makeText(getApplicationContext(), "Somethings Wrong", Toast.LENGTH_SHORT).show(); return true; } }
public int navigationDrawer() { for (int i = 0; i < mNavigationView.getMenu().size(); i++) { final MenuItem menuItem = mNavigationView.getMenu().getItem(i); if (menuItem.isChecked()) { return menuItem.getItemId(); } } return -1; }
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.content) { Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM); File output = new File(dir, "CameraContentDemo.jpeg"); i.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(output)); startActivityForResult(i, CONTENT_REQUEST); } else if (item.getItemId() == R.id.landscape) { item.setChecked(!item.isChecked()); current.lockToLandscape(item.isChecked()); isLockedToLandscape = item.isChecked(); } return (super.onOptionsItemSelected(item)); }
// Selection-of-Menu @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle presses on the action bar items switch (item.getItemId()) { case R.id.action_refresh: Intent i = new Intent(Sunday.this, SundayActivity.class); startActivity(i); break; case R.id.action_settings: mySQL.DeleteAll(); onCreate(new Bundle()); break; case R.id.notification: Calendar calendar = Calendar.getInstance(); int day = calendar.get(Calendar.DAY_OF_WEEK); Intent not_Intent; if (item.isChecked()) { item.setChecked(false); editor = someData.edit(); editor.putBoolean("CHECK", false); editor.commit(); nm.cancel(0); } else { item.setChecked(true); editor = someData.edit(); editor.putBoolean("CHECK", true); editor.commit(); if ((values.length != 0) && day == Calendar.SUNDAY) { nm.notify(0, n); } else if (day == Calendar.WEDNESDAY) { not_Intent = new Intent(Sunday.this, Wednesday.class); startActivity(not_Intent); } else if (day == Calendar.THURSDAY) { not_Intent = new Intent(Sunday.this, Thursday.class); startActivity(not_Intent); } else if (day == Calendar.FRIDAY) { not_Intent = new Intent(Sunday.this, Friday.class); startActivity(not_Intent); } else if (day == Calendar.TUESDAY) { not_Intent = new Intent(Sunday.this, Tuesday.class); startActivity(not_Intent); } else if (day == Calendar.SATURDAY) { not_Intent = new Intent(Sunday.this, Saturday.class); startActivity(not_Intent); } else if (day == Calendar.MONDAY) { not_Intent = new Intent(Sunday.this, Monday.class); startActivity(not_Intent); } break; } } if (drawertoggle.onOptionsItemSelected(item)) { return true; } return super.onOptionsItemSelected(item); }
@Override protected ItemBean sendData() throws WeiboException { if (!enableRepost.isChecked()) { CommentNewMsgDao dao = new CommentNewMsgDao( token, msg.getId(), ((EditText) findViewById(R.id.status_new_content)).getText().toString()); if (enableCommentOri.isChecked()) { dao.enableComment_ori(true); } else { dao.enableComment_ori(false); } return dao.sendNewMsg(); } else { return repost(); } }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_sspai: openUrl("http://sspai.com/dfg"); return true; case R.id.menu_checkbox_glare: updateGlareSetting(!item.isChecked()); return true; case R.id.menu_checkbox_shadow: updateShadowSetting(!item.isChecked()); return true; case R.id.menu_about: Intent intent = new Intent(getApplicationContext(), AboutActivity.class); startActivity(intent); return true; default: return super.onOptionsItemSelected(item); } }
// http://stackoverflow.com/questions/15686555/display-back-button-on-action-bar @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: // app icon in action bar clicked; go home controls.jAppOnBackPressed(); return true; default: String caption = item.getTitle().toString(); controls.jAppOnClickOptionMenuItem(item, item.getItemId(), caption, item.isChecked()); return true; // renabor } }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.turni_passati: if (item.isChecked()) { item.setChecked(false); passati = false; } else { item.setChecked(true); passati = true; } aggiornalist(); return true; default: return super.onOptionsItemSelected(item); } }
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.menu_add_task) { onAddNewTask(); return true; } else if (item.getItemId() == R.id.menu_visible_list) { Intent settingsIntent = new Intent(getBaseContext(), SyncSettingsActivity.class); startActivity(settingsIntent); 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); } }
@SuppressLint("SetTextI18n") @Override public boolean onOptionsItemSelected(MenuItem item) { if (Constants.DEBUG && item.getItemId() == R.id.debug_accept_any_log) { boolean newCheckedState = !item.isChecked(); item.setChecked(newCheckedState); mDebugModeAcceptAnyCode = newCheckedState; if (newCheckedState && TextUtils.isEmpty(mCodeEditText[0].getText())) { mCodeEditText[0].setText("ABCD"); mCodeEditText[1].setText("EFGH"); mCodeEditText[2].setText("IJKL"); mCodeEditText[3].setText("MNOP"); mCodeEditText[4].setText("QRST"); mCodeEditText[5].setText("UVWX"); Notify.create(getActivity(), "Actual backup code is all 'A's", Style.WARN).show(); } return true; } return super.onOptionsItemSelected(item); }
@SuppressWarnings("StatementWithEmptyBody") @Override public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. if (item.isChecked()) return true; int id = item.getItemId(); final ForecastFragment fragment; switch (id) { case R.id.review: fragment = new CurrentlyFragment(); break; case R.id.daily: fragment = new DailyFragment(); break; case R.id.hourly: fragment = new HourlyForecast(); break; default: devDialog.show(); return true; } new Handler() .postDelayed( new Runnable() { @Override public void run() { getFragmentManager() .beginTransaction() // .setCustomAnimations(R.animator.slide_in_up, R.animator.slide_out_up) .replace(R.id.frame, fragment, FRAGMENT_TAG) .commit(); } }, 300); drawerLayout.closeDrawer(GravityCompat.START); return true; }
@Override public boolean onOptionsItemSelected(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. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_connect) { showDeviceListDialog(); return true; } else if (id == R.id.action_disconnect) { bluetoothSerial.stop(); return true; } else if (id == R.id.action_crlf) { crlf = !item.isChecked(); item.setChecked(crlf); return true; } return super.onOptionsItemSelected(item); }
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.menu_item_bookmark) { Movie selectedMovie = getIntent().getParcelableExtra(DetailActivity.EXTRASCURRENTMOVIE); if (item.isChecked()) { item.setIcon(R.drawable.ic_bookmark_outline_plus); item.setChecked(false); if (selectedMovie != null) { removeMovieFromFavs(selectedMovie); } } else { item.setIcon(R.drawable.bookmark_plus); item.setChecked(true); if (selectedMovie != null) { addMovieToFavs(selectedMovie); } } return true; } return super.onOptionsItemSelected(item); }
@Override public boolean onOptionsItemSelected(MenuItem item) { if (DEBUG) Log.e(TAG, "onOptionsItemSelected"); switch (item.getItemId()) { case R.id.bbcode_bold: insertBBCode(BBCODE.BOLD); break; case R.id.bbcode_italics: insertBBCode(BBCODE.ITALICS); break; case R.id.bbcode_underline: insertBBCode(BBCODE.UNDERLINE); break; case R.id.bbcode_strikeout: insertBBCode(BBCODE.STRIKEOUT); break; case R.id.bbcode_url: insertBBCode(BBCODE.URL); break; case R.id.bbcode_video: insertBBCode(BBCODE.VIDEO); break; case R.id.bbcode_image: insertBBCode(BBCODE.IMAGE); break; case R.id.bbcode_thumbnail: insertBBCode(BBCODE.THUMBNAIL); break; case R.id.bbcode_quote: insertBBCode(BBCODE.QUOTE); break; case R.id.bbcode_spoiler: insertBBCode(BBCODE.SPOILER); break; case R.id.bbcode_code: insertBBCode(BBCODE.CODE); break; case R.id.submit_button: postReply(); break; case R.id.discard: deleteReply(); getActivity().setResult(RESULT_CANCELLED); leave(); break; case R.id.save_draft: saveReply(); getActivity().setResult(RESULT_CANCELLED); leave(); break; case R.id.emotes: selectionStart = mMessage.getSelectionStart(); new EmoteFragment(this).show(getFragmentManager(), "emotes"); break; case R.id.add_attachment: Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("image/*"); startActivityForResult(Intent.createChooser(intent, "Select Picture"), ADD_ATTACHMENT); break; case R.id.remove_attachment: this.mFileAttachment = null; Toast removeToast = Toast.makeText( getAwfulActivity(), getAwfulActivity().getResources().getText(R.string.file_removed), Toast.LENGTH_SHORT); removeToast.show(); invalidateOptionsMenu(); break; case R.id.signature: item.setChecked(!item.isChecked()); postSignature = item.isChecked(); break; case R.id.disableEmots: item.setChecked(!item.isChecked()); disableEmots = item.isChecked(); break; default: return super.onOptionsItemSelected(item); } return true; }
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); setupDateTimeInterpreter(id == R.id.action_week_view); switch (id) { case android.R.id.home: finish(); break; case R.id.action_today: mWeekView.goToToday(); return true; case R.id.action_day_view: if (mWeekViewType != TYPE_DAY_VIEW) { item.setChecked(!item.isChecked()); mWeekViewType = TYPE_DAY_VIEW; mWeekView.setNumberOfVisibleDays(1); // Lets change some dimensions to best fit the view. mWeekView.setColumnGap( (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics())); mWeekView.setTextSize( (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_SP, 12, getResources().getDisplayMetrics())); mWeekView.setEventTextSize( (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_SP, 12, getResources().getDisplayMetrics())); } return true; case R.id.action_three_day_view: if (mWeekViewType != TYPE_THREE_DAY_VIEW) { item.setChecked(!item.isChecked()); mWeekViewType = TYPE_THREE_DAY_VIEW; mWeekView.setNumberOfVisibleDays(3); // Lets change some dimensions to best fit the view. mWeekView.setColumnGap( (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics())); mWeekView.setTextSize( (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_SP, 12, getResources().getDisplayMetrics())); mWeekView.setEventTextSize( (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_SP, 12, getResources().getDisplayMetrics())); } return true; case R.id.action_week_view: if (mWeekViewType != TYPE_WEEK_VIEW) { item.setChecked(!item.isChecked()); mWeekViewType = TYPE_WEEK_VIEW; mWeekView.setNumberOfVisibleDays(7); // Lets change some dimensions to best fit the view. mWeekView.setColumnGap( (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 2, getResources().getDisplayMetrics())); mWeekView.setTextSize( (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_SP, 10, getResources().getDisplayMetrics())); mWeekView.setEventTextSize( (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_SP, 10, getResources().getDisplayMetrics())); } return true; } return super.onOptionsItemSelected(item); }
/*by jmpessoa: Handles menu item selections*/ @Override public boolean onContextItemSelected(MenuItem item) { String caption = item.getTitle().toString(); controls.jAppOnClickContextMenuItem(item, item.getItemId(), caption, item.isChecked()); return false; }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.descargas: { startActivity(new Intent(this, ActivityDownloads.class)); break; } case R.id.action_hide_read: { item.setChecked(!item.isChecked()); pm.edit() .putInt( FragmentMisMangas.SELECT_MODE, item.isChecked() ? FragmentMisMangas.MODE_HIDE_READ : FragmentMisMangas.MODE_SHOW_ALL) .apply(); if (fragmentMisMangas != null) fragmentMisMangas.setListManga(); break; } case R.id.action_configurar: { startActivity(new Intent(this, ActivitySettings.class)); break; } case R.id.sort_last_read: { item.setChecked(true); pm.edit().putInt("manga_view_sort_by", 0).apply(); fragmentMisMangas.setListManga(); break; } case R.id.sort_last_read_asc: { item.setChecked(true); pm.edit().putInt("manga_view_sort_by", 1).apply(); fragmentMisMangas.setListManga(); break; } case R.id.sort_name: { item.setChecked(true); pm.edit().putInt("manga_view_sort_by", 2).apply(); fragmentMisMangas.setListManga(); break; } case R.id.sort_name_asc: { item.setChecked(true); pm.edit().putInt("manga_view_sort_by", 3).apply(); fragmentMisMangas.setListManga(); break; } case R.id.sort_author: { item.setChecked(true); pm.edit().putInt("manga_view_sort_by", 4).apply(); fragmentMisMangas.setListManga(); break; } case R.id.sort_author_asc: { item.setChecked(true); pm.edit().putInt("manga_view_sort_by", 5).apply(); fragmentMisMangas.setListManga(); break; } } return super.onOptionsItemSelected(item); }
@Override public boolean isChecked() { return mNativeItem.isChecked(); }
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); // En cada Boton Seleccionar switch (id) { case R.id.action_sistema_fr_mm: { item.setChecked(!item.isChecked()); pensumValidator = 1; getActivity().invalidateOptionsMenu(); } break; case R.id.action_telecom_fr_mm: { item.setChecked(!item.isChecked()); pensumValidator = 2; getActivity().invalidateOptionsMenu(); } break; case R.id.action_industrial_fr_mm: { item.setChecked(!item.isChecked()); pensumValidator = 3; getActivity().invalidateOptionsMenu(); } break; case R.id.action_civil_fr_mm: { item.setChecked(!item.isChecked()); pensumValidator = 4; getActivity().invalidateOptionsMenu(); } break; case R.id.action_arq_fr_mm: { item.setChecked(!item.isChecked()); pensumValidator = 5; getActivity().invalidateOptionsMenu(); } break; case R.id.action_seAll: { item.setChecked(!item.isChecked()); adapterRecyclerMisMaterias.setListUserMateria(listUMLoad); } break; case R.id.action_se1: { item.setChecked(!item.isChecked()); listUMbySe = new ArrayList<>(); for (int i = 0; i < listUMLoad.size(); i++) { if (listUMLoad.get(i).getSemestre().equals("1")) { listUMbySe.add(listUMLoad.get(i)); } } adapterRecyclerMisMaterias.setListUserMateria(listUMbySe); } break; case R.id.action_se2: { item.setChecked(!item.isChecked()); listUMbySe = new ArrayList<>(); for (int i = 0; i < listUMLoad.size(); i++) { if (listUMLoad.get(i).getSemestre().equals("2")) { listUMbySe.add(listUMLoad.get(i)); } } adapterRecyclerMisMaterias.setListUserMateria(listUMbySe); } break; case R.id.action_se3: { item.setChecked(!item.isChecked()); listUMbySe = new ArrayList<>(); for (int i = 0; i < listUMLoad.size(); i++) { if (listUMLoad.get(i).getSemestre().equals("3")) { listUMbySe.add(listUMLoad.get(i)); } } adapterRecyclerMisMaterias.setListUserMateria(listUMbySe); } break; case R.id.action_se4: { item.setChecked(!item.isChecked()); listUMbySe = new ArrayList<>(); for (int i = 0; i < listUMLoad.size(); i++) { if (listUMLoad.get(i).getSemestre().equals("4")) { listUMbySe.add(listUMLoad.get(i)); } } adapterRecyclerMisMaterias.setListUserMateria(listUMbySe); } break; case R.id.action_se5: { item.setChecked(!item.isChecked()); listUMbySe = new ArrayList<>(); for (int i = 0; i < listUMLoad.size(); i++) { if (listUMLoad.get(i).getSemestre().equals("5")) { listUMbySe.add(listUMLoad.get(i)); } } adapterRecyclerMisMaterias.setListUserMateria(listUMbySe); } break; case R.id.action_se6: { item.setChecked(!item.isChecked()); listUMbySe = new ArrayList<>(); for (int i = 0; i < listUMLoad.size(); i++) { if (listUMLoad.get(i).getSemestre().equals("6")) { listUMbySe.add(listUMLoad.get(i)); } } adapterRecyclerMisMaterias.setListUserMateria(listUMbySe); } break; case R.id.action_se7: { item.setChecked(!item.isChecked()); listUMbySe = new ArrayList<>(); for (int i = 0; i < listUMLoad.size(); i++) { if (listUMLoad.get(i).getSemestre().equals("7")) { listUMbySe.add(listUMLoad.get(i)); } } adapterRecyclerMisMaterias.setListUserMateria(listUMbySe); } break; case R.id.action_se8: { item.setChecked(!item.isChecked()); listUMbySe = new ArrayList<>(); for (int i = 0; i < listUMLoad.size(); i++) { if (listUMLoad.get(i).getSemestre().equals("8")) { listUMbySe.add(listUMLoad.get(i)); } } adapterRecyclerMisMaterias.setListUserMateria(listUMbySe); } break; case R.id.action_se9: { item.setChecked(!item.isChecked()); listUMbySe = new ArrayList<>(); for (int i = 0; i < listUMLoad.size(); i++) { if (listUMLoad.get(i).getSemestre().equals("9")) { listUMbySe.add(listUMLoad.get(i)); } } adapterRecyclerMisMaterias.setListUserMateria(listUMbySe); } break; case R.id.action_se10: { item.setChecked(!item.isChecked()); listUMbySe = new ArrayList<>(); for (int i = 0; i < listUMLoad.size(); i++) { if (listUMLoad.get(i).getSemestre().equals("10")) { listUMbySe.add(listUMLoad.get(i)); } } adapterRecyclerMisMaterias.setListUserMateria(listUMbySe); } break; } return super.onOptionsItemSelected(item); }
@Override public boolean onNavigationItemSelected(MenuItem menuItem) { switch (menuItem.getItemId()) { case R.id.nav_teren: locationView.setTerrainMode(); return true; case R.id.nav_satelita: locationView.setSateliteMode(); return true; case R.id.nav_normal: locationView.setNormalMode(); return true; case R.id.nav_banki: if (!menuItem.isChecked()) { menuItem.setChecked(true); locationView.addPlaceType(Place.PlaceType.BANK); } else { menuItem.setChecked(false); locationView.removePlaceType(Place.PlaceType.BANK); } return true; case R.id.nav_hotele: if (!menuItem.isChecked()) { menuItem.setChecked(true); locationView.addPlaceType(Place.PlaceType.LODGING); } else { menuItem.setChecked(false); locationView.removePlaceType(Place.PlaceType.LODGING); } return true; case R.id.nav_restauracje: if (!menuItem.isChecked()) { menuItem.setChecked(true); locationView.addPlaceType(Place.PlaceType.RESTAURANT); } else { menuItem.setChecked(false); locationView.removePlaceType(Place.PlaceType.RESTAURANT); } return true; case R.id.nav_kawiarnie: if (!menuItem.isChecked()) { menuItem.setChecked(true); locationView.addPlaceType(Place.PlaceType.CAFE); } else { menuItem.setChecked(false); locationView.removePlaceType(Place.PlaceType.CAFE); } return true; case R.id.nav_kina: if (!menuItem.isChecked()) { menuItem.setChecked(true); locationView.addPlaceType(Place.PlaceType.MOVIE_THEATER); } else { menuItem.setChecked(false); locationView.removePlaceType(Place.PlaceType.MOVIE_THEATER); } return true; } return false; }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: sharedPrefs.edit().putBoolean("should_refresh", false).commit(); onBackPressed(); return true; case R.id.menu_settings: Intent settings = new Intent(context, SettingsActivity.class); startActivityForResult(settings, SETTINGS_RESULT); return true; case R.id.menu_save_search: Toast.makeText(context, getString(R.string.saving_search), Toast.LENGTH_SHORT).show(); new Thread( new Runnable() { @Override public void run() { try { Twitter twitter = Utils.getTwitter(context, AppSettings.getInstance(context)); twitter.createSavedSearch( searchQuery.replace(" -RT", "").replace(" TOP", "")); ((Activity) context) .runOnUiThread( new Runnable() { @Override public void run() { Toast.makeText( context, getString(R.string.success), Toast.LENGTH_SHORT) .show(); } }); } catch (TwitterException e) { // something went wrong } } }) .start(); return super.onOptionsItemSelected(item); case R.id.menu_compose_with_search: Intent compose = new Intent(context, ComposeActivity.class); compose.putExtra("user", searchQuery); startActivity(compose); return super.onOptionsItemSelected(item); case R.id.menu_search: // overridePendingTransition(0,0); // finish(); // overridePendingTransition(0,0); // return super.onOptionsItemSelected(item); case R.id.menu_pic_filter: if (!item.isChecked()) { searchQuery += " filter:links twitter.com"; item.setChecked(true); } else { searchQuery = searchQuery.replace("filter:links", "").replace("twitter.com", ""); item.setChecked(false); } Intent broadcast = new Intent("com.klinker.android.twitter.NEW_SEARCH"); broadcast.putExtra("query", searchQuery); context.sendBroadcast(broadcast); return super.onOptionsItemSelected(item); case R.id.menu_remove_rt: if (!item.isChecked()) { searchQuery += " -RT"; item.setChecked(true); } else { searchQuery = searchQuery.replace(" -RT", ""); item.setChecked(false); } broadcast = new Intent("com.klinker.android.twitter.NEW_SEARCH"); broadcast.putExtra("query", searchQuery); context.sendBroadcast(broadcast); return super.onOptionsItemSelected(item); case R.id.menu_show_top_tweets: if (!item.isChecked()) { searchQuery += " TOP"; item.setChecked(true); } else { searchQuery = searchQuery.replace(" TOP", ""); item.setChecked(false); } broadcast = new Intent("com.klinker.android.twitter.NEW_SEARCH"); broadcast.putExtra("query", searchQuery); context.sendBroadcast(broadcast); return super.onOptionsItemSelected(item); default: return super.onOptionsItemSelected(item); } }
@SuppressWarnings("deprecation") @Override public boolean onOptionsItemSelected(MenuItem item) { int itemId = item.getItemId(); if (itemId == R.id.action_find_in_page) { view.showFindDialog(null, false); return true; } if (itemId == R.id.action_bookmark_article) { Application app = (Application) getActivity().getApplication(); if (this.url != null) { if (item.isChecked()) { app.removeBookmark(this.url); displayBookmarked(false); } else { app.addBookmark(this.url); displayBookmarked(true); } } return true; } if (itemId == R.id.action_fullscreen) { ((ArticleCollectionActivity) getActivity()).toggleFullScreen(); return true; } if (itemId == R.id.action_zoom_in) { view.textZoomIn(); return true; } if (itemId == R.id.action_zoom_out) { view.textZoomOut(); return true; } if (itemId == R.id.action_zoom_reset) { view.resetTextZoom(); return true; } if (itemId == R.id.action_load_remote_content) { view.forceLoadRemoteContent = true; view.reload(); return true; } if (itemId == R.id.action_select_style) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); final String[] styleTitles = view.getAvailableStyles(); builder .setTitle(R.string.select_style) .setItems( styleTitles, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { String title = styleTitles[which]; view.saveStylePref(title); view.applyStylePref(); } }); AlertDialog dialog = builder.create(); dialog.show(); return true; } return super.onOptionsItemSelected(item); }