android.widget.AdapterView.AdapterContextMenuInfo Java Examples

The following examples show how to use android.widget.AdapterView.AdapterContextMenuInfo. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PortfolioActivity.java    From ministocks with MIT License 6 votes vote down vote up
@Override
public boolean onContextItemSelected(MenuItem item) {
    if (item.getItemId() == 1) {
        Callable callable = new Callable() {
            @Override
            public Object call() throws Exception {
                portfolioRepository.updateStock(mStockSymbol);
                refreshView();
                return new Object();
            }
        };
        DialogTools.alertWithCallback(this, "Confirm Delete",
                "Clear portfolio info for " + mStockSymbol + "?", "Delete", "Cancel",
                callable, null);
    } else if (item.getItemId() == 0) {
        AdapterContextMenuInfo menuInfo = ((AdapterView.AdapterContextMenuInfo) item.getMenuInfo());
        showPortfolioItemEdit(mPortfolioListView, menuInfo.position);
    }
    return super.onContextItemSelected(item);
}
 
Example #2
Source File: PlaylistFragment.java    From android-vlc-remote with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onContextItemSelected(MenuItem menuItem) {
    ContextMenuInfo menuInfo = menuItem.getMenuInfo();
    if (menuInfo instanceof AdapterContextMenuInfo) {
        AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
        if (info.position < mAdapter.getCount()) {
            PlaylistItem item = mAdapter.getItem(info.position);
            switch (menuItem.getItemId()) {
                case R.id.playlist_context_play:
                    selectItem(item);
                    return true;
                case R.id.playlist_context_dequeue:
                    removeItem(item, info.position);
                    return true;
                case R.id.playlist_context_search:
                    searchForItem(item);
                    return true;
            }
        }
    }
    return super.onContextItemSelected(menuItem);
}
 
Example #3
Source File: FileList.java    From stynico with MIT License 6 votes vote down vote up
@Override
   public boolean onContextItemSelected(MenuItem item)
   {
AdapterContextMenuInfo menuInfo =
    (AdapterContextMenuInfo) item.getMenuInfo();
// TODO: Implement this method
if (item.getItemId() == 0)
{
    //预览
    Intent intent = new Intent("android.intent.action.VIEW");
    intent.addCategory("android.intent.category.DEFAULT");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    Uri uri = Uri.fromFile(new File(curpath + "/" + files_name.get(menuInfo.position - dirs_name.size())));
    intent.setDataAndType(uri, "image/*");
    startActivity(intent);

}
return super.onOptionsItemSelected(item);
   }
 
Example #4
Source File: HCActivity.java    From stynico with MIT License 6 votes vote down vote up
@Override
   public boolean onContextItemSelected(MenuItem item)
   {
AdapterContextMenuInfo menuInfo =
    (AdapterContextMenuInfo) item.getMenuInfo();
// TODO: Implement this method
if (item.getItemId() == 0)
{
    //修改持续时间
    showEditTextDialog(HCActivity.this, "设置该图持续的时间(秒)", menuInfo.position);
}
else if (item.getItemId() == 1)
{
    //移除项
    items.remove(menuInfo.position);
    adapter.notifyDataSetChanged();
    showToast("移除成功");
}
return super.onOptionsItemSelected(item);
   }
 
Example #5
Source File: FileList.java    From styT with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo menuInfo =
            (AdapterContextMenuInfo) item.getMenuInfo();
    // TODO: Implement this method
    if (item.getItemId() == 0) {
        //预览
        Intent intent = new Intent("android.intent.action.VIEW");
        intent.addCategory("android.intent.category.DEFAULT");
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        Uri uri = Uri.fromFile(new File(curpath + "/" + files_name.get(menuInfo.position - dirs_name.size())));
        intent.setDataAndType(uri, "image/*");
        startActivity(intent);

    }
    return super.onOptionsItemSelected(item);
}
 
