Java Code Examples for android.widget.AdapterView.AdapterContextMenuInfo

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project aksunai, under directory /src/org/androidnerds/app/aksunai/.

Source file: Aksunai.java

  22 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo i){
  AdapterContextMenuInfo info=(AdapterContextMenuInfo)i;
  if (info.position == 0) {
    return;
  }
  menu.setHeaderTitle(R.string.menu_server_options);
  menu.add(R.string.connect);
  menu.add(R.string.edit);
  menu.add(R.string.remove);
}
 

Example 2

From project and-bible, under directory /AndBible/src/net/bible/android/view/activity/bookmark/.

Source file: BookmarkLabels.java

  22 
vote

@Override public boolean onContextItemSelected(MenuItem item){
  super.onContextItemSelected(item);
  AdapterContextMenuInfo menuInfo=(AdapterContextMenuInfo)item.getMenuInfo();
  LabelDto label=labels.get(menuInfo.position);
  if (bookmark != null) {
switch (item.getItemId()) {
case (R.id.delete):
      delete(label);
    return true;
}
}
return false;
}
 

Example 3

From project android-joedayz, under directory /Proyectos/TareasSQLite/src/com/androideity/tareasqlite/.

Source file: TareasSQLiteActivity.java

  22 
vote

@Override public boolean onContextItemSelected(MenuItem item){
switch (item.getItemId()) {
case DELETE_ID:
    AdapterContextMenuInfo info=(AdapterContextMenuInfo)item.getMenuInfo();
  dbHelper.deleteTodo(info.id);
fillData();
return true;
}
return super.onContextItemSelected(item);
}
 

Example 4

From project android-rackspacecloud, under directory /src/com/rackspacecloud/android/.

Source file: ListAccountsActivity.java

  22 
vote

public boolean onContextItemSelected(MenuItem item){
  if (accounts.size() == 0) {
    displayNoAccountsCell();
    return true;
  }
 else {
    AdapterContextMenuInfo info=(AdapterContextMenuInfo)item.getMenuInfo();
    accounts.remove(info.position);
    writeAccounts();
    loadAccounts();
    return true;
  }
}
 

Example 5

From project androidTileMapEditor_1, under directory /src/it/sineo/android/tileMapEditor/.

Source file: HomeActivity.java

  22 
vote

@Override public boolean onContextItemSelected(MenuItem item){
switch (item.getItemId()) {
case R.id.home_ctx_menu_delete:
{
      AdapterContextMenuInfo cmi=(AdapterContextMenuInfo)item.getMenuInfo();
      Uri mapUri=Uri.withAppendedPath(C.CONTENT_URI,Long.toString(cmi.id));
      getContentResolver().delete(mapUri,null,null);
      return true;
    }
default :
  return super.onContextItemSelected(item);
}
}
 

Example 6

From project androidtracks, under directory /src/org/sfcta/cycletracks/.

Source file: MainInput.java

  22 
vote

@Override public boolean onContextItemSelected(MenuItem item){
  AdapterContextMenuInfo info=(AdapterContextMenuInfo)item.getMenuInfo();
switch (item.getItemId()) {
case CONTEXT_RETRY:
    retryTripUpload(info.id);
  return true;
case CONTEXT_DELETE:
deleteTrip(info.id);
return true;
default :
return super.onContextItemSelected(item);
}
}
 

Example 7

From project android_aosp_packages_apps_Settings, under directory /src/com/android/settings/bluetooth/.

Source file: BluetoothSettings.java

  22 
vote

private CachedBluetoothDevice getDeviceFromMenuInfo(ContextMenuInfo menuInfo){
  if ((menuInfo == null) || !(menuInfo instanceof AdapterContextMenuInfo)) {
    return null;
  }
  AdapterContextMenuInfo adapterMenuInfo=(AdapterContextMenuInfo)menuInfo;
  Preference pref=(Preference)getPreferenceScreen().getRootAdapter().getItem(adapterMenuInfo.position);
  if (pref == null || !(pref instanceof BluetoothDevicePreference)) {
    return null;
  }
  return ((BluetoothDevicePreference)pref).getCachedDevice();
}
 

Example 8

From project BF3-Battlelog, under directory /src/com/ninetwozero/battlelog/activity/feed/.

Source file: FeedFragment.java

  22 
vote

public void createContextMenu(ContextMenu menu,View view,ContextMenuInfo menuInfo){
  AdapterContextMenuInfo info=(AdapterContextMenuInfo)menuInfo;
  FeedItem feedItem=(FeedItem)info.targetView.getTag();
  menu.add(Constants.MENU_ID_FEED,CONTEXT_ID_HOOAH,0,feedItem.isLiked() ? R.string.label_unhooah : R.string.label_hooah);
  if (feedItem.getNumLikes() > 0) {
    menu.add(Constants.MENU_ID_FEED,CONTEXT_ID_VIEW_HOOAH,0,"View hooahs");
  }
  menu.add(Constants.MENU_ID_FEED,CONTEXT_ID_SINGLE,0,R.string.label_single_post_view);
}
 

Example 9

From project Book-Catalogue, under directory /src/com/eleybourn/bookcatalogue/.

Source file: BookEditAnthology.java

  22 
vote

@Override public boolean onContextItemSelected(MenuItem item){
switch (item.getItemId()) {
case DELETE_ID:
    AdapterContextMenuInfo info=(AdapterContextMenuInfo)item.getMenuInfo();
  mDbHelper.deleteAnthologyTitle(info.id);
fillAnthology();
return true;
}
return super.onContextItemSelected(item);
}
 

Example 10

From project cmsandroid, under directory /src/com/zia/freshdocs/activity/.

Source file: NodeBrowseActivity.java

  22 
vote

@Override public boolean onContextItemSelected(MenuItem item){
  AdapterContextMenuInfo info=(AdapterContextMenuInfo)item.getMenuInfo();
switch (item.getItemId()) {
case R.id.menu_item_send:
    _adapter.shareContent(info.position);
  return true;
case R.id.menu_item_favorite:
_adapter.toggleFavorite(info.position);
return true;
}
return false;
}
 

Example 11

From project Diktofon, under directory /app/src/kaljurand_at_gmail_dot_com/diktofon/activity/.

Source file: RecordingListActivity.java

  22 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  super.onCreateContextMenu(menu,v,menuInfo);
  MenuInflater inflater=getMenuInflater();
  inflater.inflate(R.menu.cm_notes,menu);
  final AdapterContextMenuInfo info=(AdapterContextMenuInfo)menuInfo;
  final Recording note=(Recording)mListView.getItemAtPosition(info.position);
  if (!note.needsTrans()) {
    MenuItem menuItem=menu.findItem(R.id.cm_notes_transcribe);
    menuItem.setEnabled(false);
  }
}
 

Example 12

From project dmix, under directory /MPDroid/src/com/namelessdev/mpdroid/.

Source file: BrowseActivity.java

  22 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenu.ContextMenuInfo menuInfo){
  AdapterContextMenuInfo info=(AdapterContextMenuInfo)menuInfo;
  menu.setHeaderTitle(items.get((int)info.id).mainText());
  android.view.MenuItem addItem=menu.add(ContextMenu.NONE,ADD,0,getResources().getString(irAdd));
  addItem.setOnMenuItemClickListener(this);
  android.view.MenuItem addAndReplaceItem=menu.add(ContextMenu.NONE,ADDNREPLACE,0,R.string.addAndReplace);
  addAndReplaceItem.setOnMenuItemClickListener(this);
  android.view.MenuItem addAndPlayItem=menu.add(ContextMenu.NONE,ADDNPLAY,0,R.string.addAndPlay);
  addAndPlayItem.setOnMenuItemClickListener(this);
}
 

Example 13

From project Gibberbot, under directory /src/info/guardianproject/otr/app/im/app/.

Source file: NewChatActivity.java

  22 
vote

/** 
 * Show the context menu on a history item. 
 */
@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  AdapterContextMenuInfo info=(AdapterView.AdapterContextMenuInfo)menuInfo;
  mContextMenuHandler.mPosition=info.position;
  Cursor cursor=mChatView.getMessageAtPosition(info.position);
  int type=cursor.getInt(cursor.getColumnIndexOrThrow(Imps.Messages.TYPE));
  if (type == Imps.MessageType.OUTGOING) {
    menu.add(0,MENU_RESEND,0,R.string.menu_resend).setOnMenuItemClickListener(mContextMenuHandler);
  }
}
 

