use of android.widget.AdapterView.AdapterContextMenuInfo in project K6nele by Kaljurand.
the class AppListActivity method onCreateContextMenu.
@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);
// Disable some menu items if they do not make sense in this context.
// We could also remove them but this might be confusing for the user.
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);
}
}
use of android.widget.AdapterView.AdapterContextMenuInfo in project K6nele by Kaljurand.
the class AppListActivity method onContextItemSelected.
@Override
public boolean onContextItemSelected(MenuItem item) {
final AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
Cursor cursor = (Cursor) getListView().getItemAtPosition(info.position);
final long key = cursor.getLong(cursor.getColumnIndex(App.Columns._ID));
String fname = cursor.getString(cursor.getColumnIndex(App.Columns.FNAME));
mCurrentAppId = key;
switch(item.getItemId()) {
case R.id.cmAppAssignGrammar:
Intent pickSpeakerIntent = new Intent(AppListActivity.this, GrammarListActivity.class);
startActivityForResult(pickSpeakerIntent, ACTIVITY_SELECT_GRAMMAR_URL);
return true;
case R.id.cmAppRemoveGrammar:
Utils.getYesNoDialog(this, getString(R.string.confirmRemoveGrammar), new Executable() {
public void execute() {
removeApp(key, App.Columns.GRAMMAR);
}
}).show();
return true;
case R.id.cmAppAssignServer:
Intent intentServer = new Intent(AppListActivity.this, ServerListActivity.class);
startActivityForResult(intentServer, ACTIVITY_SELECT_SERVER_URL);
return true;
case R.id.cmAppRemoveServer:
Utils.getYesNoDialog(this, getString(R.string.confirmRemoveServer), new Executable() {
public void execute() {
removeApp(key, App.Columns.SERVER);
}
}).show();
return true;
case R.id.cmAppDelete:
Utils.getYesNoDialog(this, String.format(getString(R.string.confirmDeleteEntry), fname), new Executable() {
public void execute() {
delete(CONTENT_URI, key);
}
}).show();
return true;
default:
return super.onContextItemSelected(item);
}
}
use of android.widget.AdapterView.AdapterContextMenuInfo in project K6nele by Kaljurand.
the class GrammarListActivity method onContextItemSelected.
@Override
public boolean onContextItemSelected(MenuItem item) {
final AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
Cursor cursor = (Cursor) getListView().getItemAtPosition(info.position);
final long key = cursor.getLong(cursor.getColumnIndex(Grammar.Columns._ID));
String name = cursor.getString(cursor.getColumnIndex(Grammar.Columns.NAME));
String grammarName = cursor.getString(cursor.getColumnIndex(Grammar.Columns.NAME));
String grammarLang = cursor.getString(cursor.getColumnIndex(Grammar.Columns.LANG));
String grammarUrl = cursor.getString(cursor.getColumnIndex(Grammar.Columns.URL));
switch(item.getItemId()) {
case R.id.cmGrammarView:
Intent intentView = new Intent();
intentView.setAction(Intent.ACTION_VIEW);
intentView.setDataAndType(Uri.parse(grammarUrl), "text/plain");
startActivity(intentView);
return true;
case R.id.cmGrammarEditName:
Utils.getTextEntryDialog(this, getString(R.string.dialogTitleChangeGrammarName), grammarName, new ExecutableString() {
public void execute(String name) {
if (name != null && name.length() == 0) {
name = null;
}
update(CONTENT_URI, key, Grammar.Columns.NAME, name);
}
}).show();
return true;
case R.id.cmGrammarEditLang:
Utils.getTextEntryDialog(this, getString(R.string.dialogTitleChangeGrammarLang), grammarLang, new ExecutableString() {
public void execute(String lang) {
if (lang != null && lang.length() == 0) {
lang = null;
}
update(CONTENT_URI, key, Grammar.Columns.LANG, lang);
}
}).show();
return true;
case R.id.cmGrammarEditUrl:
Utils.getTextEntryDialog(this, getString(R.string.dialogTitleChangeGrammarUrl), grammarUrl, new ExecutableString() {
public void execute(String newUrl) {
try {
updateUrl(CONTENT_URI, key, Grammar.Columns.URL, newUrl);
} catch (MalformedURLException e) {
toast(getString(R.string.exceptionMalformedUrl));
}
}
}).show();
return true;
case R.id.cmGrammarDelete:
Utils.getYesNoDialog(this, String.format(getString(R.string.confirmDeleteEntry), name), new Executable() {
public void execute() {
delete(CONTENT_URI, key);
}
}).show();
return true;
default:
return super.onContextItemSelected(item);
}
}
use of android.widget.AdapterView.AdapterContextMenuInfo in project frostwire by frostwire.
the class PlaylistFragment method onCreateContextMenu.
@Override
public void onCreateContextMenu(final ContextMenu menu, final View v, final ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
// Get the position of the selected item
final AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
final int mPosition = info.position;
menu.clear();
mItem = mAdapter.getItem(mPosition);
// Play the playlist
menu.add(Fragments.PLAYLIST_FRAGMENT_GROUP_ID, FragmentMenuItems.PLAY_SELECTION, Menu.NONE, R.string.context_menu_play_selection).setIcon(R.drawable.contextmenu_icon_play);
// Add the playlist to the queue
menu.add(Fragments.PLAYLIST_FRAGMENT_GROUP_ID, FragmentMenuItems.ADD_TO_QUEUE, Menu.NONE, R.string.add_to_queue).setIcon(R.drawable.contextmenu_icon_queue_add);
// Delete and rename (user made playlists)
long pId = mItem.mPlaylistId;
if (pId != NEW_PLAYLIST_ID && pId != FAVORITE_PLAYLIST_ID && pId != LAST_ADDED_PLAYLIST_ID) {
menu.add(Fragments.PLAYLIST_FRAGMENT_GROUP_ID, FragmentMenuItems.RENAME_PLAYLIST, Menu.NONE, R.string.context_menu_rename_playlist).setIcon(R.drawable.contextmenu_icon_rename);
menu.add(Fragments.PLAYLIST_FRAGMENT_GROUP_ID, FragmentMenuItems.DELETE, Menu.NONE, R.string.context_menu_delete).setIcon(R.drawable.contextmenu_icon_trash);
}
}
use of android.widget.AdapterView.AdapterContextMenuInfo in project netxms by netxms.
the class NodeBrowser method onCreateContextMenu.
/* (non-Javadoc)
* @see android.app.Activity#onCreateContextMenu(android.view.ContextMenu, android.view.View, android.view.ContextMenu.ContextMenuInfo)
*/
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
android.view.MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.node_actions, menu);
AdapterView.AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
selectedObject = (AbstractObject) adapter.getItem(info.position);
GeoLocation gl = selectedObject.getGeolocation();
if ((gl == null) || (gl.getType() == GeoLocation.UNSET)) {
hideMenuItem(menu, R.id.navigate_to);
}
if (selectedObject instanceof Node) {
// add available tools to context menu
List<ObjectTool> tools = service.getTools();
if (tools != null) {
SubMenu subMenu = menu.addSubMenu(Menu.NONE, 0, 0, getString(R.string.menu_tools));
Iterator<ObjectTool> tl = tools.iterator();
ObjectTool tool;
while (tl.hasNext()) {
tool = tl.next();
switch(tool.getToolType()) {
case ObjectTool.TYPE_INTERNAL:
case ObjectTool.TYPE_ACTION:
case ObjectTool.TYPE_SERVER_COMMAND:
case ObjectTool.TYPE_SERVER_SCRIPT:
if (tool.isApplicableForNode((Node) selectedObject))
subMenu.add(Menu.NONE, (int) tool.getId(), 0, tool.getDisplayName());
break;
}
}
}
} else {
hideMenuItem(menu, R.id.find_switch_port);
hideMenuItem(menu, R.id.poll);
}
}
Aggregations