Example #6
Source File: PreventFragment.java    From prevent with Do What The F*ck You Want To Public License 6 votes vote down vote up
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    if (!canCreateContextMenu(menu, menuInfo)) {
        return;
    }
    menu.clear();
    ViewHolder holder = (ViewHolder) ((AdapterContextMenuInfo) menuInfo).targetView.getTag();
    menu.setHeaderTitle(holder.nameView.getText());
    if (holder.icon != null) {
        setHeaderIcon(menu, holder.icon);
    }
    menu.add(Menu.NONE, R.string.app_info, Menu.NONE, R.string.app_info);
    updatePreventMenu(menu, holder.packageName);
    if (getMainIntent(holder.packageName) != null) {
        menu.add(Menu.NONE, R.string.open, Menu.NONE, R.string.open);
    }
    if (holder.canUninstall) {
        menu.add(Menu.NONE, R.string.uninstall, Menu.NONE, R.string.uninstall);
    }
    if (appNotification) {
        menu.add(Menu.NONE, R.string.app_notifications, Menu.NONE, R.string.app_notifications);
    }
}
 
Example #7
Source File: ManageAccountActivity.java    From Conversations with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    ManageAccountActivity.this.getMenuInflater().inflate(
            R.menu.manageaccounts_context, menu);
    AdapterContextMenuInfo acmi = (AdapterContextMenuInfo) menuInfo;
    this.selectedAccount = accountList.get(acmi.position);
    if (this.selectedAccount.isEnabled()) {
        menu.findItem(R.id.mgmt_account_enable).setVisible(false);
        menu.findItem(R.id.mgmt_account_announce_pgp).setVisible(Config.supportOpenPgp());
    } else {
        menu.findItem(R.id.mgmt_account_disable).setVisible(false);
        menu.findItem(R.id.mgmt_account_announce_pgp).setVisible(false);
        menu.findItem(R.id.mgmt_account_publish_avatar).setVisible(false);
    }
    menu.setHeaderTitle(this.selectedAccount.getJid().asBareJid().toEscapedString());
}
 
Example #8
Source File: ActivityChooseFiltersAndActions.java    From LibreTasks with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onContextItemSelected(MenuItem item) {
  AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
  int selectedItemPosition = info.position;
  listView.setItemChecked(selectedItemPosition, true); // Set the chosen item as selected

  switch (item.getItemId()) {
  case MENU_EDIT:
    editItem(selectedItemPosition);
    return true;
  case MENU_DELETE:
    confirmDeleteItem(selectedItemPosition);
    return true;
  default:
    return super.onContextItemSelected(item);
  }
}
 
Example #9
Source File: ActivitySavedRules.java    From LibreTasks with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onContextItemSelected(MenuItem item) {
  AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
  switch (item.getItemId()) {
  case MENU_EDIT:
    editRule(info.position);
    return true;
  case MENU_DELETE:
    deleteRule(info.position);
    return true;
  case MENU_TOGGLE:
    ruleListAdapter.toggleRule(info.position);
    return true;
  case MENU_NOTIFICATION:
    ruleListAdapter.setNotification(info.position);
  default:
    return super.onContextItemSelected(item);
  }
}
 
Example #10
Source File: HomeScreenFragment.java    From Gazetti_Newspaper_Reader with MIT License 6 votes vote down vote up
@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    int position = info.position;
    String newspaper = cellList.get(position).getNewspaperImage();
    String category = cellList.get(position).getCategoryTitle();

    switch (item.getItemId()) {
        case R.id.edit:
            activityCallback.showEditCellDialog(position, newspaper, category, cellList, adapter);
            return true;
        case R.id.delete:
            UserPrefUtil.getInstance(getActivity()).deleteUserPref(cellList.get(position));
            cellList.remove(position);
            adapter.notifyDataSetChanged();
            return true;
        default:
            return super.onContextItemSelected(item);
    }
}
 
Example #11
Source File: SelectedSongsView.java    From ampdroid with MIT License 6 votes vote down vote up
@Override
public boolean onContextItemSelected(MenuItem item) {
	AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();

	switch (item.getItemId()) {
	case R.id.contextMenuAdd:
		controller.getPlayNow().add(controller.getSongs().get((int) info.id));
		Context context = getView().getContext();
		CharSequence text = getResources().getString(R.string.songsViewSongAdded);
		int duration = Toast.LENGTH_SHORT;
		Toast toast = Toast.makeText(context, text, duration);
		toast.show();
		return true;
	case R.id.contextMenuSongsOpen:
		controller.getPlayNow().clear();
		controller.getPlayNow().add(controller.getSongs().get((int) info.id));
		((MainActivity) getActivity()).play(0);
		return true;
	default:
		return super.onContextItemSelected(item);
	}
}
 