Example 14

From project HabReader, under directory /src/net/meiolania/apps/habrahabr/fragments/posts/.

Source file: PostsCommentsFragment.java

  22 
vote

@Override public boolean onContextItemSelected(MenuItem item){
  AdapterContextMenuInfo adapterContextMenuInfo=(AdapterContextMenuInfo)item.getMenuInfo();
  CommentsData commentsData=(CommentsData)getListAdapter().getItem(adapterContextMenuInfo.position);
switch (item.getItemId()) {
case MENU_OPEN_COMMENT_IN_BROWSER:
    startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse(commentsData.getUrl())));
  break;
case MENU_OPEN_AUTHOR_PROFILE:
startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse(commentsData.getAuthorUrl())));
break;
}
return super.onContextItemSelected(item);
}
 

Example 15

From project javaee-tutorial, under directory /jaxrs/android/src/org/jboss/ee/tutorial/jaxrs/android/.

Source file: LibraryListActivity.java

  22 
vote

@Override public boolean onContextItemSelected(MenuItem item){
switch (item.getItemId()) {
case R.id.menu_delete:
    AdapterContextMenuInfo info=(AdapterContextMenuInfo)item.getMenuInfo();
  LibraryClient library=getLibrary();
Book book=library.getBooks().get((int)info.id);
library.removeBook(book.getIsbn());
fillData();
return true;
}
return super.onContextItemSelected(item);
}
 

Example 16

From project k-9, under directory /src/com/fsck/k9/activity/.

Source file: FolderList.java

  22 
vote

@Override public boolean onContextItemSelected(android.view.MenuItem item){
  AdapterContextMenuInfo info=(AdapterContextMenuInfo)item.getMenuInfo();
  FolderInfoHolder folder=(FolderInfoHolder)mAdapter.getItem(info.position);
switch (item.getItemId()) {
case R.id.clear_local_folder:
    onClearFolder(mAccount,folder.name);
  break;
}
return super.onContextItemSelected(item);
}
 

Example 17

From project keepassdroid, under directory /src/com/keepassdroid/fileselect/.

Source file: FileSelectActivity.java

  22 
vote

@Override public boolean onContextItemSelected(MenuItem item){
  super.onContextItemSelected(item);
  if (item.getItemId() == CMENU_CLEAR) {
    AdapterContextMenuInfo acmi=(AdapterContextMenuInfo)item.getMenuInfo();
    TextView tv=(TextView)acmi.targetView;
    String filename=tv.getText().toString();
    mDbHelper.deleteFile(filename);
    refreshList();
    return true;
  }
  return false;
}
 

Example 18

From project liquidroid, under directory /src/liqui/droid/activity/.

Source file: Accounts.java

  22 
vote

@Override public boolean onContextItemSelected(MenuItem item){
switch (item.getItemId()) {
case SYNC_STAT_ID:
    AdapterContextMenuInfo info=(AdapterContextMenuInfo)item.getMenuInfo();
  Intent intent=new Intent().setClass(Accounts.this,SyncStatListCached.class);
intent.putExtra("ACCOUNT",mAdapter.getItem(info.position));
startActivityForResult(intent,ACTIVITY_SHOW_STATS);
return true;
}
return super.onContextItemSelected(item);
}
 

Example 19

From project LoL-Chat, under directory /src/com/rei/lolchat/ui/.

Source file: ContactList.java

  22 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenu.ContextMenuInfo menuInfo){
  super.onCreateContextMenu(menu,v,menuInfo);
  MenuInflater inflater=getMenuInflater();
  inflater.inflate(R.menu.contactlist_context,menu);
  AdapterContextMenuInfo info=(AdapterView.AdapterContextMenuInfo)menuInfo;
  Contact c=mListContact.get(info.position);
  try {
    mSelectedContact=mRoster.getContact(c.getJID());
  }
 catch (  RemoteException e) {
    e.printStackTrace();
  }
  menu.setHeaderTitle(mSelectedContact.getName());
}
 

Example 20

From project motelib, under directory /src/com/cafbit/motelib/settings/.

Source file: DevicesActivity.java

  22 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  super.onCreateContextMenu(menu,v,menuInfo);
  if ((v.equals(getListView())) && (menuInfo instanceof AdapterContextMenuInfo)) {
    AdapterContextMenuInfo acmu=(AdapterContextMenuInfo)menuInfo;
    if (acmu.id != -1) {
      onDeviceCreateContextMenu((Device)adapter.getItem((int)acmu.id),menu);
    }
  }
}
 

Example 21

From project mp3tunes-android, under directory /src/com/mp3tunes/android/activity/.

Source file: AlbumBrowser.java

  22 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View view,ContextMenuInfo menuInfoIn){
  menu.add(0,QUEUE,0,R.string.menu_play_selection);
  menu.add(0,PLAY_SELECTION,0,R.string.menu_play_selection);
  menu.add(0,SEARCH,0,R.string.search);
  AdapterContextMenuInfo mi=(AdapterContextMenuInfo)menuInfoIn;
  mAlbumCursor.moveToPosition(mi.position);
  mCurrentAlbumId=mAlbumCursor.getString(mAlbumCursor.getColumnIndexOrThrow(MediaStore.Audio.Albums._ID));
  mCurrentAlbumName=mAlbumCursor.getString(mAlbumCursor.getColumnIndexOrThrow(MediaStore.Audio.Albums.ALBUM));
  menu.setHeaderTitle(mCurrentAlbumName);
}
 

Example 22

From project MyExpenses, under directory /src/org/totschnig/myexpenses/.

Source file: ManageAccounts.java

  22 
vote

@Override public boolean onContextItemSelected(MenuItem item){
  AdapterContextMenuInfo info=(AdapterContextMenuInfo)item.getMenuInfo();
switch (item.getItemId()) {
case DELETE_ID:
    mContextAccountId=info.id;
  showDialog(DELETE_DIALOG_ID);
return true;
}
return super.onContextItemSelected(item);
}
 

Example 23

From project onebusaway-android, under directory /src/com/joulespersecond/seattlebusbot/.

Source file: MyRecentRoutesFragment.java

  22 
vote

@Override public boolean onContextItemSelected(android.view.MenuItem item){
  AdapterContextMenuInfo info=(AdapterContextMenuInfo)item.getMenuInfo();
switch (item.getItemId()) {
case CONTEXT_MENU_DELETE:
    ObaContract.Routes.markAsUnused(getActivity(),Uri.withAppendedPath(ObaContract.Routes.CONTENT_URI,QueryUtils.RouteList.getId(getListView(),info.position)));
  return true;
default :
return super.onContextItemSelected(item);
}
}
 

Example 24

From project packages_apps_BlackICEControl, under directory /src/com/blackice/control/.

Source file: ControlActivity.java

  22 
vote

@Override public boolean onOptionsItemSelected(MenuItem item){
  AdapterContextMenuInfo info=(AdapterContextMenuInfo)item.getMenuInfo();
switch (item.getItemId()) {
case R.id.change_locale:
    Log.e(TAG,"change_locale clicked");
  SharedPreferences p=getPreferences(MODE_PRIVATE);
boolean useEnglishLocale=p.getBoolean(KEY_USE_ENGLISH_LOCALE,false);
p.edit().putBoolean(KEY_USE_ENGLISH_LOCALE,!useEnglishLocale).apply();
recreate();
return true;
default :
return super.onContextItemSelected(item);
}
}
 

Example 25

From project packages_apps_ROMControl, under directory /src/com/aokp/romcontrol/fragments/.

Source file: Lockscreens.java

  22 
vote

@Override public boolean onOptionsItemSelected(MenuItem item){
  AdapterContextMenuInfo info=(AdapterContextMenuInfo)item.getMenuInfo();
switch (item.getItemId()) {
case R.id.remove_wallpaper:
    File f=new File(mContext.getFilesDir(),WALLPAPER_NAME);
  Log.e(TAG,mContext.deleteFile(WALLPAPER_NAME) + "");
Log.e(TAG,mContext.deleteFile(WALLPAPER_NAME) + "");
return true;
default :
return super.onContextItemSelected(item);
}
}
 

Example 26

From project platform_packages_apps_browser, under directory /src/com/android/browser/.

