List of usage examples for android.view MenuItem getItemId
public int getItemId();
From source file:net.idlesoft.android.apps.github.activities.Repository.java
@Override public boolean onOptionsItemSelected(final MenuItem item) { switch (item.getItemId()) { case 3:/*from w w w .j a va 2 s . c om*/ try { JSONObject newRepoInfo = null; if (mIsWatching) { final Response unwatchResp = mGapi.repo.unwatch(mRepositoryOwner, mRepositoryName); if (unwatchResp.statusCode == 200) { newRepoInfo = new JSONObject(unwatchResp.resp).getJSONObject("repository"); mIsWatching = false; } } else { final Response watchResp = mGapi.repo.watch(mRepositoryOwner, mRepositoryName); if (watchResp.statusCode == 200) { newRepoInfo = new JSONObject(watchResp.resp).getJSONObject("repository"); mIsWatching = true; } } if (newRepoInfo != null) { final String newWatcherCount = newRepoInfo.getString("watchers"); if (newWatcherCount != mJson.getString("watchers")) { if (newWatcherCount == "1") { ((TextView) findViewById(R.id.tv_repository_info_watchers)) .setText(newWatcherCount + " watcher"); } else { ((TextView) findViewById(R.id.tv_repository_info_watchers)) .setText(newWatcherCount + " watchers"); } } } } catch (final JSONException e) { e.printStackTrace(); } break; case 0: final Intent i1 = new Intent(this, Hubroid.class); startActivity(i1); return true; case 1: mEditor.clear().commit(); final Intent intent = new Intent(this, Hubroid.class); startActivity(intent); return true; case 2: final File root = Environment.getExternalStorageDirectory(); if (root.canWrite()) { final File hubroid = new File(root, "hubroid"); if (!hubroid.exists() && !hubroid.isDirectory()) { return true; } else { hubroid.delete(); return true; } } } return false; }
From source file:com.f16gaming.pathofexilestatistics.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_refresh: refreshList();// w ww . j a va 2s .c o m return true; case R.id.menu_search: rankGoDialog.show(); return true; case R.id.menu_reset: resetList(); return true; case R.id.menu_toggle: toggleList(); return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.thanu.schoolbustracker.RouteActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_legalnotices: String LicenseInfo = GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo(getApplicationContext()); AlertDialog.Builder LicenseDialog = new AlertDialog.Builder(RouteActivity.this); LicenseDialog.setTitle("Legal Notices"); LicenseDialog.setMessage(LicenseInfo); LicenseDialog.show();//w w w . jav a 2s . c o m return true; } return super.onOptionsItemSelected(item); }
From source file:com.odoo.addons.customers.CustomerDetails.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_customer_save: OValues values = mForm.getValues(); if (values != null) { if (newImage != null) { values.put("image_small", newImage); values.put("large_image", newImage); }/*from ww w. jav a 2 s .co m*/ if (record != null) { resPartner.update(record.getInt(OColumn.ROW_ID), values); Toast.makeText(this, R.string.toast_information_saved, Toast.LENGTH_LONG).show(); mEditMode = !mEditMode; setupActionBar(); } else { final int row_id = resPartner.insert(values); if (row_id != OModel.INVALID_ROW_ID) { finish(); } } } break; case R.id.menu_customer_cancel: if (record == null) { finish(); return true; } case R.id.menu_customer_edit: mEditMode = !mEditMode; setMode(mEditMode); mForm.setEditable(mEditMode); mForm.initForm(record); setCustomerImage(); break; case R.id.menu_customer_share: ShareUtil.shareContact(this, record, true); break; case R.id.menu_customer_import: ShareUtil.shareContact(this, record, false); break; } return super.onOptionsItemSelected(item); }
From source file:com.example.premiereappandroid.BloaActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.refresh_timeline: deleteTimelineRecords();/*ww w .j av a 2 s .c om*/ TimelineSelector ss = new TimelineSelector(App.HOME_TIMELINE_URL_STRING); new GetTimelineTask().execute(ss); return true; default: return false; } }
From source file:de.geeksfactory.opacclient.frontend.AccountEditActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { supportFinishAfterTransition();//w ww.ja v a 2 s . c o m return true; } else if (item.getItemId() == R.id.action_accept) { saveAndCheck(); return true; } else if (item.getItemId() == R.id.action_cancel) { if (getIntent().hasExtra("adding") && getIntent().getBooleanExtra("adding", false)) { delete(); } supportFinishAfterTransition(); return true; } else if (item.getItemId() == R.id.action_delete) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(R.string.account_delete_confirm).setCancelable(true) .setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface d, int id) { d.cancel(); } }).setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface d, int id) { d.dismiss(); delete(); finish(); } }).setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface d) { if (d != null) { d.cancel(); } } }); AlertDialog alert = builder.create(); alert.show(); return true; } return super.onOptionsItemSelected(item); }
From source file:net.olejon.spotcommander.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.main_menu_settings: { Intent intent = new Intent(mContext, SettingsActivity.class); startActivity(intent);/*from w ww . j a va 2s. co m*/ return true; } case R.id.main_menu_make_donation: { Intent intent = new Intent(mContext, DonateActivity.class); startActivity(intent); return true; } case R.id.main_menu_troubleshooting: { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.olejon.net/code/spotcommander/?troubleshooting")); startActivity(intent); return true; } case R.id.main_menu_report_issue: { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.olejon.net/code/spotcommander/?issues")); startActivity(intent); return true; } default: { return super.onOptionsItemSelected(item); } } }
From source file:fr.bde_eseo.eseomega.plans.PlansActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); switch (id) { case android.R.id.home: this.onBackPressed(); return true; case R.id.action_plans_details: Intent i = new Intent(PlansActivity.this, BigPictureActivity.class); startActivity(i);/*w w w.j ava 2 s. c o m*/ return true; } return super.onOptionsItemSelected(item); }
From source file:fr.simon.marquis.secretcodes.ui.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); getSupportActionBar().setTitle(Utils.applyCustomTypeFace(getString(R.string.app_name), this)); setContentView(R.layout.activity_main); mEmptyView = findViewById(R.id.emptyView); mGridView = (GridView) findViewById(R.id.gridView); mGridView.setChoiceMode(GridView.CHOICE_MODE_MULTIPLE_MODAL); mGridView.setAdapter(new SecretCodeAdapter(this, Utils.getSecretCodes(this))); mGridView.setEmptyView(mEmptyView);/*from ww w .j a v a2 s .com*/ mEmptyView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mEmptyView.setEnabled(false); mEmptyView.animate().alpha(0) .setDuration(getResources().getInteger(android.R.integer.config_longAnimTime)); startService(new Intent(MainActivity.this, CrawlerService.class)); } }); mGridView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { String code = ((SecretCode) arg0.getItemAtPosition(arg2)).getCode(); Toast.makeText(MainActivity.this, getString(R.string.execute_code, code), Toast.LENGTH_SHORT) .show(); try { sendBroadcast(new Intent("android.provider.Telephony.SECRET_CODE", Uri.parse("android_secret_code://" + code))); } catch (java.lang.SecurityException se) { Toast.makeText(MainActivity.this, R.string.security_exception, Toast.LENGTH_LONG).show(); } } }); mGridView.setMultiChoiceModeListener(new MultiChoiceModeListener() { @Override public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { ((SecretCodeAdapter) mGridView.getAdapter()).itemCheckedStateChanged(position, checked); mode.setTitle(Html.fromHtml("<b>" + mGridView.getCheckedItemCount() + "</b>")); } @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case R.id.action_delete: ((SecretCodeAdapter) mGridView.getAdapter()).deleteSelection(getApplicationContext()); mode.finish(); return true; case R.id.action_select_all: boolean check = mGridView.getCheckedItemCount() != mGridView.getCount(); for (int i = 0; i < mGridView.getCount(); i++) { mGridView.setItemChecked(i, check); } return true; default: return false; } } @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = mode.getMenuInflater(); if (inflater != null) { inflater.inflate(R.menu.cab, menu); } return true; } @Override public void onDestroyActionMode(ActionMode mode) { ((SecretCodeAdapter) mGridView.getAdapter()).resetSelection(); supportInvalidateOptionsMenu(); } @Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } }); supportInvalidateOptionsMenu(); }