Example #12
Source File: SessionManagerActivity.java    From sniffer154 with GNU General Public License v3.0 6 votes vote down vote up
@Override
	public boolean onContextItemSelected(MenuItem item) {
		AdapterContextMenuInfo info = (AdapterContextMenuInfo) item
				.getMenuInfo();
		switch (item.getItemId()) {
		case R.id.itemLoad:
			loadSession(info.id);
			return true;
		case R.id.itemDelete:
			deleteSession(info.id);
			return true;
//		case R.id.itemExport:
//			exportSession(info.id);
//			return true;
		default:
			return false;
		}
	}
 
Example #13
Source File: SendPage.java    From fanfouapp-opensource with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onContextItemSelected(final MenuItem item) {
    final AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) item
            .getMenuInfo();
    final int id = item.getItemId();
    final Cursor c = (Cursor) this.mCursorAdapter
            .getItem(menuInfo.position);
    if (c != null) {
        final DirectMessage dm = DirectMessage.parse(c);
        if ((dm != null) && !dm.isNull()) {
            switch (id) {
            case R.id.dm_copy:
                doCopy(dm);
                break;
            case R.id.dm_delete:
                doDelete(dm);
                break;
            default:
                break;
            }
        }
    }

    return true;
    // return super.onContextItemSelected(item);
}
 
Example #14
Source File: ChatAllHistoryActivity.java    From school_shop with MIT License 6 votes vote down vote up
@Override
	public boolean onContextItemSelected(MenuItem item) {
		boolean handled = false;
		boolean deleteMessage = false;
		if (item.getItemId() == R.id.delete_message) {
			deleteMessage = true;
			handled = true;
		} else if (item.getItemId() == R.id.delete_conversation) {
			deleteMessage = false;
			handled = true;
		}
		EMConversation tobeDeleteCons = adapter.getItem(((AdapterContextMenuInfo) item.getMenuInfo()).position);
		// 删除此会话
		EMChatManager.getInstance().deleteConversation(tobeDeleteCons.getUserName(), tobeDeleteCons.isGroup(), deleteMessage);
		InviteMessgeDao inviteMessgeDao = new InviteMessgeDao(this);
		inviteMessgeDao.deleteMessage(tobeDeleteCons.getUserName());
		adapter.remove(tobeDeleteCons);
		adapter.notifyDataSetChanged();

		// 更新消息未读数
//		updateUnreadLabel();
		
		return handled ? true : super.onContextItemSelected(item);
	}
 
Example #15
Source File: HCActivity.java    From styT with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo menuInfo =
            (AdapterContextMenuInfo) item.getMenuInfo();
    // TODO: Implement this method
    if (item.getItemId() == 0) {
        //修改持续时间
        showEditTextDialog(HCActivity.this, "设置该图持续的时间(秒)", menuInfo.position);
    } else if (item.getItemId() == 1) {
        //移除项
        items.remove(menuInfo.position);
        adapter.notifyDataSetChanged();
        showToast("移除成功");
    }
    return super.onOptionsItemSelected(item);
}
 
Example #16
Source File: AuthenticatorActivity.java    From google-authenticator-android with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
  super.onCreateContextMenu(menu, v, menuInfo);
  AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
  PinInfo selectedUser = users[(int) info.id];
  getMenuInflater().inflate(R.menu.account_list_context, menu);
  menu.setHeaderTitle(selectedUser.getIndex().getStrippedName());

  if (!isRenameAccountAvailableSupported(selectedUser)) {
    menu.removeItem(R.id.rename);
  }

  if (!isCheckAccountKeyValueSupported(selectedUser)) {
    menu.removeItem(R.id.check_code);
  }

  mostRecentContextMenu = menu;
}
 