Source file: BrowserSnapshotPage.java

  22 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  MenuInflater inflater=getActivity().getMenuInflater();
  inflater.inflate(R.menu.snapshots_context,menu);
  BookmarkItem header=new BookmarkItem(getActivity());
  header.setEnableScrolling(true);
  AdapterContextMenuInfo info=(AdapterContextMenuInfo)menuInfo;
  populateBookmarkItem(mAdapter.getItem(info.position),header);
  menu.setHeaderView(header);
}
 

Example 27

From project ratebeer-for-Android, under directory /RateBeerForAndroid/src/com/ratebeer/android/gui/fragments/.

Source file: OfflineRatingsFragment.java

  22 
vote

@Override public boolean onContextItemSelected(android.view.MenuItem item){
  AdapterContextMenuInfo acmi=(AdapterContextMenuInfo)item.getMenuInfo();
  final OfflineRating rating=(OfflineRating)ratingsView.getItemAtPosition(acmi.position);
  new ConfirmDialogFragment(new OnDialogResult(){
    @Override public void onConfirmed(){
      deleteRating(rating);
      loadRatings();
    }
  }
,R.string.rate_offline_confirmdelete,rating.getBeerName()).show(getSupportFragmentManager(),"dialog");
  return super.onContextItemSelected(item);
}
 

Example 28

From project ratebeerforandroid, under directory /RateBeerForAndroid/src/com/ratebeer/android/gui/fragments/.

Source file: OfflineRatingsFragment.java

  22 
vote

@Override public boolean onContextItemSelected(android.view.MenuItem item){
  AdapterContextMenuInfo acmi=(AdapterContextMenuInfo)item.getMenuInfo();
  final OfflineRating rating=(OfflineRating)ratingsView.getItemAtPosition(acmi.position);
  new ConfirmDialogFragment(new OnDialogResult(){
    @Override public void onConfirmed(){
      deleteRating(rating);
      loadRatings();
    }
  }
,R.string.rate_offline_confirmdelete,rating.getBeerName()).show(getSupportFragmentManager(),"dialog");
  return super.onContextItemSelected(item);
}
 

Example 29

From project reddit-is-fun, under directory /src/com/andrewshu/android/reddit/user/.

Source file: ProfileActivity.java

  22 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  super.onCreateContextMenu(menu,v,menuInfo);
  AdapterContextMenuInfo info=(AdapterContextMenuInfo)menuInfo;
  int rowId=(int)info.id;
  ThingInfo item=mThingsAdapter.getItem(rowId);
  mVoteTargetThingInfo=item;
  mVoteTargetView=v;
  if (item.getName().startsWith(Constants.THREAD_KIND)) {
    menu.add(0,Constants.DIALOG_THREAD_CLICK,Menu.NONE,"Go to thread");
  }
 else {
    menu.add(0,Constants.DIALOG_COMMENT_CLICK,Menu.NONE,"Go to comment");
  }
}
 

Example 30

From project rozkladpkp-android, under directory /src/org/tyszecki/rozkladpkp/.

Source file: RememberedFragment.java

  22 
vote

public boolean onContextItemSelected(MenuItem item){
  AdapterContextMenuInfo info=(AdapterContextMenuInfo)item.getMenuInfo();
  if (item.getItemId() == R.id.item_delete) {
    adapter.deleteItem(info.position);
    return true;
  }
 else   return super.onContextItemSelected(item);
}
 

Example 31

From project saldo, under directory /src/com/adrup/saldo/.

Source file: BankListActivity.java

  22 
vote

@Override public boolean onContextItemSelected(MenuItem item){
switch (item.getItemId()) {
case DELETE_ID:
    AdapterContextMenuInfo info=(AdapterContextMenuInfo)item.getMenuInfo();
  mDbAdapter.deleteBankLogin(info.id);
fillData();
return true;
}
return super.onContextItemSelected(item);
}
 

Example 32

From project SeriesGuide, under directory /SeriesGuide/src/com/battlelancer/seriesguide/ui/.

Source file: EpisodesFragment.java

  22 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  super.onCreateContextMenu(menu,v,menuInfo);
  AdapterContextMenuInfo info=(AdapterContextMenuInfo)menuInfo;
  WatchedBox watchedBox=(WatchedBox)info.targetView.findViewById(R.id.CustomCheckBoxWatched);
  if (watchedBox.isChecked()) {
    menu.add(0,CONTEXT_FLAG_UNWATCHED_ID,1,R.string.unmark_episode);
  }
 else {
    menu.add(0,CONTEXT_FLAG_WATCHED_ID,0,R.string.mark_episode);
  }
  menu.add(0,CONTEXT_FLAG_UNTILHERE_ID,2,R.string.mark_untilhere);
  menu.add(0,CONTEXT_MANAGE_LISTS_ID,3,R.string.list_item_manage);
  menu.add(0,CONTEXT_DELETE_EPISODE_ID,4,R.string.delete_show);
}
 

Example 33

From project shoppinglist, under directory /ShoppingList/src/org/openintents/shopping/ui/.

Source file: ItemStoresActivity.java

  22 
vote

public boolean onContextItemSelected(MenuItem item){
  AdapterContextMenuInfo menuInfo=(AdapterView.AdapterContextMenuInfo)item.getMenuInfo();
  mSelectedStorePosition=menuInfo.position;
switch (item.getItemId()) {
case MENU_RENAME_STORE:
    showDialog(DIALOG_RENAME_STORE);
  break;
case MENU_DELETE_STORE:
deleteStoreConfirm();
break;
}
return true;
}
 

Example 34

From project sls, under directory /src/com/adam/aslfms/.

Source file: ViewScrobbleCacheActivity.java

  22 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  AdapterContextMenuInfo info=(AdapterContextMenuInfo)menuInfo;
  if (info.id < 0)   return;
  MenuInflater inflater=getMenuInflater();
  inflater.inflate(R.menu.view_scrobble_cache_context,menu);
}
 

Example 35

From project Something-Awful-Android, under directory /application/src/com/ferg/awfulapp/.

Source file: ForumDisplayFragment.java

  22 
vote

@Override public void onCreateContextMenu(ContextMenu aMenu,View aView,ContextMenuInfo aMenuInfo){
  super.onCreateContextMenu(aMenu,aView,aMenuInfo);
  if (aMenuInfo instanceof AdapterContextMenuInfo) {
    android.view.MenuInflater inflater=getActivity().getMenuInflater();
    AdapterContextMenuInfo info=(AdapterContextMenuInfo)aMenuInfo;
    Cursor row=mCursorAdapter.getRow(info.id);
    if (row.getColumnIndex(AwfulThread.BOOKMARKED) > -1) {
      inflater.inflate(R.menu.thread_longpress,aMenu);
    }
  }
}
 

Example 36

From project SqueezeControl, under directory /src/com/squeezecontrol/.

Source file: AbstractMusicBrowserActivity.java

  22 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  super.onCreateContextMenu(menu,v,menuInfo);
  AdapterContextMenuInfo mi=(AdapterContextMenuInfo)menuInfo;
  mCurrentPosition=mi.position;
  LayoutInflater mInflater=getLayoutInflater();
  View hview=mInflater.inflate(R.layout.context_header,null);
  TextView firstLine=(TextView)hview.findViewById(R.id.first_line);
  firstLine.setText(getSelectedItem().getName());
  menu.setHeaderView(hview);
  menu.add(0,PLAY_CTX_MENU_ITEM,0,"Play now");
  menu.add(0,ADD_TO_PLAYLIST_CTX_MENU_ITEM,1,"Add to playlist");
  addContextMenuItems(menu);
}
 

Example 37

From project Android-File-Manager, under directory /src/com/nexes/manager/.

Source file: Main.java

  21 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo info){
  super.onCreateContextMenu(menu,v,info);
  boolean multi_data=mHandler.hasMultiSelectData();
  AdapterContextMenuInfo _info=(AdapterContextMenuInfo)info;
  mSelectedListItem=mHandler.getData(_info.position);
  if (mFileMag.isDirectory(mSelectedListItem) && !mHandler.isMultiSelected()) {
    menu.setHeaderTitle("Folder operations");
    menu.add(0,D_MENU_DELETE,0,"Delete Folder");
    menu.add(0,D_MENU_RENAME,0,"Rename Folder");
    menu.add(0,D_MENU_COPY,0,"Copy Folder");
    menu.add(0,D_MENU_MOVE,0,"Move(Cut) Folder");
    menu.add(0,D_MENU_ZIP,0,"Zip Folder");
    menu.add(0,D_MENU_PASTE,0,"Paste into folder").setEnabled(mHoldingFile || multi_data);
    menu.add(0,D_MENU_UNZIP,0,"Extract here").setEnabled(mHoldingZip);
  }
 else   if (!mFileMag.isDirectory(mSelectedListItem) && !mHandler.isMultiSelected()) {
    menu.setHeaderTitle("File Operations");
    menu.add(0,F_MENU_DELETE,0,"Delete File");
    menu.add(0,F_MENU_RENAME,0,"Rename File");
    menu.add(0,F_MENU_COPY,0,"Copy File");
    menu.add(0,F_MENU_MOVE,0,"Move(Cut) File");
    menu.add(0,F_MENU_ATTACH,0,"Email File");
  }
}
 

