List of usage examples for android.view MenuItem toString
public String toString()
From source file:com.android.music.MediaPlaybackActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { badSymptoms.saveMenu("menu", item.toString()); Intent intent;/*from w w w . ja v a 2s .co m*/ try { switch (item.getItemId()) { case GOTO_START: intent = new Intent(); intent.setClass(this, MusicBrowserActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); finish(); break; case USE_AS_RINGTONE: { // Set the system setting to make this the current ringtone if (mService != null) { MusicUtils.setRingtone(this, mService.getAudioId()); } return true; } case PARTY_SHUFFLE: MusicUtils.togglePartyShuffle(); setShuffleButtonImage(); break; case NEW_PLAYLIST: { intent = new Intent(); intent.setClass(this, CreatePlaylist.class); startActivityForResult(intent, NEW_PLAYLIST); return true; } case PLAYLIST_SELECTED: { long[] list = new long[1]; list[0] = MusicUtils.getCurrentAudioId(); long playlist = item.getIntent().getLongExtra("playlist", 0); MusicUtils.addToPlaylist(this, list, playlist); return true; } case DELETE_ITEM: { if (mService != null) { long[] list = new long[1]; list[0] = MusicUtils.getCurrentAudioId(); Bundle b = new Bundle(); String f; if (android.os.Environment.isExternalStorageRemovable()) { f = getString(R.string.delete_song_desc, mService.getTrackName()); } else { f = getString(R.string.delete_song_desc_nosdcard, mService.getTrackName()); } b.putString("description", f); b.putLongArray("items", list); intent = new Intent(); intent.setClass(this, DeleteItems.class); intent.putExtras(b); startActivityForResult(intent, -1); } return true; } case EFFECTS_PANEL: { Intent i = new Intent(AudioEffect.ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL); i.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, mService.getAudioSessionId()); startActivityForResult(i, EFFECTS_PANEL); return true; } } } catch (RemoteException ex) { } return super.onOptionsItemSelected(item); }
From source file:com.inmobi.ultrapush.AnalyzeActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { Log.i(TAG, item.toString()); switch (item.getItemId()) { case R.id.info: showInstructions();/* www . ja v a 2s.com*/ return true; case R.id.settings: Intent settings = new Intent(getBaseContext(), MyPreferences.class); settings.putExtra(MYPREFERENCES_MSG_SOURCE_ID, audioSourceIDs); settings.putExtra(MYPREFERENCES_MSG_SOURCE_NAME, audioSourceNames); startActivity(settings); return true; case R.id.info_recoder: Intent int_info_rec = new Intent(this, InfoRecActivity.class); startActivity(int_info_rec); return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.dattasmoon.pebble.plugin.IgnorePreference.java
@Override protected void onBindDialogView(View view) { btnAdd = (Button) view.findViewById(R.id.btnAdd); etMatch = (EditText) view.findViewById(R.id.etMatch); chkRawRegex = (CheckBox) view.findViewById(R.id.chkRawRegex); chkCaseInsensitive = (CheckBox) view.findViewById(R.id.chkCaseInsensitive); actvApplications = (AutoCompleteTextView) view.findViewById(R.id.actvApplications); spnApplications = (Spinner) view.findViewById(R.id.spnApplications); spnMode = (Spinner) view.findViewById(R.id.spnMode); lvIgnore = (ListView) view.findViewById(R.id.lvIgnore); lvIgnore.setAdapter(arrayAdapter);// ww w. j av a2s .c om lvIgnore.setEmptyView(view.findViewById(android.R.id.empty)); new LoadAppsTask().execute(); lvIgnore.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() { @Override public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) { AdapterView.AdapterContextMenuInfo contextInfo = (AdapterView.AdapterContextMenuInfo) menuInfo; int position = contextInfo.position; long id = contextInfo.id; // the child view who's info we're viewing (should be equal to v) final View v = contextInfo.targetView; MenuInflater inflater = new MenuInflater(getContext()); inflater.inflate(R.menu.preference_ignore_context, menu); //we have to do this mess because DialogPreference doesn't allow for onMenuItemSelected or onOptionsItemSelected. Bleh menu.findItem(R.id.btnEdit).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { final int arrayPosition = (Integer) v.getTag(); final String text = ((TextView) v.findViewById(R.id.tvItem)).getText().toString(); JSONArray temp = new JSONArray(); for (int i = 0; i < arrayAdapter.getJSONArray().length(); i++) { try { JSONObject ignore = arrayAdapter.getJSONArray().getJSONObject(i); if (i == arrayPosition) { etMatch.setText(ignore.getString("match")); chkRawRegex.setChecked(ignore.getBoolean("raw")); chkCaseInsensitive.setChecked(ignore.optBoolean("insensitive", true)); String app = ignore.getString("app"); if (app == "-1") { actvApplications.setText(getContext().getString(R.string.ignore_any)); } else { actvApplications.setText(app); } boolean exclude = ignore.optBoolean("exclude", true); if (exclude) { spnMode.setSelection(Constants.IgnoreMode.EXCLUDE.ordinal()); } else { spnMode.setSelection(Constants.IgnoreMode.INCLUDE.ordinal()); } continue; } temp.put(ignore); } catch (JSONException e) { e.printStackTrace(); } } arrayAdapter.setJSONArray(temp); arrayAdapter.notifyDataSetChanged(); return true; } }); menu.findItem(R.id.btnDelete).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { AlertDialog.Builder builder = new AlertDialog.Builder(v.getContext()); final int arrayPosition = (Integer) v.getTag(); final String text = ((TextView) v.findViewById(R.id.tvItem)).getText().toString(); builder.setMessage(getContext().getResources().getString(R.string.confirm_delete) + " '" + text + "' ?") .setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { JSONArray temp = new JSONArray(); for (int i = 0; i < arrayAdapter.getJSONArray().length(); i++) { if (i == arrayPosition) { continue; } try { temp.put(arrayAdapter.getJSONArray().getJSONObject(i)); } catch (JSONException e) { e.printStackTrace(); } } arrayAdapter.setJSONArray(temp); arrayAdapter.notifyDataSetChanged(); } }).setNegativeButton(R.string.decline, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // User cancelled the dialog } }); builder.create().show(); return true; } }); } }); btnAdd.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { JSONObject item = new JSONObject(); try { item.put("match", etMatch.getText().toString()); item.put("raw", chkRawRegex.isChecked()); item.put("insensitive", chkCaseInsensitive.isChecked()); if (actvApplications.getText().toString() .equalsIgnoreCase(getContext().getString(R.string.ignore_any))) { item.put("app", "-1"); } else { item.put("app", actvApplications.getText().toString()); } if (spnMode.getSelectedItemPosition() == Constants.IgnoreMode.INCLUDE.ordinal()) { item.put("exclude", false); } else { item.put("exclude", true); } if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, "Item is: " + item.toString()); } arrayAdapter.getJSONArray().put(item); etMatch.setText(""); arrayAdapter.notifyDataSetChanged(); } catch (JSONException e) { e.printStackTrace(); } } }); actvApplications.setText(getContext().getString(R.string.ignore_any)); actvApplications.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { actvApplications.showDropDown(); } }); actvApplications.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { ApplicationInfo pkg = (ApplicationInfo) parent.getItemAtPosition(position); if (pkg == null) { actvApplications.setText(getContext().getString(R.string.ignore_any)); } else { actvApplications.setText(pkg.packageName); } } }); actvApplications.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { actvApplications.showDropDown(); } else { if (actvApplications.getText().length() == 0) { actvApplications.setText(getContext().getString(R.string.ignore_any)); } } } }); super.onBindDialogView(view); }