Example #17
Source File: AudioPlayer.java    From VCL-Android with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onContextItemSelected(MenuItem item) {
    if (getUserVisibleHint() && item.getMenuInfo() instanceof AdapterContextMenuInfo) {
        AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
        if(info == null) // info can be null
            return super.onContextItemSelected(item);
        int id = item.getItemId();

        if(id == R.id.audio_player_mini_remove) {
            Log.d(TAG, "Context menu removing " + info.position);
            if (mService != null)
                mService.remove(info.position);
            return true;
        }
        return super.onContextItemSelected(item);
    } else
        return false;
}
 
Example #18
Source File: ManageAccountActivity.java    From Pix-Art-Messenger with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    ManageAccountActivity.this.getMenuInflater().inflate(
            R.menu.manageaccounts_context, menu);
    AdapterContextMenuInfo acmi = (AdapterContextMenuInfo) menuInfo;
    this.selectedAccount = accountList.get(acmi.position);
    if (this.selectedAccount.isEnabled()) {
        menu.findItem(R.id.mgmt_account_announce_pgp).setVisible(Config.supportOpenPgp());
    } else {
        menu.findItem(R.id.mgmt_account_reconnect).setVisible(false);
        menu.findItem(R.id.mgmt_account_announce_pgp).setVisible(false);
        menu.findItem(R.id.mgmt_account_publish_avatar).setVisible(false);
    }
    menu.setHeaderTitle(this.selectedAccount.getJid().asBareJid().toEscapedString());
}
 
Example #19
Source File: MainActivity.java    From android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean onContextItemSelected(MenuItem item) {
	
	/*
	 *  Contiene información sobre el elemento del menú contextual
	 *  sobre el que se ha pulsado
	 */
	AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
	
	switch (item.getItemId()) {
		case R.id.ctx_eliminar:
			
			eliminarContacto(info);
			return true;
		default:
			return super.onContextItemSelected(item);
	}
}
 
Example #20
Source File: TeamList.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    switch (item.getItemId()) {
    case R.id.delete_team:
        positionOfTeamToDelete = info.position;
        showDialog(CONFIRM_DELETE_DIALOG);
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}
 
Example #21
Source File: TeamDetails.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    switch (item.getItemId()) {
    case R.id.delete_meeting:
        positionOfMeetingToDelete = info.position;
        showDialog(CONFIRM_DELETE_MEETING_DIALOG);
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}
 
Example #22
Source File: MenuFileChooser.java    From Beats with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
	AdapterContextMenuInfo info = (AdapterContextMenuInfo)menuInfo;
	MenuFileItem i = adapter.getItem(info.position);
	if (i.getFile() == null) {
		return; // ignore the "..[up one directory]"
	} else { 
		menu.setHeaderIcon(R.drawable.icon_small);
		menu.setHeaderTitle(Tools.getString(R.string.MenuFilechooser_file_options));
		menu.add(0, v.getId(), 0, " " + Tools.getString(R.string.MenuFilechooser_file_open));  
		menu.add(0, v.getId(), 1, " " + Tools.getString(R.string.MenuFilechooser_file_delete));
	}
}
 
Example #23
Source File: TeamList.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    switch (item.getItemId()) {
    case R.id.delete_team:
        positionOfTeamToDelete = info.position;
        showDialog(CONFIRM_DELETE_DIALOG);
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}
 
Example #24
Source File: SearchActivity.java    From HayaiLauncher with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onContextItemSelected(MenuItem item) {
    final AdapterContextMenuInfo info = (AdapterContextMenuInfo) item
            .getMenuInfo();
    final View itemView = info.targetView;
    final LaunchableActivity launchableActivity =
            (LaunchableActivity) itemView.findViewById(R.id.appIcon).getTag();
    switch (item.getItemId()) {
        case R.id.appmenu_launch:
            launchActivity(launchableActivity);
            return true;
        case R.id.appmenu_info:
            final Intent intent = new Intent(
                    Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
            intent.setData(Uri.parse("package:"
                    + launchableActivity.getComponent().getPackageName()));
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
            return true;
        case R.id.appmenu_onplaystore:
            final Intent intentPlayStore = new Intent(Intent.ACTION_VIEW);
            intentPlayStore.setData(Uri.parse("market://details?id=" +
                    launchableActivity.getComponent().getPackageName()));
            startActivity(intentPlayStore);
            return true;
        case R.id.appmenu_pin_to_top:
            launchableActivity.setPriority(launchableActivity.getPriority() == 0 ? 1 : 0);
            mLaunchableActivityPrefs.writePreference(launchableActivity.getClassName(),
                    launchableActivity.getLaunchTime(), launchableActivity.getPriority(), launchableActivity.getusagesQuantity());
            sortApps();
            mArrayAdapter.notifyDataSetChanged();
            return true;
        default:
            return false;
    }

}
 
Example #25
Source File: VideoGridFragment.java    From VCL-Android with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onContextItemSelected(MenuItem menu) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) menu.getMenuInfo();
    if (info != null && handleContextItemSelected(menu, info.position))
        return true;
    return super.onContextItemSelected(menu);
}
 