Example 38

From project Android-Flashcards, under directory /src/com/secretsockssoftware/androidflashcards/.

Source file: AndroidFlashcards.java

  21 
vote

@Override public boolean onContextItemSelected(MenuItem item){
switch (item.getItemId()) {
case DELETE_ID:
    AdapterContextMenuInfo info=(AdapterContextMenuInfo)item.getMenuInfo();
  final LessonListItem lesson_item=lessons[(int)info.id];
AlertDialog alertDialog=new AlertDialog.Builder(me).create();
alertDialog.setTitle("Confirm Delete");
if (lesson_item.isDir) alertDialog.setMessage("Are you sure you want to delete:\n" + lesson_item.name + "\n\nAll lessons in the directory will be deleted");
 else alertDialog.setMessage("Are you sure you want to delete the lesson:\n" + lesson_item.name);
alertDialog.setButton(DialogInterface.BUTTON_POSITIVE,"OK",new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog,int which){
File f=new File(lesson_item.file);
if (lesson_item.isDir) {
deleteDir(f);
}
 else {
if (f.exists()) f.delete();
f=new File(lesson_item.source);
if (f.exists()) f.delete();
}
parseLessons();
}
}
);
alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE,"Cancel",new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog,int which){
}
}
);
alertDialog.show();
return true;
}
return super.onContextItemSelected(item);
}
 

Example 39

From project android_packages_apps_Gallery, under directory /src/com/android/camera/.

Source file: GalleryPicker.java

  21 
vote

private boolean onSlideShowClicked(ContextMenuInfo menuInfo){
  AdapterContextMenuInfo info=(AdapterContextMenuInfo)menuInfo;
  int position=info.position;
  if (position < 0 || position >= mAdapter.mItems.size()) {
    return true;
  }
  Item item=mAdapter.mItems.get(position);
  Uri targetUri=item.mFirstImageUri;
  if (targetUri != null && item.mBucketId != null) {
    targetUri=targetUri.buildUpon().appendQueryParameter("bucketId",item.mBucketId).build();
  }
  Intent intent=new Intent(Intent.ACTION_VIEW,targetUri);
  intent.putExtra("slideshow",true);
  startActivity(intent);
  return true;
}
 

Example 40

From project BombusLime, under directory /src/org/bombusim/lime/fragments/.

Source file: ChatFragment.java

  21 
vote

@Override public boolean onContextItemSelected(MenuItem item){
  AdapterContextMenuInfo info=(AdapterContextMenuInfo)item.getMenuInfo();
switch (item.getItemId()) {
case R.id.cmdCopy:
    try {
      String s=((MessageView)(info.targetView)).toString();
      ClipboardManager clipboard=(ClipboardManager)getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
      clipboard.setText(s);
    }
 catch (    Exception e) {
    }
  return true;
case R.id.cmdDelete:
chatListView.setVisibility(View.GONE);
mChat.removeFromHistory(info.id);
refreshVisualContent();
return true;
default :
return super.onContextItemSelected(item);
}
}
 

Example 41

From project Cura, under directory /src/com/cura/.

Source file: FavoriteCommands.java

  21 
vote

@Override public boolean onContextItemSelected(MenuItem item){
  AdapterContextMenuInfo info=(AdapterContextMenuInfo)item.getMenuInfo();
  String command=favoriteCommands[info.position];
  dbHelper=new DbHelper(FavoriteCommands.this);
  db=dbHelper.getWritableDatabase();
switch (item.getItemId()) {
case Menu.FIRST + 1:
    try {
      String where="command = ?";
      String[] whereArgs={command};
      db.delete(DbHelper.commandTableName,where,whereArgs);
      startActivity(getIntent());
      finish();
    }
 catch (    Exception e) {
      Log.d("SQL",e.toString());
    }
  return true;
}
return super.onOptionsItemSelected(item);
}
 

Example 42

From project daily-money, under directory /dailymoney/src/com/bottleworks/dailymoney/ui/.

Source file: AccountDetailListActivity.java

  21 
vote

@Override public boolean onContextItemSelected(MenuItem item){
  AdapterContextMenuInfo info=(AdapterContextMenuInfo)item.getMenuInfo();
  if (item.getItemId() == R.id.accdetlist_menu_edit) {
    detailListHelper.doEditDetail(info.position);
    return true;
  }
 else   if (item.getItemId() == R.id.accdetlist_menu_delete) {
    detailListHelper.doDeleteDetail(info.position);
    return true;
  }
 else   if (item.getItemId() == R.id.accdetlist_menu_copy) {
    detailListHelper.doCopyDetail(info.position);
    return true;
  }
  return super.onContextItemSelected(item);
}
 

Example 43

From project DiscogsForAndroid, under directory /src/com/discogs/activities/.

Source file: WantlistActivity.java

  21 
vote

@Override public boolean onContextItemSelected(MenuItem item){
  AdapterContextMenuInfo info=(AdapterContextMenuInfo)item.getMenuInfo();
  Want want=(Want)getListAdapter().getItem(info.position);
switch (item.getItemId()) {
case R.id.delete:
{
      deleteWant(want.getId());
      deleteWantFromList(info.position);
      return true;
    }
default :
{
    return super.onContextItemSelected(item);
  }
}
}
 

Example 44

From project ElectricSleep, under directory /src/com/androsz/electricsleepbeta/alarmclock/.

Source file: AlarmClock.java

  21 
vote

@Override public boolean onContextItemSelected(final MenuItem item){
  final AdapterContextMenuInfo info=(AdapterContextMenuInfo)item.getMenuInfo();
  final int id=(int)info.id;
switch (item.getItemId()) {
case R.id.delete_alarm:
    new AlertDialog.Builder(this).setTitle(getString(R.string.delete_alarm)).setMessage(getString(R.string.delete_alarm_confirm)).setPositiveButton(android.R.string.ok,new DialogInterface.OnClickListener(){
      @Override public void onClick(      final DialogInterface d,      final int w){
        Alarms.deleteAlarm(AlarmClock.this,id);
      }
    }
).setNegativeButton(android.R.string.cancel,null).show();
  return true;
case R.id.enable_alarm:
final Cursor c=(Cursor)mAlarmsList.getAdapter().getItem(info.position);
final Alarm alarm=new Alarm(c);
Alarms.enableAlarm(this,alarm.id,!alarm.enabled);
if (!alarm.enabled) {
SetAlarm.popAlarmSetToast(this,alarm.hour,alarm.minutes,alarm.daysOfWeek);
}
return true;
case R.id.edit_alarm:
final Intent intent=new Intent(this,SetAlarm.class);
intent.putExtra(Alarms.ALARM_ID,id);
startActivity(intent);
return true;
default :
break;
}
return super.onContextItemSelected(item);
}
 

Example 45

From project fanfoudroid, under directory /src/com/ch_linghu/fanfoudroid/.

Source file: DmActivity.java

  21 
vote

@Override public boolean onContextItemSelected(MenuItem item){
  AdapterContextMenuInfo info=(AdapterContextMenuInfo)item.getMenuInfo();
  Cursor cursor=(Cursor)mAdapter.getItem(info.position);
  if (cursor == null) {
    Log.w(TAG,"Selected item not available.");
    return super.onContextItemSelected(item);
  }
switch (item.getItemId()) {
case CONTEXT_REPLY_ID:
    String user_id=cursor.getString(cursor.getColumnIndexOrThrow(MessageTable.FIELD_USER_ID));
  Intent intent=WriteDmActivity.createIntent(user_id);
startActivity(intent);
return true;
case CONTEXT_DELETE_ID:
int idIndex=cursor.getColumnIndexOrThrow(MessageTable._ID);
String id=cursor.getString(idIndex);
doDestroy(id);
return true;
default :
return super.onContextItemSelected(item);
}
}
 

Example 46

From project FileExplorer, under directory /src/net/micode/fileexplorer/.

Source file: FavoriteList.java

  21 
vote

@Override public boolean onMenuItemClick(MenuItem item){
  int itemId=item.getItemId();
  AdapterContextMenuInfo info=(AdapterContextMenuInfo)item.getMenuInfo();
  int position=info != null ? info.position : -1;
switch (itemId) {
case MENU_UNFAVORITE:
    if (position != -1) {
      deleteFavorite(position);
    }
  break;
default :
return false;
}
return true;
}
 

Example 47

From project groundhog-reader, under directory /src/main/java/com/almarsoft/GroundhogReader/.

Source file: GroupListActivity.java

  21 
vote

@Override public boolean onContextItemSelected(MenuItem item){
  AdapterContextMenuInfo info=(AdapterContextMenuInfo)item.getMenuInfo();
  final String groupname=mGroupsArray[info.position];
  int order=item.getOrder();
  if (order == MENU_ITEM_MARKALLREAD) {
    String msg=getString(R.string.mark_read_question);
    msg=java.text.MessageFormat.format(msg,groupname);
    new AlertDialog.Builder(GroupListActivity.this).setTitle(getString(R.string.mark_all_read)).setMessage(msg).setPositiveButton(getString(R.string.yes),new DialogInterface.OnClickListener(){
      public void onClick(      DialogInterface dlg,      int sumthin){
        markAllRead(groupname);
      }
    }
).setNegativeButton(getString(R.string.no),null).show();
    return true;
  }
 else   if (order == MENU_ITEM_UNSUBSCRIBE) {
    String msg=getString(R.string.unsubscribe_question);
    msg=java.text.MessageFormat.format(msg,groupname);
    new AlertDialog.Builder(GroupListActivity.this).setTitle(getString(R.string.unsubscribe)).setMessage(msg).setPositiveButton(getString(R.string.yes),new DialogInterface.OnClickListener(){
      public void onClick(      DialogInterface dlg,      int sumthin){
        unsubscribe(groupname);
      }
    }
).setNegativeButton(getString(R.string.no),null).show();
    return true;
  }
 else   if (order == MENU_ITEM_CATCHUP) {
    String[] groupArr=new String[1];
    groupArr[0]=groupname;
    catchupGroups(groupArr);
  }
  return false;
}
 

Example 48

From project jamendo-android, under directory /src/com/teleca/jamendo/activity/.

Source file: DownloadActivity.java

  21 
vote

@Override public boolean onContextItemSelected(MenuItem item){
  AdapterContextMenuInfo info=(AdapterContextMenuInfo)item.getMenuInfo();
switch (item.getItemId()) {
case R.id.add_to_playlist:
    addToPlaylist(getJob(info.position));
  return true;
case R.id.play_download:
playNow(info.position);
return true;
case R.id.delete_download:
deleteJob(getJob(info.position));
return true;
default :
return super.onContextItemSelected(item);
}
}
 

Example 49

From project K6nele, under directory /app/src/ee/ioc/phon/android/speak/.

Source file: AppListActivity.java

  21 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  super.onCreateContextMenu(menu,v,menuInfo);
  MenuInflater inflater=getMenuInflater();
  inflater.inflate(R.menu.cm_app,menu);
  final AdapterContextMenuInfo info=(AdapterContextMenuInfo)menuInfo;
  Cursor c=(Cursor)getListView().getItemAtPosition(info.position);
  long grammarId=c.getLong(c.getColumnIndex(App.Columns.GRAMMAR));
  long serverId=c.getLong(c.getColumnIndex(App.Columns.SERVER));
  if (grammarId == 0) {
    menu.findItem(R.id.cmAppRemoveGrammar).setEnabled(false);
  }
  if (serverId == 0) {
    menu.findItem(R.id.cmAppRemoveServer).setEnabled(false);
  }
}
 

Example 50

From project MobiPerf, under directory /android/src/com/mobiperf/speedometer/.

Source file: MeasurementScheduleConsoleActivity.java

  21 
vote

/** 
 * Handles the deletion of the measurement tasks when the user clicks the context menu
 */
@Override public boolean onContextItemSelected(MenuItem item){
  AdapterContextMenuInfo info=(AdapterContextMenuInfo)item.getMenuInfo();
switch (item.getItemId()) {
case R.id.ctxMenuDeleteTask:
    scheduler=parent.getScheduler();
  if (scheduler != null) {
    String selectedTaskString=consoleContent.getItem(longClickedItemPosition);
    String taskKey=taskMap.get(selectedTaskString);
    if (taskKey != null) {
      scheduler.removeTaskByKey(taskKey);
    }
  }
updateConsole();
return true;
default :
}
return false;
}
 

Example 51

From project OneMoreDream, under directory /src/com/dixheure/.

Source file: AlarmClock.java

  21 
vote

@Override public boolean onContextItemSelected(final MenuItem item){
  final AdapterContextMenuInfo info=(AdapterContextMenuInfo)item.getMenuInfo();
  final int id=(int)info.id;
switch (item.getItemId()) {
case R.id.delete_alarm:
    new AlertDialog.Builder(this).setTitle(getString(R.string.delete_alarm)).setMessage(getString(R.string.delete_alarm_confirm)).setPositiveButton(android.R.string.ok,new DialogInterface.OnClickListener(){
      public void onClick(      DialogInterface d,      int w){
        Alarms.deleteAlarm(AlarmClock.this,id);
      }
    }
).setNegativeButton(android.R.string.cancel,null).show();
  return true;
case R.id.enable_alarm:
final Cursor c=(Cursor)mAlarmsList.getAdapter().getItem(info.position);
final Alarm alarm=new Alarm(c);
Alarms.enableAlarm(this,alarm.id,!alarm.enabled);
if (!alarm.enabled) {
SetAlarm.popAlarmSetToast(this,alarm.hour,alarm.minutes,alarm.daysOfWeek);
}
return true;
default :
break;
}
return super.onContextItemSelected(item);
}
 

Example 52

From project packages_apps_FileManager, under directory /src/org/openintents/filemanager/.

Source file: FileManagerActivity.java

  21 
vote

@Override public boolean onContextItemSelected(MenuItem item){
  super.onContextItemSelected(item);
  AdapterContextMenuInfo menuInfo=(AdapterContextMenuInfo)item.getMenuInfo();
  IconifiedTextListAdapter adapter=(IconifiedTextListAdapter)getListAdapter();
  if (adapter == null) {
    return false;
  }
  IconifiedText ic=(IconifiedText)adapter.getItem(menuInfo.position);
  mContextText=ic.getText();
  mContextIcon=ic.getIcon();
  mContextFile=FileUtils.getFile(currentDirectory,ic.getText());
switch (item.getItemId()) {
case MENU_OPEN:
    openFile(mContextFile);
  return true;
case MENU_MOVE:
promptDestinationAndMoveFile();
return true;
case MENU_COPY:
promptDestinationAndCopyFile();
return true;
case MENU_DELETE:
showDialog(DIALOG_DELETE);
return true;
case MENU_RENAME:
showDialog(DIALOG_RENAME);
return true;
case MENU_SEND:
sendFile(mContextFile);
return true;
}
return false;
}
 

Example 53

From project PinDroid, under directory /src/com/pindroid/fragment/.

Source file: BrowseBookmarkFeedFragment.java

  21 
vote

@Override public boolean onContextItemSelected(MenuItem aItem){
  AdapterContextMenuInfo menuInfo=(AdapterContextMenuInfo)aItem.getMenuInfo();
  final Cursor c=(Cursor)lv.getItemAtPosition(menuInfo.position);
  Bookmark b=BookmarkManager.CursorToBookmark(c);
switch (aItem.getItemId()) {
case R.id.menu_bookmark_context_open:
    openBookmarkInBrowser(b);
  return true;
case R.id.menu_bookmark_context_view:
viewBookmark(b);
return true;
case R.id.menu_bookmark_context_add:
addBookmark(b);
return true;
case R.id.menu_bookmark_context_read:
readBookmark(b);
return true;
case R.id.menu_bookmark_context_share:
bookmarkSelectedListener.onBookmarkShare(b);
return true;
}
return false;
}
 

Example 54

From project platform_packages_apps_alarmclock, under directory /src/com/android/alarmclock/.

Source file: AlarmClock.java

  21 