Example #26
Source File: BrowseFragment.java    From android-vlc-remote with GNU General Public License v3.0 5 votes vote down vote up
private File getFile(ContextMenuInfo menuInfo) {
    if (menuInfo instanceof AdapterContextMenuInfo) {
        AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
        if (info.position < mAdapter.getCount()) {
            return mAdapter.getItem(info.position);
        }
    }
    return null;
}
 
Example #27
Source File: SearchActivity.java    From HayaiLauncher with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
                                ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    if (menuInfo instanceof AdapterContextMenuInfo) {
        AdapterContextMenuInfo adapterMenuInfo = (AdapterContextMenuInfo) menuInfo;
        menu.setHeaderTitle(
                ((LaunchableActivity) adapterMenuInfo.targetView
                        .findViewById(R.id.appIcon).getTag()).getActivityLabel());
    }
    final MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.app, menu);
}
 
Example #28
Source File: ReminderListActivity.java    From Task-Reminder-App with MIT License 5 votes vote down vote up
@Override
public boolean onContextItemSelected(MenuItem item) {
	switch(item.getItemId()) {
   	case R.id.menu_delete:
   		AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
        mDbHelper.deleteReminder(info.id);
        fillData();
        return true;
	}
	return super.onContextItemSelected(item);
}
 
Example #29
Source File: PlaylistFragment.java    From android-vlc-remote with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    if (menuInfo instanceof AdapterContextMenuInfo) {
        AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
        PlaylistItem item = mAdapter.getItem(info.position);

        MenuInflater inflater = getActivity().getMenuInflater();
        inflater.inflate(R.menu.playlist_context, menu);

        MenuItem searchItem = menu.findItem(R.id.playlist_context_search);
        searchItem.setVisible(isSearchable(item));
    }
}
 
Example #30
Source File: MenuFileChooser.java    From Beats with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public boolean onContextItemSelected(MenuItem item) {
	AdapterContextMenuInfo info = (AdapterContextMenuInfo)item.getMenuInfo();
	MenuFileItem i = adapter.getItem(info.position);
	if (item.getOrder() == 0) { // Open
		onFileClick(i);
	} else { //item.getOrder() == 1 // Delete 
		selectedFilePath = i.getPath();
		
		DialogInterface.OnClickListener delete_action = new DialogInterface.OnClickListener() {
			public void onClick(DialogInterface dialog, int id) {
				try {
					deleteFile(new File(selectedFilePath));
				} catch (Exception e) {
					ToolsTracker.error("MenuFileChooser.deleteFile", e, selectedFilePath);
					Tools.error(
							Tools.getString(R.string.MenuFilechooser_file_delete_error) +
							selectedFilePath +
							Tools.getString(R.string.Tools_error_msg) +
							e.getMessage(),
							Tools.cancel_action);
				}
				refresh();
				dialog.cancel();
			}
		};
		
		Tools.alert(
				Tools.getString(R.string.MenuFilechooser_file_delete),
				R.drawable.icon_del,
				Tools.getString(R.string.MenuFilechooser_file_delete_confirm) +
				i.getName(),
				Tools.getString(R.string.Button_yes),
				delete_action,
				Tools.getString(R.string.Button_no),
				Tools.cancel_action,
				-1
				);
	}
	return true;
}