vote

@Override public boolean onContextItemSelected(final MenuItem item){
  final AdapterContextMenuInfo info=(AdapterContextMenuInfo)item.getMenuInfo();
  final int id=(int)info.id;
switch (item.getItemId()) {
case R.id.delete_alarm:
    new AlertDialog.Builder(this).setTitle(getString(R.string.delete_alarm)).setMessage(getString(R.string.delete_alarm_confirm)).setPositiveButton(android.R.string.ok,new DialogInterface.OnClickListener(){
      public void onClick(      DialogInterface d,      int w){
        Alarms.deleteAlarm(AlarmClock.this,id);
      }
    }
).setNegativeButton(android.R.string.cancel,null).show();
  return true;
case R.id.enable_alarm:
final Cursor c=(Cursor)mAlarmsList.getAdapter().getItem(info.position);
final Alarm alarm=new Alarm(c);
Alarms.enableAlarm(this,alarm.id,!alarm.enabled);
if (!alarm.enabled) {
SetAlarm.popAlarmSetToast(this,alarm.hour,alarm.minutes,alarm.daysOfWeek);
}
return true;
default :
break;
}
return super.onContextItemSelected(item);
}
 

Example 55

From project platform_packages_apps_Gallery, under directory /src/com/android/camera/.

Source file: GalleryPicker.java

  21 
vote

private boolean onSlideShowClicked(ContextMenuInfo menuInfo){
  AdapterContextMenuInfo info=(AdapterContextMenuInfo)menuInfo;
  int position=info.position;
  if (position < 0 || position >= mAdapter.mItems.size()) {
    return true;
  }
  Item item=mAdapter.mItems.get(position);
  Uri targetUri=item.mFirstImageUri;
  if (targetUri != null && item.mBucketId != null) {
    targetUri=targetUri.buildUpon().appendQueryParameter("bucketId",item.mBucketId).build();
  }
  Intent intent=new Intent(Intent.ACTION_VIEW,targetUri);
  intent.putExtra("slideshow",true);
  startActivity(intent);
  return true;
}
 

Example 56

From project platform_packages_apps_mms, under directory /src/com/android/mms/ui/.

Source file: SlideshowEditActivity.java

  21 
vote

@Override public boolean onContextItemSelected(MenuItem item){
  AdapterContextMenuInfo info=(AdapterView.AdapterContextMenuInfo)item.getMenuInfo();
  int position=info.position;
switch (item.getItemId()) {
case MENU_MOVE_UP:
    if ((position > 0) && (position < mSlideshowModel.size())) {
      mSlideshowEditor.moveSlideUp(position);
      mSlideListAdapter.notifyDataSetChanged();
      mList.setSelection(position - 1);
    }
  break;
case MENU_MOVE_DOWN:
if ((position >= 0) && (position < mSlideshowModel.size() - 1)) {
  mSlideshowEditor.moveSlideDown(position);
  mSlideListAdapter.notifyDataSetChanged();
  mList.setSelection(position + 1);
}
break;
case MENU_REMOVE_SLIDE:
if ((position >= 0) && (position < mSlideshowModel.size())) {
mSlideshowEditor.removeSlide(position);
mSlideListAdapter.notifyDataSetChanged();
}
break;
case MENU_ADD_SLIDE:
addNewSlide();
break;
default :
break;
}
return true;
}
 

Example 57

From project platform_packages_apps_music, under directory /src/com/android/music/.

Source file: AlbumBrowserActivity.java

  21 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View view,ContextMenuInfo menuInfoIn){
  menu.add(0,PLAY_SELECTION,0,R.string.play_selection);
  SubMenu sub=menu.addSubMenu(0,ADD_TO_PLAYLIST,0,R.string.add_to_playlist);
  MusicUtils.makePlaylistMenu(this,sub);
  menu.add(0,DELETE_ITEM,0,R.string.delete_item);
  AdapterContextMenuInfo mi=(AdapterContextMenuInfo)menuInfoIn;
  mAlbumCursor.moveToPosition(mi.position);
  mCurrentAlbumId=mAlbumCursor.getString(mAlbumCursor.getColumnIndexOrThrow(MediaStore.Audio.Albums._ID));
  mCurrentAlbumName=mAlbumCursor.getString(mAlbumCursor.getColumnIndexOrThrow(MediaStore.Audio.Albums.ALBUM));
  mCurrentArtistNameForAlbum=mAlbumCursor.getString(mAlbumCursor.getColumnIndexOrThrow(MediaStore.Audio.Albums.ARTIST));
  mIsUnknownArtist=mCurrentArtistNameForAlbum == null || mCurrentArtistNameForAlbum.equals(MediaStore.UNKNOWN_STRING);
  mIsUnknownAlbum=mCurrentAlbumName == null || mCurrentAlbumName.equals(MediaStore.UNKNOWN_STRING);
  if (mIsUnknownAlbum) {
    menu.setHeaderTitle(getString(R.string.unknown_album_name));
  }
 else {
    menu.setHeaderTitle(mCurrentAlbumName);
  }
  if (!mIsUnknownAlbum || !mIsUnknownArtist) {
    menu.add(0,SEARCH,0,R.string.search_title);
  }
}
 

Example 58

From project safe, under directory /Safe/src/org/openintents/safe/.

Source file: PassList.java

  21 
vote

public boolean onOptionsItemSelected(MenuItem item){
  if (restartTimerIntent != null)   sendBroadcast(restartTimerIntent);
  AdapterContextMenuInfo info=(AdapterContextMenuInfo)item.getMenuInfo();
  int position=-1;
  if (info == null) {
    position=getSelectedItemPosition();
  }
 else {
    position=info.position;
  }
switch (item.getItemId()) {
case android.R.id.home:
    Intent intent=new Intent(this,CategoryList.class);
  intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
break;
case ADD_PASSWORD_INDEX:
addPassword();
break;
case VIEW_PASSWORD_INDEX:
viewPassword(position);
lastPosition=position;
break;
case EDIT_PASSWORD_INDEX:
Intent i=new Intent(this,PassEdit.class);
i.putExtra(KEY_ID,rows.get(position).id);
i.putExtra(KEY_CATEGORY_ID,CategoryId);
startActivityForResult(i,REQUEST_EDIT_PASSWORD);
lastPosition=position;
break;
case DEL_PASSWORD_INDEX:
deletePassword(position);
break;
case MOVE_PASSWORD_INDEX:
movePassword(rows.get(position).id);
lastPosition=position;
break;
}
return super.onOptionsItemSelected(item);
}
 

Example 59

From project Speedometer, under directory /android/src/com/google/wireless/speed/speedometer/.

Source file: MeasurementScheduleConsoleActivity.java

  21 
vote

/** 
 * Handles the deletion of the measurement tasks when the user clicks the context menu
 */
@Override public boolean onContextItemSelected(MenuItem item){
  AdapterContextMenuInfo info=(AdapterContextMenuInfo)item.getMenuInfo();
switch (item.getItemId()) {
case R.id.ctxMenuDeleteTask:
    scheduler=parent.getScheduler();
  if (scheduler != null) {
    String selectedTaskString=consoleContent.getItem(longClickedItemPosition);
    String taskKey=taskMap.get(selectedTaskString);
    if (taskKey != null) {
      scheduler.removeTaskByKey(taskKey);
    }
  }
updateConsole();
return true;
default :
}
return false;
}
 

Example 60

From project TahoeLAFS-android, under directory /src/org/openintents/filemanager/.

Source file: FileManagerActivity.java

  21 
vote

@Override public boolean onContextItemSelected(MenuItem item){
  super.onContextItemSelected(item);
  AdapterContextMenuInfo menuInfo=(AdapterContextMenuInfo)item.getMenuInfo();
  IconifiedTextListAdapter adapter=(IconifiedTextListAdapter)getListAdapter();
  if (adapter == null) {
    return false;
  }
  IconifiedText ic=(IconifiedText)adapter.getItem(menuInfo.position);
  mContextText=ic.getText();
  mContextIcon=ic.getIcon();
  mContextFile=FileUtils.getFile(currentDirectory,ic.getText());
switch (item.getItemId()) {
case MENU_OPEN:
    openFile(mContextFile);
  return true;
case MENU_MOVE:
promptDestinationAndMoveFile();
return true;
case MENU_COPY:
promptDestinationAndCopyFile();
return true;
case MENU_DELETE:
showDialog(DIALOG_DELETE);
return true;
case MENU_RENAME:
showDialog(DIALOG_RENAME);
return true;
case MENU_SEND:
sendFile(mContextFile);
return true;
}
return false;
}
 

Example 61

From project android-client_1, under directory /src/com/buddycloud/view/.

Source file: RosterActivity.java

  19 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  getMenuInflater().inflate(R.menu.roster_context,menu);
  Intent openChannel=new Intent();
  openChannel.setClassName("com.buddycloud.android.buddydroid",ChannelMessageActivity.class.getCanonicalName());
  Cursor buddy=(Cursor)listAdapter.getItem(((AdapterContextMenuInfo)menuInfo).position);
  String jid=buddy.getString(buddy.getColumnIndex(Roster.JID));
  openChannel.setData(Uri.parse("channel:" + jid));
  menu.findItem(R.id.open_channel).setIntent(openChannel);
  super.onCreateContextMenu(menu,v,menuInfo);
}
 

Example 62

From project android-vpn-settings, under directory /src/com/android/settings/vpn/.

Source file: VpnSettings.java

  19 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  super.onCreateContextMenu(menu,v,menuInfo);
  VpnProfile p=getProfile(getProfilePositionFrom((AdapterContextMenuInfo)menuInfo));
  if (p != null) {
    VpnState state=p.getState();
    menu.setHeaderTitle(p.getName());
    boolean isIdle=(state == VpnState.IDLE);
    boolean isNotConnect=(isIdle || (state == VpnState.DISCONNECTING) || (state == VpnState.CANCELLED));
    menu.add(0,CONTEXT_MENU_CONNECT_ID,0,R.string.vpn_menu_connect).setEnabled(isIdle && (mActiveProfile == null));
    menu.add(0,CONTEXT_MENU_DISCONNECT_ID,0,R.string.vpn_menu_disconnect).setEnabled(state == VpnState.CONNECTED);
    menu.add(0,CONTEXT_MENU_EDIT_ID,0,R.string.vpn_menu_edit).setEnabled(isNotConnect);
    menu.add(0,CONTEXT_MENU_DELETE_ID,0,R.string.vpn_menu_delete).setEnabled(isNotConnect);
  }
}
 

Example 63

From project android-xbmcremote, under directory /src/org/xbmc/android/remote/presentation/controller/.

Source file: AlbumListController.java

  19 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  final ThreeLabelsItemView view=(ThreeLabelsItemView)((AdapterContextMenuInfo)menuInfo).targetView;
  menu.setHeaderTitle(((Album)mList.getItemAtPosition(view.getPosition())).name);
  menu.add(0,ITEM_CONTEXT_QUEUE,1,"Queue Album");
  menu.add(0,ITEM_CONTEXT_PLAY,2,"Play Album");
  menu.add(0,ITEM_CONTEXT_INFO,3,"View Details");
}
 

Example 64

From project android_packages_apps_Tag, under directory /src/com/android/apps/tag/.

Source file: MyTagList.java

  19 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View view,ContextMenuInfo info){
  Cursor cursor=mAdapter.getCursor();
  if (cursor == null || cursor.isClosed() || !cursor.moveToPosition(((AdapterContextMenuInfo)info).position)) {
    return;
  }
  menu.setHeaderTitle(cursor.getString(TagQuery.COLUMN_TITLE));
  long id=cursor.getLong(TagQuery.COLUMN_ID);
  MenuInflater inflater=getMenuInflater();
  inflater.inflate(R.menu.my_tag_list_context_menu,menu);
  menu.findItem(R.id.set_as_active).setVisible(id != mActiveTagId);
  mTagIdLongPressed=id;
  if (mWriteSupport) {
    menu.add(0,1,0,"Write to tag");
  }
}
 

Example 65

From project Anki-Android, under directory /src/com/ichi2/anki/.

Source file: SharedDeckPicker.java

  19 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  Resources res=getResources();
  int position=((AdapterContextMenuInfo)menuInfo).position;
  Object obj=mAllSharedDecks.get(position);
  if (obj instanceof Download) {
    Download download=(Download)obj;
    menu.add(Menu.NONE,MENU_CANCEL,Menu.NONE,res.getString(R.string.cancel_download));
    if (download.getStatus() == SharedDeckDownload.STATUS_PAUSED) {
      menu.add(Menu.NONE,MENU_RESUME,Menu.NONE,res.getString(R.string.resume_download));
    }
 else     if (download.getStatus() == SharedDeckDownload.STATUS_UPDATING) {
      menu.add(Menu.NONE,MENU_PAUSE,Menu.NONE,res.getString(R.string.pause_download));
    }
  }
}
 

Example 66

From project Birthday-widget, under directory /Birthday/src/main/java/cz/krtinec/birthday/.

Source file: Birthday.java

  19 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  menu.setHeaderTitle(R.string.context_menu_header);
  Event item=listOfContacts.get(((AdapterContextMenuInfo)menuInfo).position);
  MenuItem callItem=menu.add(R.string.context_menu_call).setEnabled(false);
  MenuItem smstItem=menu.add(R.string.context_menu_text).setEnabled(false);
  MenuItem emailItem=menu.add(R.string.context_menu_email).setEnabled(false);
  String phone=BirthdayProvider.getPhoneNumber(this,item.getContactId());
  if (phone != null) {
    smstItem.setEnabled(true);
    Intent smsIntent=new Intent(Intent.ACTION_VIEW,Uri.parse("sms:" + phone));
    smsIntent.putExtra("sms_body",Utils.getCongrats(this,item));
    smstItem.setIntent(smsIntent);
    callItem.setEnabled(true);
    Intent callIntent=new Intent(Intent.ACTION_VIEW,Uri.parse("tel:" + phone));
    callItem.setIntent(callIntent);
  }
  String email=BirthdayProvider.getEmail(this,item.getContactId());
  if (email != null) {
    emailItem.setEnabled(true);
    String subject=getString(R.string.congrats_subject);
    String body=Utils.getCongrats(this,item);
    Intent mailer=new Intent(Intent.ACTION_SEND);
    mailer.setType("text/plain");
    mailer.putExtra(Intent.EXTRA_EMAIL,new String[]{email});
    mailer.putExtra(Intent.EXTRA_SUBJECT,subject);
    mailer.putExtra(Intent.EXTRA_TEXT,body);
    emailItem.setIntent(mailer);
  }
}
 

Example 67

From project creamed_glacier_app_settings, under directory /src/com/android/settings/vpn2/.

Source file: VpnSettings.java

  19 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View view,ContextMenuInfo info){
  if (mDialog != null) {
    Log.v(TAG,"onCreateContextMenu() is called when mDialog != null");
    return;
  }
  if (info instanceof AdapterContextMenuInfo) {
    Preference preference=(Preference)getListView().getItemAtPosition(((AdapterContextMenuInfo)info).position);
    if (preference instanceof VpnPreference) {
      VpnProfile profile=((VpnPreference)preference).getProfile();
      mSelectedKey=profile.key;
      menu.setHeaderTitle(profile.name);
      menu.add(Menu.NONE,R.string.vpn_menu_edit,0,R.string.vpn_menu_edit);
      menu.add(Menu.NONE,R.string.vpn_menu_delete,0,R.string.vpn_menu_delete);
    }
  }
}
 

Example 68

From project DroidExpenses, under directory /de.simtem.android.expenses/src/de/simtem/android/expenses/.

Source file: Accounts.java

  19 
vote

/** 
 * @see Activity#onCreateContextMenu(ContextMenu,View,ContextMenuInfo)
 */
@Override public void onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo menuInfo){
  int position=((AdapterContextMenuInfo)menuInfo).position;
  Account account=accounts.getItem(position);
  if (account != null) {
    getMenuInflater().inflate(R.menu.account_context,menu);
    menu.setHeaderTitle(account.getName());
  }
}
 

Example 69

From project filemanager, under directory /FileManager/src/org/openintents/filemanager/compatibility/.

Source file: BookmarkListActionHandler.java

  19 
vote

/** 
 * Offers a centralized bookmark action execution component.
 * @param item The MenuItem selected.
 * @param list The list to act upon.
 * @param pos The selected item's position.
 */
public static void handleItemSelection(MenuItem item,ListView list){
  if (VERSION.SDK_INT < VERSION_CODES.HONEYCOMB || ListViewMethodHelper.listView_getCheckedItemCount(list) == 1) {
    long id=-1;
    if (item.getMenuInfo() instanceof AdapterContextMenuInfo)     id=list.getAdapter().getItemId(((AdapterContextMenuInfo)item.getMenuInfo()).position);
    if (VERSION.SDK_INT > VERSION_CODES.HONEYCOMB)     id=ListViewMethodHelper.listView_getCheckedItemIds(list)[0];
switch (item.getItemId()) {
case R.id.menu_delete:
      list.getContext().getContentResolver().delete(BookmarksProvider.CONTENT_URI,BookmarksProvider._ID + "=?",new String[]{"" + id});
    break;
}
}
 else {
switch (item.getItemId()) {
case R.id.menu_delete:
  long[] ids=ListViewMethodHelper.listView_getCheckedItemIds(list);
for (int i=0; i < ids.length; i++) {
  list.getContext().getContentResolver().delete(BookmarksProvider.CONTENT_URI,BookmarksProvider._ID + "=?",new String[]{"" + ids[i]});
}
break;
}
}
((BookmarkListAdapter)list.getAdapter()).notifyDataSetChanged();
}
 

Example 70

From project ohmagePhone, under directory /src/org/ohmage/triggers/types/location/.

Source file: LocTrigSettingsActivity.java

  19 
vote

@Override public boolean onContextItemSelected(MenuItem item){
  int pos=((AdapterContextMenuInfo)item.getMenuInfo()).position;
  mCursor.moveToPosition(pos);
  int categId=mCursor.getInt(mCursor.getColumnIndexOrThrow(LocTrigDB.KEY_ID));
switch (item.getItemId()) {
case MENU_DELETE_CATEG:
    mDialogCategId=categId;
  mDialogText=null;
removeDialog(DIALOG_DELETE);
showDialog(DIALOG_DELETE);
return true;
case MENU_RENAME_CATEG:
mDialogCategId=categId;
removeDialog(DIALOG_RENAME);
showDialog(DIALOG_RENAME);
return true;
default :
break;
}
return super.onContextItemSelected(item);
}
 

Example 71

From project Ohmage_Phone, under directory /src/org/ohmage/triggers/types/location/.

Source file: LocTrigSettingsActivity.java

  19 
vote

@Override public boolean onContextItemSelected(MenuItem item){
  int pos=((AdapterContextMenuInfo)item.getMenuInfo()).position;
  mCursor.moveToPosition(pos);
  int categId=mCursor.getInt(mCursor.getColumnIndexOrThrow(LocTrigDB.KEY_ID));
switch (item.getItemId()) {
case MENU_DELETE_CATEG:
    mDialogCategId=categId;
  mDialogText=null;
removeDialog(DIALOG_DELETE);
showDialog(DIALOG_DELETE);
return true;
case MENU_RENAME_CATEG:
mDialogCategId=categId;
removeDialog(DIALOG_RENAME);
showDialog(DIALOG_RENAME);
return true;
default :
break;
}
return super.onContextItemSelected(item);
}
 

Example 72

From project OpenBike, under directory /src/fr/openbike/android/ui/.

Source file: OpenBikeListActivity.java

  19 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View view,ContextMenuInfo menuInfo){
  super.onCreateContextMenu(menu,view,menuInfo);
  MenuInflater inflater=getMenuInflater();
  inflater.inflate(R.menu.list_context_menu,menu);
  ViewHolder holder=((ViewHolder)((AdapterContextMenuInfo)menuInfo).targetView.getTag());
  menu.removeItem(holder.favorite.isChecked() ? R.id.add_favorite : R.id.remove_favorite);
  if (!Utils.isIntentAvailable(new Intent(Intent.ACTION_VIEW,Uri.parse("geo:0,0?q=bibi")),this)) {
    menu.removeItem(R.id.show_on_google_maps);
  }
  if (!Utils.isIntentAvailable(new Intent(Intent.ACTION_VIEW,Uri.parse("google.navigation:q=bibi")),this)) {
    menu.removeItem(R.id.navigate);
  }
  menu.removeItem(holder.favorite.isChecked() ? R.id.add_favorite : R.id.remove_favorite);
  mSelected=(String.valueOf((Integer)holder.favorite.getTag()));
  menu.setHeaderTitle(holder.name.getText());
}
 

Example 73

From project platform_packages_apps_contacts, under directory /src/com/android/contacts/detail/.

Source file: ContactDetailFragment.java

  19 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View view,ContextMenuInfo menuInfo){
  super.onCreateContextMenu(menu,view,menuInfo);
  AdapterView.AdapterContextMenuInfo info=(AdapterContextMenuInfo)menuInfo;
  DetailViewEntry selectedEntry=(DetailViewEntry)mAllEntries.get(info.position);
  menu.setHeaderTitle(selectedEntry.data);
  menu.add(ContextMenu.NONE,ContextMenuIds.COPY_TEXT,ContextMenu.NONE,getString(R.string.copy_text));
  String selectedMimeType=selectedEntry.mimetype;
  boolean isUniqueMimeType=true;
  if (Phone.CONTENT_ITEM_TYPE.equals(selectedMimeType)) {
    isUniqueMimeType=mIsUniqueNumber;
  }
 else   if (Email.CONTENT_ITEM_TYPE.equals(selectedMimeType)) {
    isUniqueMimeType=mIsUniqueEmail;
  }
  if (selectedEntry.isPrimary) {
    menu.add(ContextMenu.NONE,ContextMenuIds.CLEAR_DEFAULT,ContextMenu.NONE,getString(R.string.clear_default));
  }
 else   if (!isUniqueMimeType) {
    menu.add(ContextMenu.NONE,ContextMenuIds.SET_DEFAULT,ContextMenu.NONE,getString(R.string.set_default));
  }
}
 

Example 74

From project platform_packages_apps_settings, under directory /src/com/android/settings/vpn2/.

Source file: VpnSettings.java

  19 
vote

@Override public void onCreateContextMenu(ContextMenu menu,View view,ContextMenuInfo info){
  if (mDialog != null) {
    Log.v(TAG,"onCreateContextMenu() is called when mDialog != null");
    return;
  }
  if (info instanceof AdapterContextMenuInfo) {
    Preference preference=(Preference)getListView().getItemAtPosition(((AdapterContextMenuInfo)info).position);
    if (preference instanceof VpnPreference) {
      VpnProfile profile=((VpnPreference)preference).getProfile();
      mSelectedKey=profile.key;
      menu.setHeaderTitle(profile.name);
      menu.add(Menu.NONE,R.string.vpn_menu_edit,0,R.string.vpn_menu_edit);
      menu.add(Menu.NONE,R.string.vpn_menu_delete,0,R.string.vpn_menu_delete);
    }
  }
}
 

Example 75

From project sonet, under directory /core/src/com/piusvelte/sonet/core/.

Source file: ManageAccounts.java

  19 
vote

@Override public boolean onContextItemSelected(MenuItem item){
  if (item.getItemId() == DELETE_ID) {
    mUpdateWidget=true;
    String accountId=Long.toString(((AdapterContextMenuInfo)item.getMenuInfo()).id);
    getContentResolver().delete(Accounts.getContentUri(this),Accounts._ID + "=?",new String[]{accountId});
    getContentResolver().delete(Widgets.getContentUri(this),Widgets.ACCOUNT + "=?",new String[]{accountId});
    Cursor statuses=getContentResolver().query(Statuses.getContentUri(this),new String[]{Statuses._ID},Statuses.ACCOUNT + "=?",new String[]{accountId},null);
    if (statuses.moveToFirst()) {
      while (!statuses.isAfterLast()) {
        getContentResolver().delete(Status_links.getContentUri(this),Status_links.STATUS_ID + "=?",new String[]{Long.toString(statuses.getLong(0))});
        getContentResolver().delete(Status_images.getContentUri(this),Status_images.STATUS_ID + "=?",new String[]{Long.toString(statuses.getLong(0))});
        statuses.moveToNext();
      }
    }
    statuses.close();
    getContentResolver().delete(Statuses.getContentUri(this),Statuses.ACCOUNT + "=?",new String[]{accountId});
    getContentResolver().delete(Widget_accounts.getContentUri(this),Widget_accounts.ACCOUNT + "=?",new String[]{accountId});
    getContentResolver().delete(Notifications.getContentUri(this),Notifications.ACCOUNT + "=?",new String[]{accountId});
    listAccounts();
  }
  return super.onContextItemSelected(item);
}